作业的编辑

This commit is contained in:
cxt 2017-05-23 18:52:58 +08:00
parent 1e8a36a8d2
commit d64aba1391
9 changed files with 122 additions and 239 deletions

View File

@ -326,23 +326,15 @@ class HomeworkCommonController < ApplicationController
def edit
@user = User.current
@hw_status = params[:hw_status].to_i
@is_manage = params[:is_manage]
if @hw_status != 1
@left_nav_type = 3
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
else
respond_to do |format|
format.html{render :layout => 'base_course_community'}
end
@homework_type = @homework.homework_type
respond_to do |format|
format.html{render :layout => 'base_edu'}
end
end
def update
if params[:homework_common]
is_update = @homework.name != params[:homework_common][:name] || @homework.description != params[:homework_common][:description] || params[:homework_type].to_i != @homework.homework_type
is_update = @homework.name != params[:homework_common][:name] || @homework.description != params[:homework_common][:description]
if params[:homework_type].to_i == 2
is_update = is_update || params[:language_type] != @homework.homework_detail_programing.language
if !is_update && params[:sample] && params[:program]
@ -356,92 +348,8 @@ class HomeworkCommonController < ApplicationController
@homework.name = params[:homework_common][:name]
@homework.description = params[:homework_common][:description]
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
if params[:homework_common][:end_time] != ""
if params[:homework_common][:publish_time] == ""
@homework.publish_time = Time.now
else
@homework.publish_time = params[:homework_common][:publish_time]
end
param_end_time = Time.parse(params[:homework_common][:end_time]).to_s
homework_end_time = @homework.end_time ? @homework.end_time.to_s : ''
if homework_end_time != param_end_time
if homework_end_time > param_end_time
@homework.student_works.where("work_status = 1").each do |st|
if param_end_time < st.commit_time
st.late_penalty = @homework.late_penalty
st.work_status = 2
st.save
#更新CourseHomeworkStatistics中学生的迟交作品数
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
end
end
else
@homework.student_works.where("work_status = 2").each do |st|
if param_end_time >= Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
st.late_penalty = 0
st.work_status = 1
st.save
#更新CourseHomeworkStatistics中学生的迟交作品数
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
end
end
end
end
@homework.end_time = params[:homework_common][:end_time] || Time.now
status = false
if @homework.publish_time > Time.now && homework_detail_manual.comment_status == 1
homework_detail_manual.comment_status = 0
@homework.student_works.destroy_all
#更新CourseHomeworkStatistics中每个学生的未交作品数
@homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
end
elsif @homework.publish_time <= Time.now && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
create_works_list @homework if params[:homework_type].to_i != 3
status = true
#更新CourseHomeworkStatistics中每个学生的未交作品数
@homework.course.student.each do |student|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
end
end
eval_start = homework_detail_manual.evaluation_start
if eval_start.nil? || (Time.parse(eval_start.to_s) <= @homework.end_time && homework_detail_manual.comment_status <= 1)
homework_detail_manual.evaluation_start = (@homework.end_time + 7*24*60*60).strftime("%Y-%m-%d")
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
end
end
if params[:homework_type] && params[:homework_type].to_i != @homework.homework_type
if @homework.homework_type == 2
@homework.homework_detail_programing.destroy if @homework.homework_detail_programing
@homework.homework_tests.destroy_all
elsif @homework.homework_type == 3
@homework.homework_detail_group.destroy if @homework.homework_detail_group
create_works_list @homework if homework_detail_manual.comment_status > 0 && @homework.student_works.empty?
end
if params[:homework_type].to_i == 3
@homework.student_works.destroy_all
end
@homework.homework_type = params[:homework_type].to_i
end
anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
if anonymous != @homework.anonymous_comment
if anonymous == 1
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.4 : 1.0
else
homework_detail_manual.ta_proportion = @homework.homework_type == 2 ? 0.3 : 0.6
end
end
@homework.save_attachments(params[:attachments])
@homework.reference_answer = params[:homework_common][:reference_answer]
render_attachment_warning_if_needed(@homework)
#编程作业相关属性
@ -449,13 +357,6 @@ class HomeworkCommonController < ApplicationController
@homework.homework_detail_programing ||= HomeworkDetailPrograming.new
@homework_detail_programing = @homework.homework_detail_programing
@homework_detail_programing.language = params[:language_type].to_i if params[:language_type]
if anonymous != @homework.anonymous_comment
if anonymous == 1
@homework_detail_programing.ta_proportion = 0.6
else
@homework_detail_programing.ta_proportion = 0.5
end
end
@homework.homework_samples.delete_all if params[:sample]
sample_inputs = params[:sample][:input] if params[:sample]
@ -489,15 +390,7 @@ class HomeworkCommonController < ApplicationController
@homework_detail_group.base_on_project = params[:base_on_project] ? 1 : 0
end
if anonymous != @homework.anonymous_comment
@homework.student_works.where("work_status != 0").each do |student_work|
student_work.save
end
end
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
if @homework.save
homework_detail_manual.save if homework_detail_manual
@homework_detail_programing.save if @homework_detail_programing
@homework_detail_group.save if @homework_detail_group
@ -505,20 +398,7 @@ class HomeworkCommonController < ApplicationController
# create_works_list @homework
# end
@hw_status = params[:hw_status].to_i
if params[:is_manage] == "1"
redirect_to user_manage_homeworks_user_path(User.current.id)
elsif params[:is_manage] == "2"
redirect_to user_receive_homeworks_user_path(User.current.id)
elsif @hw_status == 1
redirect_to user_course_community_path(User.current.id)
elsif @hw_status == 2
redirect_to course_path(@course.id)
elsif @hw_status == 5
redirect_to student_work_index_url(:homework => @homework.id)
else
redirect_to homework_common_index_path(:course => @course.id)
end
redirect_to student_work_index_url(:homework => @homework.id)
end
end
end

View File

@ -1,5 +1,5 @@
<div class="edu-con-top">
<p class="ml15 color-grey">新建普通作业</p>
<p class="ml15 color-grey"><%= edit_mode ? '编辑' : '新建' %>普通作业</p>
</div>
<div class="alert alert-red mt15 none" id="new_homework_notice">
<button class="task-close fr" type="button">×</button>
@ -10,12 +10,11 @@
<div class="edu-con-bg01 mt15" style="padding:30px 0;">
<div class="ml30 mr30">
<div class="">
<%= labelled_form_for @homework, :url =>{:controller=>'homework_common',:action => 'create', :course => @course.id}, :method => "post" do |f| %>
<ul>
<input type="hidden" name="homework_type" value="<%= @homework_type %>">
<li class="clearfix mb15">
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>标题&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="homework_common[name]" id="new_homework_name" class="panel-form-width-690 panel-form-height-30 fl panel-box-sizing" maxlength="60" placeholder="最多60个字符" />
<input type="text" name="homework_common[name]" id="new_homework_name" value="<%= @homework.name %>" class="panel-form-width-690 panel-form-height-30 fl panel-box-sizing" maxlength="60" placeholder="最多60个字符" />
</li>
<li class="clearfix mb5">
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>内容&nbsp;&nbsp;&nbsp;</label>
@ -60,7 +59,6 @@
<%= link_to '取消', homework_common_index_path(:course => @course), :class => 'task-btn fr mr10' %>
</li>
</ul>
<% end %>
</div>
</div>
</div>

View File

@ -1,5 +1,7 @@
<% not_allow_select = edit_mode && @homework.student_works.has_committed.count != 0 %>
<div class="edu-con-top">
<p class="ml15 color-grey">新建分组作业</p>
<p class="ml15 color-grey"><%= edit_mode ? '编辑' : '新建' %>分组作业</p>
</div>
<div class="alert alert-red mt15 none" id="new_homework_notice">
<button class="task-close fr" type="button">×</button>
@ -10,12 +12,11 @@
<div class="edu-con-bg01 mt15" style="padding:30px 0;">
<div class="ml30 mr30">
<div class="">
<%= labelled_form_for @homework, :url =>{:controller=>'homework_common',:action => 'create', :course => @course.id}, :method => "post" do |f| %>
<ul>
<input type="hidden" name="homework_type" value="<%= @homework_type %>">
<li class="clearfix mb15">
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>标题&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="homework_common[name]" id="new_homework_name" class="panel-form-width-690 panel-form-height-30 fl panel-box-sizing" maxlength="60" placeholder="最多60个字符" />
<input type="text" name="homework_common[name]" id="new_homework_name" value="<%= @homework.name %>" class="panel-form-width-690 panel-form-height-30 fl panel-box-sizing" maxlength="60" placeholder="最多60个字符" />
</li>
<li class="clearfix mb5">
<label class=" panel-form-label fl"><span class="color-orange mr5">*</span>内容&nbsp;&nbsp;&nbsp;</label>
@ -37,13 +38,16 @@
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => @homework} %>
</li>
<li class="clearfix mb5">
<label class=" panel-form-label fl"><span class="color-orange mr5">*</span>分组设置&nbsp;&nbsp;&nbsp;</label>
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>分组设置&nbsp;&nbsp;&nbsp;</label>
<ul class="fl edu-bg-grey mb15" style="padding-bottom:10px;" >
<li class="mt10 mr10 mb10 clearfix">
<span class="ml15 mr5">每组最小人数</span>
<input id="min_num" type="text" name="min_num" class="task-form-10 task-height-40 mr5 panel-box-sizing" placeholder="2" /><span>人</span>
<input id="min_num" type="text" name="min_num" value="<%= @homework.homework_detail_group ? @homework.homework_detail_group.min_num : '' %>" class="task-form-10 task-height-40 mr5 panel-box-sizing" placeholder="2" /><span>人</span>
<span class="ml30 mr5">每组最大人数</span>
<input id="max_num" type="text" name="max_num" class="task-form-10 task-height-40 mr5 panel-box-sizing" placeholder="10"/><span>人</span>
<input id="max_num" type="text" name="max_num" value="<%= @homework.homework_detail_group ? @homework.homework_detail_group.max_num : '' %>" class="task-form-10 task-height-40 mr5 panel-box-sizing" placeholder="10"/><span>人</span>
<span class="color-orange ml15 none" data-min-num="<%= @homework.homework_detail_group ? @homework.homework_detail_group.min_num : '' %>" data-max-num="<%= @homework.homework_detail_group ? @homework.homework_detail_group.max_num : '' %>" id="min_max_num_notice">
已有学生提交作品,只能扩大分组范围,原分组人数为<%= @homework.homework_detail_group ? @homework.homework_detail_group.min_num : '' %>-<%= @homework.homework_detail_group ? @homework.homework_detail_group.max_num : '' %>人
</span>
</li>
<span class="color-orange ml15 ">注:任一成员都可以提交作品,提交作品时需要关联同组成员,组内成员作品共享。</span>
</ul>
@ -71,11 +75,10 @@
<!--</a>-->
<!--</li>-->
<li class="clearfix mt10">
<a href="javascript:void(0);" onclick="submit_new_common_homework(3);" class="task-btn task-btn-blue fr">保存</a>
<a href="javascript:void(0);" onclick="submit_new_common_homework(3, true);" class="task-btn task-btn-blue fr">保存</a>
<%= link_to '取消', homework_common_index_path(:course => @course), :class => 'task-btn fr mr10' %>
</li>
</ul>
<% end %>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
<div class="edu-con-top">
<p class="ml15 color-grey">新建编程作业</p>
<p class="ml15 color-grey"><%= edit_mode ? '编辑' : '新建' %>编程作业</p>
</div>
<div class="alert alert-red mt15 none" id="new_homework_notice">
<button class="task-close fr" type="button">×</button>
@ -11,12 +11,11 @@
<div class="edu-con-bg01 mt15 program_homework" style="padding:30px 0;">
<div class="ml30 mr30">
<div class="">
<%= labelled_form_for @homework, :url =>{:controller=>'homework_common',:action => 'create', :course => @course.id}, :method => "post" do |f| %>
<ul>
<input type="hidden" name="homework_type" value="<%= @homework_type %>">
<li class="clearfix mb15">
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>标题&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="homework_common[name]" id="new_homework_name" class="panel-form-width-690 panel-form-height-30 fl panel-box-sizing" maxlength="60" placeholder="最多60个字符" />
<input type="text" name="homework_common[name]" id="new_homework_name" value="<%= @homework.name %>" class="panel-form-width-690 panel-form-height-30 fl panel-box-sizing" maxlength="60" placeholder="最多60个字符" />
</li>
<li class="clearfix mb5">
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>内容&nbsp;&nbsp;&nbsp;</label>
@ -40,21 +39,39 @@
<li class="clearfix mb15">
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>样例设置&nbsp;&nbsp;&nbsp;</label>
<ul class="fl edu-bg-grey">
<li class="clearfix mt10 ml10 mr10">
<p class="clearfix mb5">
<span class="color-green fb fl" name="sample_inputs_label">样例1</span>
<a href="javascript:void(0);" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt5"></i></a>
<span class="color-grey fr font-12">温馨提示:请至少输入一组样例供学生参考。</span>
</p>
<textarea class="task-form-100 task-height-40 mb10 panel-box-sizing" placeholder="样例输入" name="sample[input][]"></textarea>
<textarea class="task-form-100 task-height-40 mb10 panel-box-sizing" placeholder="样例输出" name="sample[output][]"></textarea>
</li>
<% if edit_mode && @homework.homework_samples.count > 0 %>
<% @homework.homework_samples.each_with_index do |sample, index| %>
<li class="clearfix mt10 ml10 mr10">
<p class="clearfix mb5">
<span class="color-green fb fl" name="sample_inputs_label">样例<%= index + 1 %></span>
<a href="javascript:void(0);" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt5"></i></a>
<% if index != 0 %>
<a href="javascript:void(0);" title="删除" class="sample_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt5"></i></a>
<% else %>
<span class="color-grey fr font-12">温馨提示:请至少输入一组样例供学生参考。</span>
<% end %>
</p>
<textarea class="task-form-100 task-height-40 mb10 panel-box-sizing" placeholder="样例输入" name="sample[input][]"><%= sample.input %></textarea>
<textarea class="task-form-100 task-height-40 mb10 panel-box-sizing" placeholder="样例输出" name="sample[output][]"><%= sample.output %></textarea>
</li>
<% end %>
<% else %>
<li class="clearfix mt10 ml10 mr10">
<p class="clearfix mb5">
<span class="color-green fb fl" name="sample_inputs_label">样例1</span>
<a href="javascript:void(0);" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt5"></i></a>
<span class="color-grey fr font-12">温馨提示:请至少输入一组样例供学生参考。</span>
</p>
<textarea class="task-form-100 task-height-40 mb10 panel-box-sizing" placeholder="样例输入" name="sample[input][]"></textarea>
<textarea class="task-form-100 task-height-40 mb10 panel-box-sizing" placeholder="样例输出" name="sample[output][]"></textarea>
</li>
<% end %>
</ul>
</li>
<li class="clearfix mb15">
<label class="panel-form-label fl"><span class="color-orange mr5">*</span>测试集设置&nbsp;&nbsp;&nbsp;</label>
<ul class="fl edu-bg-grey">
<li class="clearfix mt10 ml10 mr10 ">
<li class="clearfix mt10 ml10 mr10">
<p class="clearfix">
<select class="fl task-form-10 task-height-40" name="language_type">
<%= options_for_select({"C语言" => 1, "C++" => 2, "Python" => 3, "Java" => 4}, 1) %>
@ -62,14 +79,30 @@
<span class="color-grey fr font-12" >温馨提示:您可以在发布后,通过"模拟答题"进行标准代码的检测。</span>
</p>
</li>
<li class="clearfix mt10 ml10 mr10">
<p class="clearfix mb5">
<span class="color-green fb fl" name="inputs_label">测试1</span>
<a href="javascript:void(0);" title="增加" class="test_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt5"></i></a>
</p>
<textarea class="task-form-50 task-height-40 mb10 fl panel-box-sizing" placeholder="测试输入" name="program[input][]"></textarea>
<textarea class="task-form-45 task-height-40 mb10 fl ml10 panel-box-sizing" placeholder="测试输出" name="program[output][]" style="width:49%;"></textarea>
</li>
<% if edit_mode %>
<% @homework.homework_tests.each_with_index do |test, index| %>
<li class="clearfix mt10 ml10 mr10">
<p class="clearfix mb5">
<span class="color-green fb fl" name="inputs_label">测试<%= index + 1 %></span>
<a href="javascript:void(0);" title="增加" class="test_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt5"></i></a>
<% if index != 0 %>
<a href="javascript:void(0);" title="删除" class="test_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt5"></i></a>
<% end %>
</p>
<textarea class="task-form-50 task-height-40 mb10 fl panel-box-sizing" placeholder="测试输入" name="program[input][]"><%= test.input %></textarea>
<textarea class="task-form-45 task-height-40 mb10 fl ml10 panel-box-sizing" placeholder="测试输出" name="program[output][]" style="width:49%;"><%= test.output %></textarea>
</li>
<% end %>
<% else %>
<li class="clearfix mt10 ml10 mr10">
<p class="clearfix mb5">
<span class="color-green fb fl" name="inputs_label">测试1</span>
<a href="javascript:void(0);" title="增加" class="test_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt5"></i></a>
</p>
<textarea class="task-form-50 task-height-40 mb10 fl panel-box-sizing" placeholder="测试输入" name="program[input][]"></textarea>
<textarea class="task-form-45 task-height-40 mb10 fl ml10 panel-box-sizing" placeholder="测试输出" name="program[output][]" style="width:49%;"></textarea>
</li>
<% end %>
</ul>
</li>
<li class="clearfix mb5">
@ -99,7 +132,6 @@
<%= link_to '取消', homework_common_index_path(:course => @course), :class => 'task-btn fr mr10' %>
</li>
</ul>
<% end %>
</div>
</div>
</div>

View File

@ -1,63 +1,19 @@
<script type="text/javascript">
<% if @hw_status != 1 %>
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
<% end %>
function reset_homework(){
$("#homework_name").val("");
$("#homework_publish_time").val("");
$("#homework_end_time").val("");
$("#course_id").val($("#option_select").val());
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>");
//homework_description_editor.html("");
$("#homework_name_span").text("");
$("#homework_end_time_span").text("");
$("#homework_end_time_span").text("");
$("#homework_course_id_span").text("");
$("#homework_editor").toggle();
}
function cancel_edit(){
<% if @is_manage.to_i == 1 %>
window.location.href='<%=user_manage_homeworks_user_path(User.current.id) %>';
<% elsif @is_manage.to_i == 2 %>
window.location.href='<%=user_receive_homeworks_user_path(User.current.id) %>';
<% elsif @hw_status == 3 %>
window.location.href='<%=homework_common_index_path(:course => @course.id) %>';
<% elsif @hw_status == 1 %>
window.location.href='<%=user_path(User.current.id) %>';
<% elsif @hw_status == 2 %>
window.location.href='<%=course_path(@course.id) %>';
<% end %>
}
</script>
<div class="homepageRightBanner mb10 <%= (@hw_status == 2 || @hw_status == 3 || @hw_status == 5) ? 'ml10' : '' %>">
<div class="NewsBannerName">编辑作业</div>
</div>
<div class="cl"></div>
<!-- 老师身份才可以发布作业 -->
<div class="HomeWork mb10 ml10" nhname='homework_common_form'>
<% committed_work_count = @homework.student_works.has_committed.count %>
<% stu_pro_count = @homework.student_work_projects.count %>
<% if committed_work_count != 0 %>
<% if @homework.homework_type == 1 %>
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型。</p>
<% elsif @homework.homework_type == 2 %>
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和测试集。</p>
<% elsif @homework.homework_type == 3 %>
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和分组设置(可扩大分组范围)。</p>
<% content_for :header_tags do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<% end %>
<div class="edu-class-container" style="min-height: 760px;">
<p class="mb10">
<i class="fa fa-map-marker mr5 color-grey" ></i>
<%= link_to '班级首页', course_path(@course) %> >
<%= link_to '作业列表', homework_common_index_path(:course => @course) %> >
编辑</p>
<%= form_for @homework, :html => {:id => 'homework_common_submit_form'} do |f| %>
<% if @homework_type == 1 %>
<%= render :partial => 'new_common_homework', :locals => {:f => f, :edit_mode => true} %>
<% elsif @homework_type == 2 %>
<%= render :partial => 'new_program_homework', :locals => {:f => f, :edit_mode => true} %>
<% elsif @homework_type == 3 %>
<%= render :partial => 'new_group_homework', :locals => {:f => f, :edit_mode => true} %>
<% end %>
<% elsif stu_pro_count != 0 && @homework.homework_type == 3 %>
<p class="c_red mb5">已有<%=stu_pro_count %>个学生关联项目,不允许再修改作业类型。</p>
<% end %>
<%= form_for @homework do |f| %>
<input type="text" name="hw_status" class="none" value="<%= @hw_status%>"/>
<input type="text" name="is_manage" class="none" value="<%= @is_manage%>"/>
<div id="HomeWorkCon">
<%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
</div>
<% end%>
</div><!----HomeWork end-->
</div>

View File

@ -7,11 +7,13 @@
<%= link_to '班级首页', course_path(@course) %> >
<%= link_to '作业列表', homework_common_index_path(:course => @course) %> >
新建</p>
<% if @homework_type == 1 %>
<%= render :partial => 'new_common_homework' %>
<% elsif @homework_type == 2 %>
<%= render :partial => 'new_program_homework' %>
<% elsif @homework_type == 3 %>
<%= render :partial => 'new_group_homework' %>
<%= labelled_form_for @homework, :url =>{:controller=>'homework_common',:action => 'create', :course => @course.id}, :html => {:id => 'homework_common_submit_form'}, :method => "post" do |f| %>
<% if @homework_type == 1 %>
<%= render :partial => 'new_common_homework', :locals => {:f => f, :edit_mode => false} %>
<% elsif @homework_type == 2 %>
<%= render :partial => 'new_program_homework', :locals => {:f => f, :edit_mode => false} %>
<% elsif @homework_type == 3 %>
<%= render :partial => 'new_group_homework', :locals => {:f => f, :edit_mode => false} %>
<% end %>
<% end %>
</div>

View File

@ -54,12 +54,19 @@
<div class="fr edu-position edu-position-hidebox">
<a href="javascript:void(0);" class="font-16"><i class="fa fa-bars"></i></a>
<ul class="edu-position-hide undis" style="left:-85px;">
<% if @homework.homework_type != 4 %>
<li>
<%= link_to l(:button_edit), edit_homework_common_path(@homework) %>
</li>
<% end %>
<li>
<%= link_to "设置", setting_homework_common_path(@homework) %>
</li>
<% if @homework.homework_type != 4 %>
<li>
<%= link_to '进入实训', edit_homework_common_path(@homework) %>
</li>
<% end %>
<% if (User.current.teacher_of_course(@homework.course) || @homework.user == User.current) && User.current.homework_banks.where(:homework_common_id => @homework.id).empty? %>
<li>
<%= link_to "加入题库", add_to_homework_bank_homework_common_path(@homework, :type => 1)%>
@ -127,13 +134,13 @@
<li class="clearfix mb15">
<label class="panel-form-label fl color-grey">样例输入&nbsp;&nbsp;&nbsp;</label>
<div class="fl edu-bg-grey">
<pre class="mt10 ml10 mr10 mb10" style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=sample.input.nil? ? " " : sample.input %></pre>
<pre class="mt10 ml10 mr10 mb10" style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=sample.input.blank? ? " " : sample.input %></pre>
</div>
</li>
<li class="clearfix mb15">
<label class="panel-form-label fl color-grey">样例输出&nbsp;&nbsp;&nbsp;</label>
<div class="fl edu-bg-grey">
<pre class="mt10 ml10 mr10 mb10" style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=sample.output.nil? ? " " : sample.output %></pre>
<pre class="mt10 ml10 mr10 mb10" style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=sample.output.blank? ? " " : sample.output %></pre>
</div>
</li>
</ul>
@ -162,10 +169,10 @@
<tr>
<td class="edu-txt-center"><%=i+1 %></td>
<td style="height:100%; width:48%;">
<div style="height:100%; width:100%; "><pre style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=test.input.nil? ? " " : test.input %></pre></div>
<div style="height:100%; width:100%; "><pre style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=test.input.blank? ? " " : test.input %></pre></div>
</td>
<td style="height:100%; width:48%;">
<div style=" height:100%; width:100%;"><pre style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=test.output.nil? ? " " : test.output %></pre></div>
<div style=" height:100%; width:100%;"><pre style="font-family: '微软雅黑','宋体'; word-wrap:break-word; white-space:pre-wrap;"><%=test.output.blank? ? " " : test.output %></pre></div>
</td>
</tr>
<% end %>
@ -448,8 +455,6 @@
</div>
<div id="edu-tab-con-3" class="undis">
<div class="edu-tab-con-box">
<a href="javascript:void(0);" class="link-color-grey fr font-16 mt8" title="编辑"><i class="fa fa-edit mr15"></i></a>
<div class="cl"></div>
<div>
<% if @homework.reference_answer %>
<%= @homework.reference_answer.html_safe %>

View File

@ -133,9 +133,9 @@
<tbody>
<tr>
<td style=" height:100%; width:48%;">
<div style="height:100%; width:100%; "><%= x["output"].nil? ? "" : x["output"].force_encoding("UTF-8") %></div></td>
<div style="height:100%; width:100%; "><%= x["output"].blank? ? "" : x["output"].force_encoding("UTF-8") %></div></td>
<td style=" height:100%; width:48%;">
<div style=" height:100%; width:100%;"><%= x["result"].nil? ? "" : x["result"].force_encoding("UTF-8") %></div>
<div style=" height:100%; width:100%;"><%= x["result"].blank? ? "" : x["result"].force_encoding("UTF-8") %></div>
</td>
</tr>
</tbody>

View File

@ -725,7 +725,7 @@ function student_choose_group(course_id, member_id){
});
}
function submit_new_common_homework(type){
function submit_new_common_homework(type, edit_mode){
var notice_count = 0;
$("#new_homework_notice_count").parent().hide();
$("#new_homework_notice>ul").empty();
@ -767,12 +767,19 @@ function submit_new_common_homework(type){
notice_count++;
$("#new_homework_notice>ul").append("<li>分组最小人数不得大于最大人数</li>");
}
if(edit_mode){
var data_min = parseInt($("#min_max_num_notice").attr("data-min-num"));
var data_max = parseInt($("#min_max_num_notice").attr("data-max-num"));
if(parseInt(min) > data_min || parseInt(max) < data_max){
$("#min_max_num_notice").show();
return false;
}
}
}
if(notice_count == 0){
homework_description_editor.sync();
homework_ref_answer_editor.sync();
$("#new_homework_common").submit();
console.log("111111111111111111");
$("#homework_common_submit_form").submit();
} else{
$("#new_homework_notice_count").html(notice_count);
$("#new_homework_notice_count").parent().show();
@ -786,7 +793,7 @@ function SearchByName_1(url)
$.get(
url,
{
name : $("#course_student_name").val(),
name : $("#course_student_name").val()
},
function (data) {
}