新版发布作业

This commit is contained in:
cxt 2016-09-13 16:18:57 +08:00
parent 9bc40d2fad
commit 9002844188
12 changed files with 275 additions and 135 deletions

View File

@ -85,6 +85,7 @@ class HomeworkCommonController < ApplicationController
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
@homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id]
@homework.homework_type = params[:homework_type].to_i || @homework.homework_type
anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0
if anonymous != @homework.anonymous_comment
if anonymous == 1

View File

@ -1052,7 +1052,7 @@ class UsersController < ApplicationController
else
homework.publish_time = params[:homework_common][:publish_time]
end
homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
homework.homework_type = params[:homework_type].to_i || 1
homework.late_penalty = 10
homework.teacher_priority = 1

View File

@ -3521,3 +3521,21 @@ def get_forge_act_message(act, type)
format_time(forge_act.nil? ? act.created_on : forge_act.try(:updated_at))
end
#作业类型
def homework_type_option
type = []
option1 = []
option1 << "普通作业"
option1 << 1
option2 = []
option2 << "编程作业"
option2 << 2
option3 = []
option3 << "分组作业"
option3 << 3
type << option1
type << option2
type << option3
type
end

View File

@ -41,6 +41,20 @@
<!-- 老师身份才可以发布作业 -->
<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>
<% 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="is_in_course" class="none" value="<%= @is_in_course%>"/>
<input type="text" name="course_activity" class="none" value="<%= @course_activity%>"/>

View File

@ -1,27 +1,27 @@
<span class="f16 fontBlue">分组设置</span>
<a href="javascript:void(0);" class="popClose" title="关闭弹框"></a>
<div class="mt10">
<span class="f14 fontGrey3 mr5">每组最小人数:</span>
<input id="min_num" type="text" name="" class="markInput" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.min_num : 2 %>" />人
<span class="c_red undis" id="min_num_notice"></span>
<div id="groupHomework">
<div> <span class="f14 mt5 fl fontGrey3 mr10">分组设置:</span>
<div class="mr50 fl"> <span class="f14 fontGrey3 mr5">每组最小人数:</span>
<input id="min_num" type="text" name="min_num" class="markInput" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.min_num : 2 %>" <%=not_allow_select ? 'disabled' : '' %>/>人
</div>
<div class="fl"> <span class="f14 fontGrey3 mr5">每组最大人数:</span>
<input id="max_num" type="text" name="max_num" class="markInput" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.max_num : 10 %>" <%=not_allow_select ? 'disabled' : '' %>/>人
</div>
<span class="c_red undis ml20 mt7 fl" id="min_max_num_notice"></span>
<div class="cl"></div>
<div class="ml80">
<label>
<input type="checkbox" class="mr5" name="base_on_project" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.base_on_project : 1 %>" id="base_on_project" <%=not_allow_select ? 'disabled' : '' %>/>
<span class="f14 fontGrey3 mr10">基于项目实施</span>
</label>
<p class="c_red">提醒勾选后各小组必须在Trustie平台创建项目教师可随时观察平台对各小组最新进展的实时统计</p>
</div>
<div class="cl"></div>
</div>
</div>
<div class="mt10">
<span class="f14 fontGrey3 mr5">每组最大人数:</span>
<input id="max_num" type="text" name="" class="markInput" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.max_num : 10 %>" />人
<span class="c_red undis" id="max_num_notice"></span>
</div>
<p class="c_red undis" id="min_max_num_notice"></p>
<div class="mb10 mt10">
<label>
<input type="checkbox" class="mr5" name="base_on_project" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.base_on_project : 1 %>" id="base_on_project"/>
<span class="f14 fontGrey3 mr10">基于项目实施</span>
</label>
<p class="c_red">提醒勾选后各小组必须在Trustie平台创建项目教师可随时观察平台对各小组最新进展的实时统计</p>
</div>
<div class="courseSendSubmit">
<a href="javascript:void(0);" class="group_save_btn sendSourceText">确定</a>
</div>
<div class="courseSendCancel">
<a href="javascript:void(0);" class="sendSourceText linkGrey6" id="cancel_group">取消</a>
</div>
<div class="cl"></div>
<div class="cl"></div>
<script>
if($.trim($("#base_on_project").val()) == 1) {
$("#base_on_project").attr('checked','checked');
}
</script>

View File

@ -71,17 +71,6 @@
<!-- , user_import_resource_user_path(User.current.id,:homework_id=>container.id) -->
<a href="javascript:void(0);" class="AnnexBtn fl mt3 mr15" onclick="$('#_file').click();" title="请选择文件上传">上传附件</a>
<%= link_to "资源库", user_ref_resource_search_user_path(User.current.id, :homework_id => container.id), :class => "FilesBtn fl mt3 mr15", :title => "请从资源库中选择文件作为作业的附件", :remote => true %>
<% if defined?(has_program) && has_program %>
<div id="program_setting" class="fl">
<a href="javascript:void(0);" class="ProBtn fl mt3"title="请设置编程语言和输入测试集">编程</a>
<span class="fl C_lgrey mt3 program_detail_info mr15"></span>
</div>
<% end %>
<% if defined?(has_group) && has_group %>
<div id="group_setting" class="fl">
<a href="javascript:void(0);" class="groupBtn fl mt3" title="请设置分组作业的相关参数">分组</a>
</div>
<% end %>
</div>
<% content_for :header_tags do %>

View File

@ -1,3 +1,4 @@
<% not_allow_select = edit_mode && homework.student_works.has_committed.count != 0 %>
<% content_for :header_tags do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
@ -5,14 +6,31 @@
<script type="text/javascript">
var first_click = true;
$(function(){
$("#homework_type_option").on("change",function(){
var type = $(this).children('option:selected').val()
if(type == "1"){
$("#homeworkSetting").addClass("undis");
$("#homeworkSetting").html("");
}else if(type == "2"){
$("#homeworkSetting").removeClass("undis");
$("#homeworkSetting").html("<%=escape_javascript(render :partial => 'users/user_programing_attr', :locals => {:edit_mode => edit_mode, :homework=>homework, :not_allow_select => not_allow_select}) %>");
}else{
$("#homeworkSetting").removeClass("undis");
$("#homeworkSetting").html("<%=escape_javascript(render :partial => 'users/user_group_attr', :locals => {:edit_mode => edit_mode, :homework=>homework, :not_allow_select => not_allow_select}) %>");
}
});
if($.trim($("#anonymous_comment").val()) == 1) {
$("#anonymous_comment").attr('checked',true);
} else {
$("#anonymous_comment").attr('checked',false);
} else {
$("#anonymous_comment").attr('checked',true);
}
if($.trim($("#base_on_project").val()) == 1) {
$("#base_on_project").attr('checked','checked');
}
<% if edit_mode && homework.homework_type == 2 %>
$("#homeworkSetting").removeClass("undis");
$("#homeworkSetting").html("<%=escape_javascript(render :partial => 'users/user_programing_attr', :locals => {:edit_mode => edit_mode, :homework=>homework, :not_allow_select => not_allow_select}) %>");
<% elsif edit_mode && homework.homework_type == 3 %>
$("#homeworkSetting").removeClass("undis");
$("#homeworkSetting").html("<%=escape_javascript(render :partial => 'users/user_group_attr', :locals => {:edit_mode => edit_mode, :homework=>homework, :not_allow_select => not_allow_select}) %>");
<% end %>
<% if edit_mode && homework.is_program_homework? %>
$("#BluePopupBox a.BlueCirBtn").click();
<% end %>
@ -21,15 +39,15 @@
<% end %>
<% if edit_mode %>
$("#anonymous_comment").on('click',function(){
$("#anonymous_hint").show();
$("#homework_end_time_span").html("更改后评分比例将恢复默认值");
});
<% end %>
});
function checked_val() {
if ($("#anonymous_comment").is(":checked")) {
$("#anonymous_comment").val(1);
} else {
$("#anonymous_comment").val(0);
} else {
$("#anonymous_comment").val(1);
}
}
function nh_reset_homework_form(params){
@ -63,6 +81,10 @@
else if(!regex_course_id()){
$("#course_id").focus();
}
else if($("#homework_type_option").val() == 2 && !regex_program_attr()) {
}
else if($("#homework_type_option").val() == 3 && !regex_group_attr()) {
}
else{
params.textarea.html(params.editor.html());
params.editor.sync();
@ -154,28 +176,29 @@
<div class="HomeWorkCon">
<a id="submit_homework"></a>
<div>
<input type="text" name="homework_common[name]" id="homework_name" class="InputBox w701" maxlength="255" onfocus="$('#homework_editor').show()" onkeyup="regex_homework_name();" placeholder="发布作业,请先输入作业标题" value="<%= homework.name%>" >
<input type="text" name="homework_common[name]" id="homework_name" class="InputBox fl <%= edit_mode ? 'w701' : 'w603' %>" maxlength="255" onfocus="$('#homework_editor').show()" onkeyup="regex_homework_name();" placeholder="发布作业,请先输入作业标题" value="<%= homework.name%>" >
<%= link_to("从题库选用", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fr",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%>
<% unless edit_mode %>
<input type="hidden" name="quotes" id="ref_homework_id" value=""/>
<% end %>
<div class="cl"></div>
<p id="homework_name_span" class="c_red mt5"></p>
</div>
<div class="cl"></div>
<div class=" mt10">
<%= link_to("从题库选用", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%>
<% unless edit_mode %>
<input type="hidden" name="quotes" id="ref_homework_id" value=""/>
<% end %>
<%# if edit_mode %>
<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>
<%# end %>
<div class="mt10">
<% group_pro = homework.homework_type == 3 && homework.student_work_projects.count != 0 %>
<select class="homework-type-option fl mr10" name="homework_type" <%=(not_allow_select || group_pro) ? 'disabled' : '' %> id="homework_type_option">
<%= options_for_select(homework_type_option,homework.homework_type) %>
</select>
<label class="fl c_grey f14 mt5">截止日期:</label>
<div class="calendar_div fl mr10">
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
<% if homework.homework_detail_manual.comment_status.to_i < 2 %>
<%= calendar_for('homework_end_time')%>
<% end %>
</div>
<%# if edit_mode %>
<label class="fl c_grey f14" style="margin-top: 4px;">发布日期(可选)</label>
<%# end %>
<label class="fl c_grey f14 mt5" style="margin-top: 4px;">发布日期(可选):</label>
<div class="calendar_div fl">
<% allow_edit = homework.student_works.has_committed.count == 0 && homework.student_work_projects.count ==0 %>
<input title="<%=allow_edit ? '' : '已有学生提交作品或关联项目,发布日期不可再编辑' %>" type="text" name="homework_common[publish_time]" id="homework_publish_time" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.publish_time%>" >
@ -184,10 +207,10 @@
<% end %>
</div>
<% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
<div class="fl f14 ml10" style="margin-top: 4px;">
<div class="fr f14 ml10" style="margin-top: 4px;">
<input type="checkbox" name="homework_common[anonymous_comment]" value="<%=edit_mode ? homework.anonymous_comment : 1 %>" id="anonymous_comment"/>
<span class="f14 c_grey">用匿评</span>
<span id="anonymous_hint" style="display: none; font-size: 12px;" class="c_red">更改后评分比例将恢复默认值</span>
<span class="f14 c_grey">用匿评</span>
<!--<span id="anonymous_hint" style="display: none; font-size: 12px;" class="c_red">更改后评分比例将恢复默认值</span>-->
</div>
<% end %>
</div>
@ -216,9 +239,13 @@
<p id="e_tips" class="c_grey"></p>
<div class="cl"></div>
<div class="mt10 b_grey undis" style="padding:10px;" id="homeworkSetting">
</div>
<div id="homework_attachments">
<!-- 编辑作业 && 作业类型为匿评作业 时没有编程选项-->
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type != 2), :has_group=>(!(edit_mode && homework.homework_type != 3))&& homework.student_works.empty?,:show_member => true} %>
<!-- 编辑作业 && 作业类型为匿评作业时没有编程选项-->
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :show_member => true} %>
</div>
<div class="mt5">
@ -234,50 +261,21 @@
<% end %>
<div class="cl"></div>
</div>
<input type="hidden" name="homework_type" value="<%= edit_mode ? homework.homework_type : 1 %>">
</div>
</div>
<div class="cl"></div>
<script id="t:test-answer-list" type="text/html">
<div class="mt10">
<label class="fl mt5" name="inputs_label">&nbsp;&nbsp;&nbsp;</label>
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" name="program[input][]"></textarea>
<textarea class="InputBox W320 fl mr5" placeholder="测试输出" name="program[output][]"></textarea>
<div class="mt10" style="margin-left:63px;">
<label class="fl fontGrey2 mr10 mt5" name="inputs_label">&nbsp;&nbsp;&nbsp;</label>
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]"></textarea>
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]"></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
<div class="cl"></div>
</div>
</script>
<script type="text/html" id="t:program-input-list">
<div class="program-input">
<input type="hidden" name="language_type" value="<!= language_type !>" />
<! for(var i=0; i< input_groups.length; ++i) { !>
<input name="program[input][]" type="hidden" value="<!= input_groups[i].input !>" />
<input name="program[output][]" type="hidden" value="<!= input_groups[i].output !>" />
<! } !>
</div>
</script>
<script id="t:group-input-list" type="text/html">
<div class="group-input">
<input type="hidden" name="min_num" value="<!= min_num !>" />
<input type="hidden" name="max_num" value="<!= max_num !>" />
<input type="hidden" name="base_on_project" value="<!= base_on_project !>" />
</div>
</script>
<div class="BluePopupBox" id="BluePopupBox" style="display:none;">
<%= render :partial => 'users/user_programing_attr', :locals => {:edit_mode => edit_mode, :homework=>homework} %>
</div><!----BluePopupBox end-->
<div class="BluePopupBox" style="display:none;" id="GroupPopupBox">
<%= render :partial => 'users/user_group_attr', :locals => {:edit_mode => edit_mode, :homework=>homework}%>
</div>
<% unless edit_mode %>
<div class="BluePopupBox" style="display:none;" id="NoticePopupBox">
<%= render :partial => 'users/homework_type_notice', :locals => {:edit_mode => edit_mode, :homework=>homework}%>

View File

@ -1,46 +1,63 @@
<a href="javascript:void(0);" class="CloseBtn" title="关闭弹框"></a>
<h2 class="BluePopuph2 fl">编程作业的测试集设置</h2>
<div class="cl"></div>
<div class="HomeWorkCon">
<div class="mt15">
<select class="InputBox W120 language_type" >
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3, "Java"=>4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
</select>
</div>
<div style="height: 320px; overflow-y:auto; width:756px;">
<div id="programHomework">
<span class="f14 mt5 fl fontGrey3 mr10">测试集设置:</span>
<select class="InputBox W120 language_type" name="language_type" <%=not_allow_select ? 'disabled' : '' %>>
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3, "Java"=>4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
</select>
<span class="f12 c_red mt5 fr">温馨提示:您可以在发布作业后,在作业"模拟答题"中进行标准代码的检测。</span>
<div class="cl"></div>
<% if edit_mode && homework.is_program_homework? %>
<% homework.homework_tests.each_with_index do |test, index| %>
<div class="mt10">
<label class="fl mt5" name="inputs_label"><%=index+1 %>&nbsp;&nbsp;</label>
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" name="program[input][]"><%= test.input %></textarea>
<textarea class="InputBox W320 fl mr5" placeholder="测试输出" name="program[output][]"><%= test.output %></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<% if index != 0 %>
<div class="mt10" style="margin-left:63px;">
<label class="fl fontGrey2 mr10 mt5" name="inputs_label"><%=index+1 %>&nbsp;&nbsp;</label>
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]" <%=not_allow_select ? 'disabled' : '' %>><%= test.input %></textarea>
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]" <%=not_allow_select ? 'disabled' : '' %>><%= test.output %></textarea>
<% unless not_allow_select %>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<% if index != 0 %>
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
<% end %>
<div class="cl"></div>
<% end %>
<% end %>
<div class="cl"></div>
</div>
<% end %>
<% else %>
<div class="mt10">
<label class="fl mt5" name="inputs_label">1&nbsp;&nbsp;</label>
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" name="program[input][]" id="textarea_input_test"></textarea>
<textarea class="InputBox W320 fl mr5" placeholder="测试输出" name="program[output][]" id="textarea_output_test"></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<div class="cl"></div>
<div class="mt10" style="margin-left:63px;">
<label class="fl fontGrey2 mr10 mt5" name="inputs_label">1&nbsp;&nbsp;</label>
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]" id="textarea_input_test"></textarea>
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]" id="textarea_output_test"></textarea>
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
<div class="cl"></div>
</div>
<% end %>
</div>
<div class="mt10">
<span class="f12 c_red db mt5 fl">温馨提示:您可以在发布作业后,在作业“模拟答题”中进行标准代码的检测。</span>
<a href="#submit_homework" class="BlueCirBtn fr">确&nbsp;&nbsp;定</a>
<div class="cl"></div>
</div>
</div><!----HomeWorkCon end-->
</div>
<script>
$(function(){
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
$("#programHomework").on('click', 'a.icon_add', function(){
var html = bt('t:test-answer-list', null);
$(this).parent('.mt10').after(html);
var inputs = document.getElementsByName("program[input][]");
var outputs = document.getElementsByName("program[output][]");
var inputs_labels = document.getElementsByName("inputs_label");
for(var j= 0; j<inputs_labels.length; j++){
$(inputs_labels[j]).html(j + 1 + "&nbsp;&nbsp;" );
}
if (inputs.length == outputs.length) {
for (var i=0; i<inputs.length; i++) {
autoTextarea2(inputs[i], outputs[i]);
autoTextarea2(outputs[i], inputs[i]);
}
}
$(inputs[inputs.length - 1]).focus();
});
$("#programHomework").on('click', 'a.icon_remove', function(){
$(this).parent('.mt10').remove();
});
});
<% if !edit_mode %>
var text = document.getElementById("textarea_input_test");
var text2 = document.getElementById("textarea_output_test");

View File

@ -10,11 +10,11 @@ $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users
homework_description_editor.html("<%= escape_javascript(@homework.description.html_safe)%>");
//$("input[name='homework_type']").val("<%#= @homework.homework_type%>");
<% if @homework_detail_programing %>
$("#BluePopupBox").html("<%=escape_javascript( render :partial => 'users/user_programing_attr', :locals => {:edit_mode => true, :homework => @homework})%>");
$("#BluePopupBox a.BlueCirBtn").click();
$("#homeworkSetting").removeClass("undis");
$("#homeworkSetting").html("<%=escape_javascript(render :partial => 'users/user_programing_attr', :locals => {:edit_mode => true, :homework=>@homework, :not_allow_select => false}) %>");
<% elsif @homework_detail_group %>
$('span.group_detail_info').text('分组人数:<%=@homework_detail_group.min_num %>-<%=@homework_detail_group.max_num %> 人');
$("#GroupPopupBox").html("<%=escape_javascript( render :partial => 'users/user_group_attr', :locals => {:edit_mode => true, :homework => @homework})%>");
$("#GroupPopupBox a.group_save_btn").click();
$("#homeworkSetting").removeClass("undis");
$("#homeworkSetting").html("<%=escape_javascript(render :partial => 'users/user_group_attr', :locals => {:edit_mode => true, :homework=>@homework, :not_allow_select => false}) %>");
<% end %>
$("#homework_type_option option[value='<%=@homework.homework_type %>']").attr("selected",true);
$("#homework_editor").show();

View File

@ -815,6 +815,57 @@ function regex_course_id(){
}
}
//验证分组作业的参数
function regex_group_attr(){
var min = $.trim($("#min_num").val());
var max = $.trim($("#max_num").val());
var regex = /^\d+$/;
if(!regex.test(min) || parseInt(min) <= 0) {
$("#min_max_num_notice").html("人数为正整数");
$("#min_max_num_notice").show();
$("#min_num").focus();
return false;
} else {
$("#min_max_num_notice").html("");
$("#min_max_num_notice").hide();
}
if(!regex.test(max) || parseInt(max) <= 0) {
$("#min_max_num_notice").html("人数为正整数");
$("#min_max_num_notice").show();
$("#max_num").focus();
return false;
} else {
$("#min_max_num_notice").html("");
$("#min_max_num_notice").hide();
}
if(parseInt(min) > parseInt(max)) {
$("#min_max_num_notice").html("最小人数不得大于最大人数");
$("#min_max_num_notice").show();
$("#max_num").focus();
return false;
} else {
$("#min_max_num_notice").html("");
$("#min_max_num_notice").hide();
}
if ($("#base_on_project").is(":checked")) {
$("#base_on_project").val(1);
} else {
$("#base_on_project").val(0);
}
return true;
}
//验证编程作业的参数
function regex_program_attr() {
$.each($('#programHomework textarea.InputBox'), function(i, val){
if ($(val).val().length<=0) {
$(val)[0].focus();
return false;
}
});
return true;
}
function regexHomeworkCommonName()
{
var name = $.trim($("#homework_attach_name").val());

View File

@ -194,6 +194,57 @@ function regex_course_id(){
}
}
//验证分组作业的参数
function regex_group_attr(){
var min = $.trim($("#min_num").val());
var max = $.trim($("#max_num").val());
var regex = /^\d+$/;
if(!regex.test(min) || parseInt(min) <= 0) {
$("#min_max_num_notice").html("人数为正整数");
$("#min_max_num_notice").show();
$("#min_num").focus();
return false;
} else {
$("#min_max_num_notice").html("");
$("#min_max_num_notice").hide();
}
if(!regex.test(max) || parseInt(max) <= 0) {
$("#min_max_num_notice").html("人数为正整数");
$("#min_max_num_notice").show();
$("#max_num").focus();
return false;
} else {
$("#min_max_num_notice").html("");
$("#min_max_num_notice").hide();
}
if(parseInt(min) > parseInt(max)) {
$("#min_max_num_notice").html("最小人数不得大于最大人数");
$("#min_max_num_notice").show();
$("#max_num").focus();
return false;
} else {
$("#min_max_num_notice").html("");
$("#min_max_num_notice").hide();
}
if ($("#base_on_project").is(":checked")) {
$("#base_on_project").val(1);
} else {
$("#base_on_project").val(0);
}
return true;
}
//验证编程作业的参数
function regex_program_attr() {
$.each($('#programHomework textarea.InputBox'), function(i, val){
if ($(val).val().length<=0) {
$(val)[0].focus();
return false;
}
});
return true;
}
//老师导入作业时查询作业
function search_homework_by_name(url){
$.get(

View File

@ -270,6 +270,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.w350{ width:350px;}
.w610{ width:610px;}
.w600{ width:600px !important;}
.w603{ width:603px !important;}
.w606{ width:606px; }
.w620{ width:620px;}
.w680{ width: 680px;}