diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 55bac3e46..ff211cde9 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -789,6 +789,7 @@ class CoursesController < ApplicationController @homework = Bid.new @homework.safe_attributes = params[:bid] @homework.open_anonymous_evaluation = 1 + @homework.deadline = (Time.now + 3600 * 24).strftime('%Y-%m-%d') if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] )) render :layout => 'base_courses' else diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 0949899dd..034cbdf1a 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -31,7 +31,7 @@ <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> - <%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()' %> + <%= button_tag "文件浏览", :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sb' %> <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => 'file_selector', diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb new file mode 100644 index 000000000..3150d6b6a --- /dev/null +++ b/app/views/bids/_new_homework_form.html.erb @@ -0,0 +1,41 @@ +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %> +<%= error_messages_for 'bid' %> +<%= hidden_field_tag 'course_id', @course.id %> +
+

<%= l(:label_course_homework_new)%>

+
+
+ +
+
diff --git a/app/views/courses/new_homework.html.erb b/app/views/courses/new_homework.html.erb index 2e0b35c6d..04456c4d2 100644 --- a/app/views/courses/new_homework.html.erb +++ b/app/views/courses/new_homework.html.erb @@ -1,115 +1,8 @@ - - -

<%=l(:label_course_new_homework)%>

- <%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %> -
- <%= render :partial => 'homework_form', :locals => { :f => f } %> - - <%= l(:button_create)%> - <%= javascript_tag "$('#bid_name').focus();" %> - <% end %> -
\ No newline at end of file + <%= render :partial => 'bids/new_homework_form', :locals => { :f => f } %> +
  • + <%= l(:button_create)%> + <%= link_to l(:button_cancel), homework_course_path(@course), :class => "blue_btn grey_btn fl c_white"%> +
    +
  • +<% end %> \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 205db44ba..373943f05 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2016,7 +2016,7 @@ zh: label_anonymous_comments: 匿评 label_submit_comments: 提交评论 - field_evaluation_num: 匿评分配数量 + field_evaluation_num: 匿评分配数 label_my_score: 我的评分 field_open_anonymous_evaluation: 是否使用匿评 label_course_empty_select: 尚未选择课程! @@ -2084,6 +2084,9 @@ zh: label_totle: 共有 label_homework_count: 个作业 lebel_homework_commit: 已提交的作业 + label_open_anonymous_evaluation: 是否匿评 + label_evaluation_description: 即每份作业被允许匿评的人数 + label_name_not_null: 名称不能为空 diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 651013973..fdcac6601 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1,3 +1,4 @@ +//验证搜索时输入名字 function regexName(content) { var name = $.trim($("#name").val()); @@ -14,26 +15,26 @@ function regexName(content) return true; } } - +//提交搜索 function submitSerch(content) { if(regexName(content)){$("#course_search_form").submit();} } - +//课程描述显示更多信息 function show_more_msg() { $("#course_description").toggleClass("course_description_none"); } - +//作业描述显示更多信息 function bid_show_more_des(id) { $("#bid_description_" + id).toggleClass("news_description_none"); } - +//将右侧的最小高度设置成左侧高度,美化界面 $(document).ready(function () { $("#RSide").css("min-height",$("#LSide").height()-30); }); - +//课程作业结束时间倒计时 function ShowCountDown(year,month,day,divname) { var now = new Date(); @@ -49,4 +50,76 @@ function ShowCountDown(year,month,day,divname) +hour+" 
     " +minute+"  " +second+" "); +} +//验证新建作业的名字 +function regex_bid_name() +{ + var name = $.trim($("#bid_name").val()); + + if(name=="") + { + $("#bid_name_span").text("名称不能为空"); + return false; + } + else + { + $("#bid_name_span").text(""); + return true; + } +} +function regex_evaluation_num() +{ + var evaluation_num = $.trim($("#bid_evaluation_num").val()); + var regex = /^\d+$/; + if($("#bid_open_anonymous_evaluation").attr("checked") == "checked") + { + if(evaluation_num=="") + { + $("#bid_evaluation_num_span").text("匿评分配数量不能为空"); + return false; + } + else if(regex.test(evaluation_num)) + { + if(evaluation_num > 0) + { + $("#bid_evaluation_num_span").text(""); + return true; + } + else + { + $("#bid_evaluation_num_span").text("匿评分配数量必须为大于0"); + return false; + } + } + else + { + $("#bid_evaluation_num_span").text("匿评分配数量只能为数字"); + return false; + } + } + else + { + return true; + } +} + +$(function(){ + $("#bid_open_anonymous_evaluation").click(function(){ + if($("#bid_open_anonymous_evaluation").attr("checked") == "checked") + { + $("#bid_evaluation_num").slideDown(); + } + else + { + $("#bid_evaluation_num").slideUp(); + } + }); +}); + +function submit_new_bid() +{ + if(regex_bid_name()&®ex_evaluation_num()) + { + $("#new_bid").submit(); + } } \ No newline at end of file