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

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)
@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,6 +67,7 @@
<%= render :partial => "exercise/total_questions_score" %>
</div>
<% 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>
@ -95,6 +96,8 @@
<% end %>
</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,6 +109,7 @@
分</span><span class="ml10 color-red"><%= question_commit_status exercise_question, @exercise_user.user %></span>
</p>
<% if exercise_question.question_type != 4 %>
<% if @show_score %>
<% is_correct = answer_is_correct(exercise_question, user) %>
<p class="fr">
<% if exercise_question.question_type == 3 && @is_teacher %>
@ -130,15 +134,18 @@
</span>分
<% 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 %>
<% 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 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p>

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