新建作业的时候,必须先选择作业类型

This commit is contained in:
cxt 2016-11-18 10:43:49 +08:00
parent 4d7dbc1fc6
commit db71b1578b
4 changed files with 71 additions and 50 deletions

View File

@ -3724,6 +3724,9 @@ end
#作业类型
def homework_type_option
type = []
option0 = []
option0 << "请选择"
option0 << 0
option1 = []
option1 << "普通作业"
option1 << 1
@ -3733,6 +3736,7 @@ def homework_type_option
option3 = []
option3 << "分组作业"
option3 << 3
type << option0
type << option1
type << option2
type << option3

View File

@ -12,6 +12,8 @@
$("#homework_end_time_span").text("");
$("#homework_course_id_span").text("");
$("#homework_editor").toggle();
$("#select_type_nitice").show();
document.getElementById("homework_type_option").options[0].selected = true;
}
$(function(){

View File

@ -7,7 +7,12 @@
var first_click = true;
$(function(){
$("#homework_type_option").on("change",function(){
$('#homework_editor').show();
var type = $(this).children('option:selected').val();
if(type == "0"){
$('#select_type_nitice').show();
}else{
$('#select_type_nitice').hide();
if(type == "1"){
$("#homeworkSetting").addClass("undis");
$("#homeworkSetting").html("");
@ -18,6 +23,7 @@
$("#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',false);
@ -69,7 +75,10 @@
}
var is_checked = false;
checked_val();
if(!regex_homework_name()){
if($("#homework_type_option").children('option:selected').val() == '0'){
$("#select_type_nitice").show();
}
else if(!regex_homework_name()){
$("#homework_name").focus();
}
else if(!regex_homework_end_time()){
@ -176,8 +185,21 @@
<div class="HomeWorkCon">
<a id="submit_homework"></a>
<div>
<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%>" >
<% 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,edit_mode ? homework.homework_type : 0) %>
</select>
<% if not_allow_select || group_pro %>
<input type="text" style="display: none" name="homework_type" value="<%=homework.homework_type %>"/>
<% end %>
<span class="c_red fl ml10 mt5 <%= edit_mode ? 'none' : '' %>" id="select_type_nitice">发布作业,请先选择作业类型</span>
<%= link_to("从题库选用", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fr",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%>
</div>
<div class="cl"></div>
<div id="homework_editor" class="mt10" style="display: <%= edit_mode ? 'block':'none'%>">
<div>
<input type="text" name="homework_common[name]" id="homework_name" class="InputBox fl w701" maxlength="255" onkeyup="regex_homework_name();" placeholder="发布作业,请先输入作业标题" value="<%= homework.name%>" >
<% unless edit_mode %>
<input type="hidden" name="quotes" id="ref_homework_id" value=""/>
<% end %>
@ -187,15 +209,8 @@
<div class="cl"></div>
<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>
<% if not_allow_select || group_pro %>
<input type="text" style="display: none" name="homework_type" value="<%=homework.homework_type %>"/>
<% end %>
<label class="fl c_grey f14 mt5">截止日期:</label>
<div class="calendar_div fl mr10">
<div class="calendar_div fl mr70">
<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')%>
@ -220,7 +235,6 @@
<div class="cl"></div>
<p id="homework_end_time_span" class="c_red mt5"></p>
<div class="cl"></div>
<div id="homework_editor" style="display: <%= edit_mode ? 'block':'none'%>">
<div class="mt10">
<% if edit_mode %>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='homework_textarea' name="homework_common[description]"><%=homework.description %></textarea>

View File

@ -16,5 +16,6 @@ homework_description_editor.html("<%= escape_javascript(@homework.description.ht
$("#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);
document.getElementById("homework_type_option").options[<%=@homework.homework_type %>].selected = true;
$("#select_type_nitice").hide();
$("#homework_editor").show();