diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 1a7fb58a..fd8a7216 100755 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -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 diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 28ebf46f..9ce0a9ee 100755 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -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 diff --git a/app/views/exercise/_exercise_setting.html.erb b/app/views/exercise/_exercise_setting.html.erb index 41f183b1..734991ce 100755 --- a/app/views/exercise/_exercise_setting.html.erb +++ b/app/views/exercise/_exercise_setting.html.erb @@ -138,6 +138,12 @@