试卷增加查看个人成绩的设置

dev_local
cxt 6 years ago
parent c3c020a404
commit 5f9b7c7741

@ -416,6 +416,7 @@ class ExerciseController < ApplicationController
@exercise.time = (params[:time].strip == "" ? -1 : params[:time]) if params[:time] @exercise.time = (params[:time].strip == "" ? -1 : params[:time]) if params[:time]
@exercise.question_random = params[:question_random] ? 1 : 0 @exercise.question_random = params[:question_random] ? 1 : 0
@exercise.choice_random = params[:choice_random] ? 1 : 0 @exercise.choice_random = params[:choice_random] ? 1 : 0
@exercise.view_score = params[:view_score] ? 1 : 0
@exercise.score_open = params[:score_open] ? 1 : 0 @exercise.score_open = params[:score_open] ? 1 : 0
@exercise.answer_open = params[:answer_open] ? 1 : 0 @exercise.answer_open = params[:answer_open] ? 1 : 0
@exercise.show_statistic = params[:show_statistic] ? 1 : 0 @exercise.show_statistic = params[:show_statistic] ? 1 : 0
@ -1342,11 +1343,14 @@ class ExerciseController < ApplicationController
end end
@exercise = Exercise.find params[:id] @exercise = Exercise.find params[:id]
@course = @exercise.course @course = @exercise.course
@is_teacher = params[:pdf] ? true : User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_teacher = params[:pdf] && User.current.nil? ? true : User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
if @is_teacher || (User.current.member_of_course?(@exercise.course) && @exercise.exercise_status > 2) @user = User.find params[:user_id]
@user = User.find params[:user_id] current_ex_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current.id, @exercise.id).first if User.current
if @is_teacher || (User.current.member_of_course?(@exercise.course) && @exercise.end_time <= Time.now &&
current_ex_user && (@exercise.score_open || User.current == @user))
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first @exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
@exercise_questions = (@exercise.user_question_list @exercise_user.id).reorder("question_number = 0 asc, question_number asc") @exercise_questions = (@exercise.user_question_list @exercise_user.id).reorder("question_number = 0 asc, question_number asc")
@show_score = User.current.present? && User.current == @user && !@exercise.view_score ? false : true
respond_to do |format| respond_to do |format|
if params[:pdf] if params[:pdf]
format.html { render :layout => "pdf" } format.html { render :layout => "pdf" }
@ -1470,7 +1474,7 @@ class ExerciseController < ApplicationController
:status => answer_status) :status => answer_status)
end end
score4 += exercise_cha_score score4 += exercise_cha_score.to_f
end end
end end
end end

@ -126,7 +126,7 @@ module ExerciseHelper
score = 0 score = 0
if eq.question_type == 5 if eq.question_type == 5
eq.exercise_shixun_answers.where(:user_id => user.id).each do |answer| eq.exercise_shixun_answers.where(:user_id => user.id).each do |answer|
score += answer.score score += answer.score.to_f
end end
end end
score score

@ -138,6 +138,12 @@
<div class="ml30 mr30 mb15"> <div class="ml30 mr30 mb15">
<div class="clearfix pl30"> <div class="clearfix pl30">
<ul> <ul>
<li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label>
<input class="magic-checkbox fl magic-checkbox_show" type="checkbox" disabled <%= @exercise.view_score ? 'checked' : '' %>>
<label class="fl" style="top:0px">查看个人成绩</label>
<span class="fl color-grey">(选中则在截止时间之后提交了答题的学生可以看到自己的成绩,否则不公开)</span>
</li>
<li class="clearfix"> <li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label> <label class="panel-form-label fl mr10">&nbsp;</label>
<input class="magic-checkbox fl mt5 magic-checkbox_show" type="checkbox" disabled <%= @exercise.score_open ? 'checked' : '' %>> <input class="magic-checkbox fl mt5 magic-checkbox_show" type="checkbox" disabled <%= @exercise.score_open ? 'checked' : '' %>>
@ -309,6 +315,12 @@
<div class="ml30 mr30"> <div class="ml30 mr30">
<div class="clearfix pl30"> <div class="clearfix pl30">
<ul> <ul>
<li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label>
<input name="view_score" class="magic-checkbox fl magic-checkbox_show" type="checkbox" id="view_score" <%= @exercise.view_score ? 'checked' : '' %>>
<label class="fl" for="view_score" style="top:0px">查看个人成绩</label>
<span class="fl color-grey">(选中则在截止时间之后提交了答题的学生可以看到自己的成绩,否则不公开)</span>
</li>
<li class="clearfix"> <li class="clearfix">
<label class="panel-form-label fl mr10">&nbsp;</label> <label class="panel-form-label fl mr10">&nbsp;</label>
<input name="score_open" class="magic-checkbox fl magic-checkbox_show" type="checkbox" id="public_scroe" <%= @exercise.score_open ? 'checked' : '' %>> <input name="score_open" class="magic-checkbox fl magic-checkbox_show" type="checkbox" id="public_scroe" <%= @exercise.score_open ? 'checked' : '' %>>

@ -67,34 +67,37 @@
<%= render :partial => "exercise/total_questions_score" %> <%= render :partial => "exercise/total_questions_score" %>
</div> </div>
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20 panel-box-sizing" id="exercise_No"> <% if @show_score %>
<div class="clearfix"> <div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20 panel-box-sizing" id="exercise_No">
<span class="fl ml15 mr20 font-15">客观题</span> <div class="clearfix">
<span class="checkstatus_box_small post_btn_green mt10"></span><span class="fl mr20 font-12 mt3">正确</span> <span class="fl ml15 mr20 font-15">客观题</span>
<span class="checkstatus_box_small post_btn_red mt10"></span><span class="fl font-12 mt3">错误</span> <span class="checkstatus_box_small post_btn_green mt10"></span><span class="fl mr20 font-12 mt3">正确</span>
<p class="mr15 mt3 fr color-grey font-14">总分:<span class="color-light-green" id="exercise_user_score"><%= @exercise_user.score.nil? ? "--" : format("%.1f", @exercise_user.score) %></span>分 <span class="checkstatus_box_small post_btn_red mt10"></span><span class="fl font-12 mt3">错误</span>
</p> <p class="mr15 mt3 fr color-grey font-14">总分:<span class="color-light-green" id="exercise_user_score"><%= @exercise_user.score.nil? ? "--" : format("%.1f", @exercise_user.score) %></span>分
</div> </p>
<div class="clearfix ml80 mt10 mb5"> </div>
<% que_count = exercise_questions.where(:question_type => [1, 2, 3]).count %> <div class="clearfix ml80 mt10 mb5">
<% exercise_questions.where(:question_type => [1, 2, 3, 5]).each_with_index do |eq, index| %> <% que_count = exercise_questions.where(:question_type => [1, 2, 3]).count %>
<% is_correct = answer_is_correct(eq, user) %> <% exercise_questions.where(:question_type => [1, 2, 3, 5]).each_with_index do |eq, index| %>
<a href="javascript:void(0);" onclick="scroll_70height(<%= eq.id %>);" style="cursor:pointer" class="checkstatus_box_big color_white <%= is_correct ? 'post_btn_green' : 'post_btn_red' %>"><%= eq.ques_number(index-que_count + 1) %></a> <% is_correct = answer_is_correct(eq, user) %>
<% end %> <a href="javascript:void(0);" onclick="scroll_70height(<%= eq.id %>);" style="cursor:pointer" class="checkstatus_box_big color_white <%= is_correct ? 'post_btn_green' : 'post_btn_red' %>"><%= eq.ques_number(index-que_count + 1) %></a>
</div> <% end %>
<div class="clearfix"> </div>
<span class="fl ml15 mr20 font-15">主观题</span> <div class="clearfix">
<span class="fl checkstatus_box_small post_btn_white mt10" style="border: 1px solid #CCCCCC;"></span><span class="fl mr20 font-12 mt3">已评</span> <span class="fl ml15 mr20 font-15">主观题</span>
<span class="fl checkstatus_box_small post_btn_grey mt10"></span><span class="fl font-12 mt3">未评</span> <span class="fl checkstatus_box_small post_btn_white mt10" style="border: 1px solid #CCCCCC;"></span><span class="fl mr20 font-12 mt3">已评</span>
<span class="mr15 mt3 fr color-grey font-14">开始答题时间:<%= format_time @exercise_user.start_at %></span> <span class="fl checkstatus_box_small post_btn_grey mt10"></span><span class="fl font-12 mt3">未评</span>
</div> <span class="mr15 mt3 fr color-grey font-14">开始答题时间:<%= format_time @exercise_user.start_at %></span>
<div class="clearfix ml80 mt10"> </div>
<% exercise_questions.where(:question_type => 4).each do |eq| %> <div class="clearfix ml80 mt10">
<% ea = @exercise_user.user.exercise_answer.where(:exercise_question_id => eq.id).first %> <% exercise_questions.where(:question_type => 4).each do |eq| %>
<a href="javascript:void(0);" onclick="scroll_70height(<%= eq.id%>);" style="cursor:pointer" id="ex_comment_status_<%= eq.id %>" class="checkstatus_box_big <%= (ea && ea.score == -1) ? 'post_btn_grey' : 'post_btn_white' %>"><%= eq.question_number %></a> <% ea = @exercise_user.user.exercise_answer.where(:exercise_question_id => eq.id).first %>
<% end %> <a href="javascript:void(0);" onclick="scroll_70height(<%= eq.id%>);" style="cursor:pointer" id="ex_comment_status_<%= eq.id %>" class="checkstatus_box_big <%= (ea && ea.score == -1) ? 'post_btn_grey' : 'post_btn_white' %>"><%= eq.question_number %></a>
<% end %>
</div>
</div> </div>
</div> <% end %>
<div class="clearfix" id="problem_main"> <div class="clearfix" id="problem_main">
<% question_list = exercise_questions.includes(:exercise_shixun_answers, :exercise_choices => [:exercise_answers]) %> <% question_list = exercise_questions.includes(:exercise_shixun_answers, :exercise_choices => [:exercise_answers]) %>
<% question_list.each_with_index do |exercise_question, index| %> <% question_list.each_with_index do |exercise_question, index| %>
@ -106,38 +109,42 @@
分</span><span class="ml10 color-red"><%= question_commit_status exercise_question, @exercise_user.user %></span> 分</span><span class="ml10 color-red"><%= question_commit_status exercise_question, @exercise_user.user %></span>
</p> </p>
<% if exercise_question.question_type != 4 %> <% if exercise_question.question_type != 4 %>
<% is_correct = answer_is_correct(exercise_question, user) %> <% if @show_score %>
<p class="fr"> <% is_correct = answer_is_correct(exercise_question, user) %>
<% if exercise_question.question_type == 3 && @is_teacher %> <p class="fr">
<% answer = get_user_answer(exercise_question, user).first %> <% if exercise_question.question_type == 3 && @is_teacher %>
<% if answer.present? %> <% answer = get_user_answer(exercise_question, user).first %>
<a href="javascript:void(0)" onclick="toggle_comment_block(<%= exercise_question.id %>, <%= answer.id %>)" data-remote="true" class="mr15 color-blue">调分</a> <% if answer.present? %>
<% end %> <a href="javascript:void(0)" onclick="toggle_comment_block(<%= exercise_question.id %>, <%= answer.id %>)" data-remote="true" class="mr15 color-blue">调分</a>
<% score = answer.present? ? (answer.score == -1 ? (is_correct ? exercise_question.question_score : 0) : answer.score) : 0 %> <% end %>
<span class="<%= score != 0 ? 'color-light-green' : 'color-red' %> mr3" id="question_score_<%= exercise_question.id %>"> <% score = answer.present? ? (answer.score == -1 ? (is_correct ? exercise_question.question_score : 0) : answer.score) : 0 %>
<span class="<%= score != 0 ? 'color-light-green' : 'color-red' %> mr3" id="question_score_<%= exercise_question.id %>">
<% if is_correct || score == 0 %> <% if is_correct || score == 0 %>
<i class="mr5 fa <%= is_correct ? 'fa-check' : 'fa-close' %> font-14"></i> <i class="mr5 fa <%= is_correct ? 'fa-check' : 'fa-close' %> font-14"></i>
<% end %> <% end %>
<%= score %> <%= score %>
</span>分 </span>分
<% else %> <% else %>
<% score = exercise_question.question_type != 5 ? (is_correct ? exercise_question.question_score : 0) : shixun_question_score(exercise_question, user) %> <% score = exercise_question.question_type != 5 ? (is_correct ? exercise_question.question_score : 0) : shixun_question_score(exercise_question, user) %>
<span class="<%= score != 0 ? 'color-light-green' : 'color-red' %> mr3" id="question_score_<%= exercise_question.id %>"> <span class="<%= score != 0 ? 'color-light-green' : 'color-red' %> mr3" id="question_score_<%= exercise_question.id %>">
<% if exercise_question.question_type != 5 || (is_correct || score == 0) %> <% if exercise_question.question_type != 5 || (is_correct || score == 0) %>
<i class="mr5 fa <%= is_correct ? 'fa-check' : 'fa-close' %> font-14"></i> <i class="mr5 fa <%= is_correct ? 'fa-check' : 'fa-close' %> font-14"></i>
<% end %> <% end %>
<%= score %> <%= score %>
</span>分 </span>分
<% end %> <% end %>
</p> </p>
<% end %>
<% if exercise_question.question_type == 5 %> <% if exercise_question.question_type == 5 %>
<%= link_to '实训详情', shixun_path(exercise_question.shixun), :target => "_blank", :class => "fr mr10 white-btn orange-btn" %> <%= link_to '实训详情', shixun_path(exercise_question.shixun), :target => "_blank", :class => "fr mr10 white-btn orange-btn" %>
<% end %> <% end %>
<% else %> <% else %>
<% answer = get_user_answer(exercise_question, user) %> <% if @show_score %>
<p class="fr" id="question_score_<%= exercise_question.id %>"> <% answer = get_user_answer(exercise_question, user) %>
<span class="<%= answer.empty? ? 'color-red' : (answer.first.score == -1 || answer.first.score == 0 ? "color-red" : "color-light-green") %> mr3"><%= answer.empty? ? 0 : (answer.first.score == -1 ? "未批" : answer.first.score) %></span><%= answer.empty? ? "分" : (answer.first.score == -1 ? "" : "分") %> <p class="fr" id="question_score_<%= exercise_question.id %>">
</p> <span class="<%= answer.empty? ? 'color-red' : (answer.first.score == -1 || answer.first.score == 0 ? "color-red" : "color-light-green") %> mr3"><%= answer.empty? ? 0 : (answer.first.score == -1 ? "未批" : answer.first.score) %></span><%= answer.empty? ? "分" : (answer.first.score == -1 ? "" : "分") %>
</p>
<% end %>
<% end %> <% end %>
</div> </div>
<% if exercise_question.question_type == 5 %> <% if exercise_question.question_type == 5 %>

@ -25,7 +25,7 @@
<tbody> <tbody>
<% exercise_subject_q = @exercise.exercise_questions.where(:question_type => 4).count == 0 %> <% exercise_subject_q = @exercise.exercise_questions.where(:question_type => 4).count == 0 %>
<% @exercise_users_list.each_with_index do |exercise, index| %> <% @exercise_users_list.each_with_index do |exercise, index| %>
<% show_score = exercise.commit_status == 1 && (@is_teacher || @exercise.exercise_status == 3) %> <% show_score = exercise.commit_status == 1 && (@is_teacher || (@exercise.end_time <= Time.now && @exercise.view_score)) %>
<tr id="exercise_user_<%= exercise.id %>"> <tr id="exercise_user_<%= exercise.id %>">
<td><%= (@page - 1) * @limit + index + 1 %></td> <td><%= (@page - 1) * @limit + index + 1 %></td>
<td> <td>

@ -0,0 +1,8 @@
class AddColumnExerciseViewSelfScore < ActiveRecord::Migration
def up
add_column :exercises, :view_score, :boolean, default: true
end
def down
end
end
Loading…
Cancel
Save