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("<%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>+