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