diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 04189af6a..8ef6e8d72 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -502,24 +502,6 @@ class ExerciseController < ApplicationController uncomplete_question end - # 获取当前学生回答问题的答案 - def get_user_answer(question,user) - user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") - user_answer - end - - # 获取问题的标准答案 - def get_user_standard_answer(question,user) - if question.question_type == 3 - standard_answer =[] - question.exercise_standard_answers.each do |answer| - standard_answer << answer.answer_text - end - else - standard_answer = question.exercise_standard_answers - end - standard_answer - end # 是否完成了答题 def get_complete_question(exercise,user) diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index d67f4443f..21c0144b9 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -106,4 +106,23 @@ module ExerciseHelper end end + # 获取当前学生回答问题的答案 + def get_user_answer(question,user) + user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") + user_answer + end + + # 获取问题的标准答案 + def get_user_standard_answer(question,user) + if question.question_type == 3 + standard_answer =[] + question.exercise_standard_answers.each do |answer| + standard_answer << answer.answer_text + end + else + standard_answer = question.exercise_standard_answers + end + standard_answer + end + end \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 6e0953e74..69f55f3d7 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -82,19 +82,22 @@ //添加标题时确定按钮 function add_poll_question(doc,quest_type,quest_id) { - if(arguments[1] && arguments[2]){ - var title = $.trim($("#poll_questions_title_"+quest_type+"_"+quest_id)); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} - } else { - var title = $.trim($("#poll_questions_title").val()); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} - } + var title = $.trim($("#poll_questions_title").val()); + var score = $.trim($("#questions_score").val()); + if(title.length == 0 || score.length == 0){ + alert("题目标题/分数+不能为空"); + }else{ + doc.parent().parent().parent().submit();} } //修改标题时确定按钮 function edit_poll_question(doc,id) { var title = $.trim($("#poll_questions_title_" + id).val()); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + var score = $.trim($("#poll_question_score_"+ id).val()); + if(title.length == 0 || score.length == 0){ + alert("题目标题不能为空"); + }else{ + doc.parent().parent().parent().submit();} } //问卷头 diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index af9896b01..0f51dfeb7 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,17 +3,24 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); - var time = <%=exercise.time %>; - var total_seconds = time * 60; - getTime(total_seconds); + /*start_time = new Date(); + start_time.setFullYear(<%#=exercise_user.start_at.year%>); + start_time.setMonth(<%#=exercise_user.start_at.month%>); + start_time.setDate(<%#=exercise_user.start_at.day%>); + start_time.setHours(<%#=exercise_user.start_at.hour%>); + start_time.setMinutes(<%#=exercise_user.start_at.min%>); + start_time.setSeconds(<%#=exercise_user.start_at.sec%>); + //alert(start_time); + end_time = start_time.getTime() + 1000*60*<%#=exercise.time %>; + getTime(end_time);*/ }); - function getTime(total_seconds) { - start_time = new Date($("#start_time").html()); - end_time = start_time + 60*60*<%=exercise.time %>; + function getTime(end_time) { + //alert(end_time); now = new Date(); + var total_seconds = (now.getTime() - end_time)/1000; //start = new Date(start_time); //end_time = start_time; - var total_seconds = total_seconds - 1; + //var total_seconds = total_seconds - 1; var hours = total_seconds / 60 / 60; var hoursRound = Math.floor(hours); var minutes = total_seconds /60 - (60 * hoursRound); @@ -23,9 +30,9 @@ $("#rest_hours").html(hoursRound); $("#rest_minutes").html(minutesRound); $("#rest_seconds").html(secondsRound); - if(total_seconds >0) { - setTimeout("getTime("+total_seconds+");", 1000); - } + //if(total_seconds >0) { + setTimeout("getTime("+end_time+");", 1000); + //} }
@@ -36,7 +43,9 @@
开始时间:<%=format_time(exercise_user.start_at.to_s)%> 测验时长:<%=exercise.time %>分钟 +
<%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 9ce136667..c6b9a251c 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -30,7 +30,9 @@
第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + <% answer = get_user_answer(exercise_question, User.current)%> + <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% if answer.exercise_choice_id == standard_answer.exercise_choice_id %> √ <% else %> × @@ -67,7 +69,9 @@
第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + <% answer = get_user_answer(exercise_question, User.current)%> + <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% if answer.exercise_choice_id == standard_answer.exercise_choice_id %> √ <% else %> × @@ -104,7 +108,9 @@
第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + <% answer = get_user_answer(exercise_question, User.current)%> + <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% if standard_answer.include?(answer.exercise_choice_id) %> √ <% else %> × diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 606b14aae..a3f6380cf 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -54,7 +54,7 @@
">

多选题

- <% mcq_question_list.each_with_index do |exercise_question, index| %> + <% mcq_question_list.each_with_index do |exercise_question, list_index| %>
diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 5d5170562..b749c4374 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -13,7 +13,7 @@
  • <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> - 分 +
  • @@ -46,7 +46,7 @@
  • - +
  • diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 96b1476ad..a7029d3ea 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -13,7 +13,7 @@
  • <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - 分 +
  • @@ -46,7 +46,7 @@
  • - +
  • diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index c97483bce..1ee79e198 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -13,7 +13,7 @@
  • <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - 分 +
  • diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 183e8d190..b932eac1e 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -46,13 +46,13 @@ ''+ ''+ ''+ - ''+ + ''+ '
  • '+ '
    '+ '
      '+ '
    • '+ ''+ - '分'+ + '分'+ '
    • '+ '
    • '+ ''+ @@ -84,13 +84,13 @@ '
      '+ '
    • '+ ''+ - ''+ + ''+ '
    • '+ '
      '+ '
    '+ '
    '+ ''+ '<% end%>' ); - $("#poll_questions_title_"+quest_type+"_"+quest_id).focus(); + $("#poll_questions_title").focus(); } } else { diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index af2b0facb..2a91afab5 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -45,13 +45,13 @@ ''+ ''+ ''+ - ''+ + ''+ '
    '+ '
    '+ '
      '+ '
    • '+ ''+ - '分'+ + '分'+ '
    • '+ '
    • '+ ''+ @@ -83,13 +83,13 @@ '
      '+ '
    • '+ ''+ - ''+ + ''+ '
    • '+ '
      '+ '
    '+ '
    '+ '
    '+ '<% end%>' ); - $("#poll_questions_title_"+quest_type+"_"+quest_id).focus(); + $("#poll_questions_title").focus(); } }else { $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 9c7936e6d..5f36a931e 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -33,13 +33,13 @@ ''+ ''+ ''+ - ''+ + ''+ '
    '+ '
    '+ '
      '+ '
    • '+ ''+ - '分'+ + '分'+ '
    • '+ '
    • '+ ''+ @@ -65,7 +65,7 @@ '
    '+ '
    '+ '
    '+ '<% end%>' ); - $("#poll_questions_title_"+quest_type+"_"+quest_id).focus(); + $("#poll_questions_title").focus(); } } else { $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");