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

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.question_random = params[:question_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.answer_open = params[:answer_open] ? 1 : 0
@exercise.show_statistic = params[:show_statistic] ? 1 : 0
@ -1342,11 +1343,14 @@ class ExerciseController < ApplicationController
end
@exercise = Exercise.find params[:id]
@course = @exercise.course
@is_teacher = params[:pdf] ? 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]
@is_teacher = params[:pdf] && User.current.nil? ? true : User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@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_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|
if params[:pdf]
format.html { render :layout => "pdf" }
@ -1470,7 +1474,7 @@ class ExerciseController < ApplicationController
:status => answer_status)
end
score4 += exercise_cha_score
score4 += exercise_cha_score.to_f
end
end
end

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

@ -138,6 +138,12 @@
<div class="ml30 mr30 mb15">
<div class="clearfix pl30">
<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">
<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' : '' %>>
@ -309,6 +315,12 @@
<div class="ml30 mr30">
<div class="clearfix pl30">
<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">
<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' : '' %>>

@ -67,34 +67,37 @@
<%= render :partial => "exercise/total_questions_score" %>
</div>
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20 panel-box-sizing" id="exercise_No">
<div class="clearfix">
<span class="fl ml15 mr20 font-15">客观题</span>
<span class="checkstatus_box_small post_btn_green mt10"></span><span class="fl mr20 font-12 mt3">正确</span>
<span class="checkstatus_box_small post_btn_red mt10"></span><span class="fl 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>分
</p>
</div>
<div class="clearfix ml80 mt10 mb5">
<% que_count = exercise_questions.where(:question_type => [1, 2, 3]).count %>
<% exercise_questions.where(:question_type => [1, 2, 3, 5]).each_with_index do |eq, index| %>
<% is_correct = answer_is_correct(eq, user) %>
<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>
<% end %>
</div>
<div class="clearfix">
<span class="fl ml15 mr20 font-15">主观题</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="fl checkstatus_box_small post_btn_grey mt10"></span><span class="fl font-12 mt3">未评</span>
<span class="mr15 mt3 fr color-grey font-14">开始答题时间:<%= format_time @exercise_user.start_at %></span>
</div>
<div class="clearfix ml80 mt10">
<% exercise_questions.where(:question_type => 4).each do |eq| %>
<% ea = @exercise_user.user.exercise_answer.where(:exercise_question_id => eq.id).first %>
<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 %>
<% if @show_score %>
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20 panel-box-sizing" id="exercise_No">
<div class="clearfix">
<span class="fl ml15 mr20 font-15">客观题</span>
<span class="checkstatus_box_small post_btn_green mt10"></span><span class="fl mr20 font-12 mt3">正确</span>
<span class="checkstatus_box_small post_btn_red mt10"></span><span class="fl 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>分
</p>
</div>
<div class="clearfix ml80 mt10 mb5">
<% que_count = exercise_questions.where(:question_type => [1, 2, 3]).count %>
<% exercise_questions.where(:question_type => [1, 2, 3, 5]).each_with_index do |eq, index| %>
<% is_correct = answer_is_correct(eq, user) %>
<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>
<% end %>
</div>
<div class="clearfix">
<span class="fl ml15 mr20 font-15">主观题</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="fl checkstatus_box_small post_btn_grey mt10"></span><span class="fl font-12 mt3">未评</span>
<span class="mr15 mt3 fr color-grey font-14">开始答题时间:<%= format_time @exercise_user.start_at %></span>
</div>
<div class="clearfix ml80 mt10">
<% exercise_questions.where(:question_type => 4).each do |eq| %>
<% ea = @exercise_user.user.exercise_answer.where(:exercise_question_id => eq.id).first %>
<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>
<% end %>
<div class="clearfix" id="problem_main">
<% question_list = exercise_questions.includes(:exercise_shixun_answers, :exercise_choices => [:exercise_answers]) %>
<% 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>
</p>
<% if exercise_question.question_type != 4 %>
<% is_correct = answer_is_correct(exercise_question, user) %>
<p class="fr">
<% if exercise_question.question_type == 3 && @is_teacher %>
<% answer = get_user_answer(exercise_question, user).first %>
<% if answer.present? %>
<a href="javascript:void(0)" onclick="toggle_comment_block(<%= exercise_question.id %>, <%= answer.id %>)" data-remote="true" class="mr15 color-blue">调分</a>
<% end %>
<% 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 @show_score %>
<% is_correct = answer_is_correct(exercise_question, user) %>
<p class="fr">
<% if exercise_question.question_type == 3 && @is_teacher %>
<% answer = get_user_answer(exercise_question, user).first %>
<% if answer.present? %>
<a href="javascript:void(0)" onclick="toggle_comment_block(<%= exercise_question.id %>, <%= answer.id %>)" data-remote="true" class="mr15 color-blue">调分</a>
<% end %>
<% 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 %>
<i class="mr5 fa <%= is_correct ? 'fa-check' : 'fa-close' %> font-14"></i>
<% end %>
<%= score %>
<%= score %>
</span>分
<% else %>
<% 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 %>">
<% else %>
<% 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 %>">
<% if exercise_question.question_type != 5 || (is_correct || score == 0) %>
<i class="mr5 fa <%= is_correct ? 'fa-check' : 'fa-close' %> font-14"></i>
<% end %>
<%= score %>
<%= score %>
</span>分
<% end %>
</p>
<% end %>
</p>
<% end %>
<% if exercise_question.question_type == 5 %>
<%= link_to '实训详情', shixun_path(exercise_question.shixun), :target => "_blank", :class => "fr mr10 white-btn orange-btn" %>
<% end %>
<% else %>
<% answer = get_user_answer(exercise_question, user) %>
<p class="fr" id="question_score_<%= exercise_question.id %>">
<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>
<% if @show_score %>
<% answer = get_user_answer(exercise_question, user) %>
<p class="fr" id="question_score_<%= exercise_question.id %>">
<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 %>
</div>
<% if exercise_question.question_type == 5 %>

@ -25,7 +25,7 @@
<tbody>
<% exercise_subject_q = @exercise.exercise_questions.where(:question_type => 4).count == 0 %>
<% @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 %>">
<td><%= (@page - 1) * @limit + index + 1 %></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