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); + //} }