256 lines
15 KiB
Plaintext
256 lines
15 KiB
Plaintext
<script type="text/javascript">
|
||
$(function(){
|
||
$("#RSide").removeAttr("id");
|
||
$("#homework_page_right").css("min-height",$("#courseLSide").height()-33);
|
||
$("#Container").css("width","1000px");
|
||
});
|
||
</script>
|
||
<div class="homepageRight mt0 ml10">
|
||
<div class="resources">
|
||
<div class="testStatus"><!--头部显示 start-->
|
||
<h1 class="ur_page_title text_c" id="polls_name_h"><%= exercise.exercise_name%></h1>
|
||
<div class="fontGrey2">
|
||
<span class="mr100">开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S") %></span>
|
||
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%></span>
|
||
<% unless exercise.time == -1 %>
|
||
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
|
||
<% end %>
|
||
<%# time = exercise_user.end_at - exercise_user.start_at %>
|
||
</div>
|
||
<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%></pre>
|
||
<div class="cl"></div>
|
||
</div>
|
||
<div>
|
||
<div class="fl mb5">得分:<span class="c_red" id="exercise_user_score"><%=exercise_user.score %></span>分</div>
|
||
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,exercise.course) || (exercise.exercise_status == 3 && exercise.show_result == 1) %>
|
||
<%= link_to '返回统计结果>>',student_exercise_list_exercise_path(exercise.id,:course_id => exercise.course.id) , :class => "fr linkBlue" %>
|
||
<% end %>
|
||
</div>
|
||
<div class="cl"></div>
|
||
<% mc_question_list = exercise.exercise_questions.where("question_type=1") %>
|
||
<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %>
|
||
<% single_question_list = exercise.exercise_questions.where("question_type=3") %>
|
||
<% multi_question_list = exercise.exercise_questions.where("question_type=4") %>
|
||
|
||
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
|
||
<h3 class="fontGrey3">单选题</h3>
|
||
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
|
||
<div id="poll_questions_<%= exercise_question.id%>">
|
||
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
|
||
<div>
|
||
<div class="exercise_title">
|
||
<div>
|
||
<span class="fl lh27">第<%= exercise_question.question_number%>题. <%= exercise_question.question_score %>分
|
||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
|
||
<div class="fr" id="menu_div_<%= exercise_question.id %>">
|
||
<% answer = get_user_answer(exercise_question, user)%>
|
||
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
|
||
<% is_correct = !answer.empty? && !standard_answer.empty? && answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %>
|
||
<div class="fr">
|
||
得分:<div class="c_red fr mr10 ml10"><%= is_correct ? exercise_question.question_score : 0 %></div>
|
||
</div>
|
||
<span class="fr mt-4 f16 mr20"><i class="<%= is_correct ? 'icon-ok c_green' : 'icon-remove c_red' %>"></i></span>
|
||
</div>
|
||
<div class="cl"></div>
|
||
</div>
|
||
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
|
||
</div>
|
||
|
||
<div class="cl"></div>
|
||
<div class="exercise_inputs">
|
||
<table class="" style="width:100%;">
|
||
<tbody>
|
||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||
<tr>
|
||
<td>
|
||
<label>
|
||
<%= radio_button "exercise",exercise_question.id.to_s+"exercise_choice_id",exercise_choice.id,:class=>"ur_radio",:checked => answer_be_selected?(exercise_choice,user),:disabled => !@can_edit_excercise %>
|
||
<%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%>
|
||
</label>
|
||
</td>
|
||
</tr>
|
||
<% end %>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<% end %>
|
||
</div>
|
||
|
||
<div class="testStatus" id="mcq_question_list" style="display: <%=mcq_question_list.count > 0 ? "" : "none" %>">
|
||
<h3 class="fontGrey3">多选题</h3>
|
||
<% mcq_question_list.each_with_index do |exercise_question, list_index| %>
|
||
<div id="poll_questions_<%= exercise_question.id%>">
|
||
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mcq_question_list.count ? '' : 'border_b' %>">
|
||
<div>
|
||
<div class="exercise_title">
|
||
<div>
|
||
<span class="fl lh27">第<%= exercise_question.question_number%>题. <%= exercise_question.question_score %>分
|
||
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
|
||
<div class="fr" id="menu_div_<%= exercise_question.id %>">
|
||
<% answer = get_user_answer(exercise_question, user)%>
|
||
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
|
||
<% is_correct = !standard_answer.empty? && get_mulscore(exercise_question, user).to_i == standard_answer.first.exercise_choice_id %>
|
||
<div class="fr">
|
||
得分:<div class="c_red fr mr10 ml10"><%= is_correct ? exercise_question.question_score : 0 %></div>
|
||
</div>
|
||
<span class="fr mt-4 f16 mr20"><i class="<%= is_correct ? 'icon-ok c_green' : 'icon-remove c_red' %>"></i></span>
|
||
</div>
|
||
<div class="cl"></div>
|
||
</div>
|
||
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
|
||
</div>
|
||
|
||
<div class="cl"></div>
|
||
<div class="exercise_inputs">
|
||
<table class="" style="width:100%;">
|
||
<tbody>
|
||
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
|
||
<tr>
|
||
<td>
|
||
<label>
|
||
<input class="ur_radio" type="checkbox" <%= answer_be_selected?(exercise_choice,user) ? "checked":"" %> <%= @can_edit_excercise?"":"disabled=disabled" %> >
|
||
<%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%>
|
||
</label>
|
||
</td>
|
||
</tr>
|
||
<% end %>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div><!--多选题显示 end-->
|
||
</div>
|
||
</div>
|
||
<% end %>
|
||
</div>
|
||
|
||
<div class="testStatus" id="single_question_list" style="display: <%=single_question_list.count > 0 ? "" : "none" %>">
|
||
<h3 class="fontGrey3">填空题</h3>
|
||
<% single_question_list.each_with_index do |exercise_question,list_index| %>
|
||
<div id="poll_questions_<%= exercise_question.id%>">
|
||
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == single_question_list.count ? '' : 'border_b' %>">
|
||
<div>
|
||
<div class="exercise_title">
|
||
<div>
|
||
<span class="fl lh27">第<%= exercise_question.question_number%>题. <%= exercise_question.question_score %>分</span>
|
||
<div class="fr" id="menu_div_<%= exercise_question.id %>">
|
||
<% answer = get_user_answer(exercise_question, user)%>
|
||
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
|
||
<% is_correct = !answer.empty? && !standard_answer.empty? && standard_answer.include?(answer.first.answer_text) %>
|
||
<div class="fr">
|
||
得分:<div class="c_red fr mr10 ml10"><%= is_correct ? exercise_question.question_score : 0 %></div>
|
||
</div>
|
||
<span class="fr mt-4 f16 mr20"><i class="<%= is_correct ? 'icon-ok c_green' : 'icon-remove c_red' %>"></i></span>
|
||
</div>
|
||
<div class="cl"></div>
|
||
</div>
|
||
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
|
||
</div>
|
||
|
||
<div class="cl"></div>
|
||
<div class="mb10">
|
||
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
|
||
参考答案<%= convert_to_chi_num(index+1) %>:<%= exercise_choice.answer_text%><br />
|
||
<% end %>
|
||
</div>
|
||
<div>
|
||
<input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(exercise_question.id,user.id).html_safe %>" <%= @can_edit_excercise?"":"disabled=disabled" %>>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<% end %>
|
||
</div>
|
||
|
||
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>">
|
||
<h3 class="fontGrey3">问答题</h3>
|
||
<% multi_question_list.each_with_index do |exercise_question, list_index| %>
|
||
<div id="poll_questions_<%= exercise_question.id%>">
|
||
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == multi_question_list.count ? '' : 'border_b' %>">
|
||
<div>
|
||
<div class="exercise_title">
|
||
<div>
|
||
<span class="fl lh27">第<%= exercise_question.question_number%>题. <%= exercise_question.question_score %>分</span>
|
||
<div class="fr" id="menu_div_<%= exercise_question.id %>">
|
||
<% answer = get_user_answer(exercise_question, user)%>
|
||
<div class="fr">
|
||
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,exercise.course) %>
|
||
得分:
|
||
<% if answer.empty? %>
|
||
<div id="exercise_question_score_<%= exercise_question.id %>" title="未答题系统自动打0分" class="c_red fr mr10 ml10">
|
||
0
|
||
</div>
|
||
<% else %>
|
||
<div id="exercise_question_score_<%= exercise_question.id %>" title="双击批阅" ondblclick="edit_question_score('<%= exercise_question.id %>', <%= exercise_question.question_score %>, <%= exercise_user.user_id %>)" class="c_red fr mr10 ml10">
|
||
<%= answer.first.score == -1 ? "双击批阅" : answer.first.score %>
|
||
</div>
|
||
<% end %>
|
||
<% else %>
|
||
得分:<div class="c_red fr mr10 ml10"><%= answer.empty? ? 0 : (answer.first.score == -1 ? "未批" : answer.first.score) %></div>
|
||
<% end %>
|
||
</div>
|
||
</div>
|
||
<div class="cl"></div>
|
||
</div>
|
||
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
|
||
</div>
|
||
<div class="cl"></div>
|
||
<% if exercise_question.exercise_standard_answers.count > 0 %>
|
||
<div class="mb10">
|
||
参考答案:<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise_question.exercise_standard_answers.first.answer_text%></pre>
|
||
</div>
|
||
<% end %>
|
||
<div>
|
||
<textarea style="width: 693px; height: 90px; line-height: 30px; border: 1px solid #CBCBCB; color: #888888;" name="exercise_choice" placeholder="在此填入答案" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,exercise_user.user_id).html_safe %></textarea>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<% end %>
|
||
</div>
|
||
<div class="cl"></div>
|
||
<!--contentbox end-->
|
||
</div>
|
||
<!--RSide end-->
|
||
</div>
|
||
|
||
<script>
|
||
// 在线测验的主观题打分
|
||
function edit_question_score(id, score, user_id){
|
||
$("#exercise_question_score_"+id).html("<input type='text' id='edit_score_input' onblur='edit_question_score_submit(this, "+ id +", "+ score +", "+ user_id +")' class='score_input' placeholder='0-"+ score +"'></input>");
|
||
}
|
||
|
||
function edit_question_score_submit(obj, id, score, user_id){
|
||
$.ajax({
|
||
type: "post",
|
||
url: "<%= edit_question_score_exercise_path(exercise) %>",
|
||
data: {
|
||
exercise_question_id: id,
|
||
user_id: user_id,
|
||
score: $(obj).val().trim()
|
||
},
|
||
success: function (data) {
|
||
var dataObj = eval(data);
|
||
if(dataObj.status == 2){
|
||
$("#ajax_notice_p").html("请输入0-"+score);
|
||
$("#ajax-notice").css('top', $(window).scrollTop()+200);
|
||
$("#ajax-notice").show();
|
||
} else if(dataObj.status == 1){
|
||
$("#exercise_question_score_"+id).html(dataObj.score);
|
||
$("#exercise_user_score").html(dataObj.total_score);
|
||
$("#ajax_notice_p").html("分数已保存");
|
||
$("#ajax-notice").css('top', $(window).scrollTop()+200);
|
||
$("#ajax-notice").show();
|
||
}
|
||
setTimeout(function(){
|
||
$("#ajax-notice").hide();
|
||
},2000);
|
||
},
|
||
error: function () {
|
||
long_notice_box("网路异常,请重新批阅。");
|
||
}
|
||
});
|
||
}
|
||
</script> |