diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 02a8400a7..02ee909b7 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -132,7 +132,9 @@ class ExerciseController < ApplicationController @exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time] @exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) @exercise.publish_time = params[:exercise][:publish_time] - @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result] + @exercise.show_result = params[:show_result].blank? ? 1 : params[:show_result] + @exercise.question_random = params[:question_random] + @exercise.choice_random = params[:choice_random] if @exercise.save respond_to do |format| format.js diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 3234d15c0..b7e4b9efd 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -82,6 +82,27 @@ class HomeworkCommonController < ApplicationController @homework.publish_time = params[:homework_common][:publish_time] end homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new + param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d") + homework_end_time = Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") + 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 < Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d") + st.late_penalty = @homework.late_penalty + st.work_status = 2 + st.save + 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 + end + end + end + end @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] if params[:homework_type] && params[:homework_type].to_i != @homework.homework_type diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 6dadf92b5..47fccefff 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -175,4 +175,43 @@ module ExerciseHelper standard_answer end + # 问题随机的下拉列表 + def question_random_select + type = [] + option1 = [] + option1 << "题目不随机打乱" + option1 << 0 + type << option1 + option2 = [] + option2 << "题目随机打乱" + option2 << 1 + type << option2 + end + + # 选项随机的下拉列表 + def choice_random_select + type = [] + option1 = [] + option1 << "选项不随机打乱" + option1 << 0 + type << option1 + option2 = [] + option2 << "选项随机打乱" + option2 << 1 + type << option2 + end + + #允许学生查看结果的下拉列表 + def show_result_select + type = [] + option1 = [] + option1 << "允许学生查看测验结果" + option1 << 1 + type << option1 + option2 = [] + option2 << "不允许学生查看测验结果" + option2 << 0 + type << option2 + end + end \ No newline at end of file diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index a071904ce..e23f3134a 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -16,13 +16,13 @@
- diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index cb41cf26b..c2c01ac25 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -168,17 +168,55 @@ $("#edit_poll_questions_"+question_id).show(); $("#poll_questions_title_"+question_id).focus(); } - //单选题 - function add_single_answer(doc) - { - var li = doc.parent().after("
  • " + - ""+ - "
  • "); - var select_items =$("label[name='select_items']",li.parent()); - for(var i=0; i:   "); + // 选项的选择 + function toggle_select(doc, type){ + if(doc.hasClass("question_choice_blue")){ + doc.removeClass("question_choice_blue").addClass("question_choice_white"); + if(type == "1"){ + $("#question_standard_answer").html("请点击选项"); + $("#exercise_choice").val(""); + }else{ + var eles = doc.parent().parent().find("a.question_choice_blue"); + var str = ""; + if(eles.length > 0){ + for(var i=0; i" + + ""+ + "
    "); + var select_items =$("li.new_answer",li.parent()); + li.prev().prev().find("a.question_choice_white").html(String.fromCharCode(64 + select_items.length)); + doc.prev("a.question_choice_dash").html(String.fromCharCode(64 + select_items.length + 1)); + } function add_candidate_answer(doc) { doc.parent().after("
  • " + @@ -214,10 +252,11 @@ { var parent = doc.parent().parent(); doc.parent().remove(); - var select_items =$("label[name='select_items']",parent); + + var select_items =$("li.ur_item",parent); var candiate_items =$("label[name='candiate_items']",parent); for(var i=0; i:   "); + $(select_items[i]).find("a.choice_btn").html(String.fromCharCode(64 + parseInt(i+1))); } for(var i=0; i:   "); diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 054285825..6ebf3bd40 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -3,6 +3,14 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> + + 分 + 请点击选项 + 标准答案: +
    +
    @@ -10,52 +18,44 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> - - 分 -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • + +
    • + A + + +
    • +
      +
    • + B + + +
    • +
      +
    • + C + + +
    • +
      +
    • + D + + +
    • +
      +
    • + E +
      新建选项
      +
    • +
      -
    • - - -
    • -
    diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index d8dbf0adb..965772051 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -3,6 +3,14 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> + + 分 + 请点击选项 + 标准答案: +
    +
    @@ -10,52 +18,43 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - - 分 -
    • -
      -
    • - - - + +
    • + A +
    • -
    • - - - +
    • + B +
    • -
    • - - - +
    • + C +
    • -
    • - - - +
    • + D +
    • - - + E +
      新建选项
    • -
      +
    diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb index faadb08a9..23aae4cb3 100644 --- a/app/views/exercise/_new_question.html.erb +++ b/app/views/exercise/_new_question.html.erb @@ -14,7 +14,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } @@ -26,7 +26,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } @@ -38,7 +38,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index d0fce87c8..669a1b8db 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -3,6 +3,12 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> + + 分 +
    +
    @@ -10,12 +16,6 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - - 分 -
    • -
    • @@ -42,8 +42,8 @@
    diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index 4cc5a6cf8..b59eb11c7 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -1,5 +1,5 @@ -
    - +
    +

    <%= exercise.exercise_name%>

    @@ -12,5 +12,10 @@ <% end %>
    <%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>
    +
    \ No newline at end of file diff --git a/db/migrate/20161129084352_add_column_to_exercises.rb b/db/migrate/20161129084352_add_column_to_exercises.rb new file mode 100644 index 000000000..ea3d01667 --- /dev/null +++ b/db/migrate/20161129084352_add_column_to_exercises.rb @@ -0,0 +1,6 @@ +class AddColumnToExercises < ActiveRecord::Migration + def change + add_column :exercises, :question_random, :integer, :default => 0 + add_column :exercises, :choice_random, :integer, :default => 0 + end +end diff --git a/db/migrate/20161206061652_update_student_work_score.rb b/db/migrate/20161206061652_update_student_work_score.rb new file mode 100644 index 000000000..4fcd374ca --- /dev/null +++ b/db/migrate/20161206061652_update_student_work_score.rb @@ -0,0 +1,19 @@ +class UpdateStudentWorkScore < ActiveRecord::Migration + def up + homework = HomeworkCommon.where("id = 4198").first + unless homework.nil? + homework.student_works.each do |st| + if st.late_penalty != 0 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") > Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d") + if st.work_status == 2 + st.work_status = 1 + end + st.late_penalty = 0 + st.save + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index c61a33fc1..9109f785d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20161201083030) do +ActiveRecord::Schema.define(:version => 20161129084352) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -966,7 +966,6 @@ ActiveRecord::Schema.define(:version => 20161201083030) do t.integer "homework_common_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.integer "no_anon_penalty", :default => 1 end create_table "homework_detail_programings", :force => true do |t| diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index 97ba3801f..c0bb5343d 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -604,3 +604,10 @@ a:hover.ex_icon_edit{ background:url(/images/course/icons.png) -21px -276px no- .archive_course_notice {width:220px; position:absolute; padding:5px 10px; white-space:nowrap; background-color:#fff; right:-265px; top:-15px; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);} .archive_course_notice em {display:block; border-width:10px; position:absolute;top:26px; left:-20px; border-style:dashed solid dashed dashed; border-color:transparent #eaeaea transparent transparent; font-size:0; line-height:0;} .archive_course_notice span {display:block; border-width:10px; position:absolute;top:26px; left:-18px; border-style:dashed solid dashed dashed; border-color:transparent #fff transparent transparent; font-size:0; line-height:0;} + +/* 新版测验 */ +.blue_select{ background: #3b94d6; font-size: 12px; color: #fff; padding: 5px 10px;} +.grey_select{ background: #c3c3c3; font-size: 12px; color: #fff; padding: 5px 10px;} +a.question_choice_white{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a.question_choice_blue{ background: #3b94d6; color: #fff; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +.question_choice_dash{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px dashed #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}