Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course

This commit is contained in:
huang 2015-11-20 17:29:33 +08:00
commit 431d1d886c
11 changed files with 78 additions and 43 deletions

View File

@ -537,9 +537,7 @@ class ExerciseController < ApplicationController
standard_answer = question.exercise_standard_answers.first
end
standard_answer
end
# 是否完成了答题
end # 是否完成了答题
def get_complete_question(exercise,user)
questions = exercise.exercise_questions
complete_question = []

View File

@ -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

View File

@ -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();}
}
//问卷头

View File

@ -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);
//}
}
</script>
<div class="homepageRight mt0 ml10">
@ -36,7 +43,9 @@
<div class="fontGrey2">
<span class="mr130">开始时间:<%=format_time(exercise_user.start_at.to_s)%></span>
<span class="mr130">测验时长:<%=exercise.time %>分钟</span>
<!--
<span class="fr">剩余时长:<span class="c_red" id="rest_hours"></span>&nbsp;小时&nbsp;<span class="c_red" id="rest_minutes"></span>&nbsp;分钟&nbsp;<span class="c_red" id="rest_seconds"></span>&nbsp;秒</span>
-->
</div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<div class="cl"></div>

View File

@ -30,7 +30,9 @@
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<span class="ml15 c_red">
<% 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 @@
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<span class="ml15 c_red">
<% 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 @@
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<span class="ml15 c_red">
<% 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 %>
×

View File

@ -13,7 +13,7 @@
<li class="ur_item">
<% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %>
<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
</li>
<div class="cl"></div>
<li class="ur_item">
@ -46,7 +46,7 @@
<div class="cl"></div>
<li class="ur_item">
<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="exercise_choice" placeholder="若标准答案为A在此输入A即可" type="text">
<input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A在此输入A即可" type="text">
</li>
<div class="cl"></div>
</ul>

View File

@ -13,7 +13,7 @@
<li class="ur_item">
<% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %>
<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
</li>
<div class="cl"></div>
<li class="ur_item">
@ -46,7 +46,7 @@
<div class="cl"></div>
<li class="ur_item">
<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="exercise_choice" placeholder="若标准答案为A,B,C在答案输入框填入ABC即可" type="text">
<input id="question_standard_ans" name="exercise_choice" placeholder="若标准答案为A,B,C在答案输入框填入ABC即可" type="text">
</li>
<div class="cl"></div>
</ul>

View File

@ -13,7 +13,7 @@
<li class="ur_item">
<% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %>
<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input value="<%= score%>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
<input id="question_score" value="<%= score%>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
</li>
<div class="cl"></div>
<li class="ur_item">

View File

@ -46,13 +46,13 @@
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
'<input type="hidden" name="question_type" value="1"/>'+
'<input name="question_title" id="poll_questions_title_'+quest_type+"_"+quest_id+'" class="questionTitle" placeholder="请输入单选题题目" type="text"/>'+
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text"/>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item">'+
'<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input value="<%=score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'<input value="<%=score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'</li>'+
'<li class="ur_item">'+
'<label>选项A<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
@ -84,13 +84,13 @@
'<div class="cl"></div>'+
'<li class="ur_item">'+
'<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input name="exercise_choice" placeholder="若标准答案为A在此输入A即可" type="text">'+
'<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A在此输入A即可" type="text">'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),\''+quest_type+'\','+quest_id+');">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));">'+
'保存'+
'</a>'+
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
@ -101,7 +101,7 @@
'</div>'+
'<% end%>'
);
$("#poll_questions_title_"+quest_type+"_"+quest_id).focus();
$("#poll_questions_title").focus();
}
}
else {

View File

@ -45,13 +45,13 @@
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
'<input type="hidden" name="question_type" value="2"/>'+
'<input name="question_title" id="poll_questions_title_'+quest_type+"_"+quest_id+'" class="questionTitle" placeholder="请输入多选题题目" type="text"/>'+
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入多选题题目" type="text"/>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item">'+
'<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input value="<%= score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'</li>'+
'<li class="ur_item">'+
'<label>选项A<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
@ -83,13 +83,13 @@
'<div class="cl"></div>'+
'<li class="ur_item">'+
'<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input name="exercise_choice" placeholder="若标准答案为A,B,C在答案输入框填入ABC即可" type="text">'+
'<input name="exercise_choice" id="question_standard_ans" placeholder="若标准答案为A,B,C在答案输入框填入ABC即可" type="text">'+
'</li>'+
'<div class="cl"></div>'+
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),\''+quest_type+'\','+quest_id+');">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));">'+
'保存'+
'</a>'+
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
@ -100,7 +100,7 @@
'</div>'+
'<% end%>'
);
$("#poll_questions_title_"+quest_type+"_"+quest_id).focus();
$("#poll_questions_title").focus();
}
}else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");

View File

@ -33,13 +33,13 @@
'<input type="hidden" name="quest_id" value="'+quest_id+'"/>'+
'<input type="hidden" name="quest_num" value="'+quest_num+'"/>'+
'<input type="hidden" name="question_type" value="3"/>'+
'<input name="question_title" id="poll_questions_title_'+quest_type+"_"+quest_id+'" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+
'<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text"/>'+
'</div>'+
'<div class="ur_editor_content">'+
'<ul>'+
'<li class="ur_item">'+
'<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
'<input value="<%= score %>" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'<input value="<%= score %>" id="question_score" type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;"/>分'+
'</li>'+
'<li class="ur_item">'+
'<label>候选答案一<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>'+
@ -65,7 +65,7 @@
'</ul>'+
'</div>'+
'<div class="ur_editor_footer">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),\''+quest_type+'\','+quest_id+');">'+
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));">'+
'保存'+
'</a>'+
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
@ -76,7 +76,7 @@
'</div>'+
'<% end%>'
);
$("#poll_questions_title_"+quest_type+"_"+quest_id).focus();
$("#poll_questions_title").focus();
}
} else {
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");