|
|
|
@ -9,11 +9,11 @@ class ExerciseController < ApplicationController
|
|
|
|
|
:send_to_course, :get_student_uncomplete_question, :edit_question_score, :setting, :set_public,
|
|
|
|
|
:ex_setting, :add_to_exercise_bank, :choose_shixuns, :shixun_question, :back_to_answer, :export_blank_exercise, :export_student_result,
|
|
|
|
|
:choose_student, :redo_exercise, :cancel_commit_confirm, :cancel_commit,
|
|
|
|
|
:update_shixun_block, :delete_shixun_question]
|
|
|
|
|
:update_shixun_block, :delete_shixun_question, :delete_choose_shixun]
|
|
|
|
|
before_filter :find_course, :only => [:index,:new,:create]
|
|
|
|
|
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :create_exercise_question, :publish_exercise, :publish_notice, :end_exercise, :cancel_publish,
|
|
|
|
|
:update_question_num, :send_to_course, :edit_question_score, :set_public, :ex_setting, :export_blank_exercise, :export_student_result,
|
|
|
|
|
:choose_shixuns, :shixun_question, :update_shixun_block, :delete_shixun_question]
|
|
|
|
|
:choose_shixuns, :shixun_question, :update_shixun_block, :delete_shixun_question, :delete_choose_shixun]
|
|
|
|
|
before_filter :require_login, :only => [:student_exercise_list, :show]
|
|
|
|
|
include ExerciseHelper
|
|
|
|
|
include ApplicationHelper
|
|
|
|
@ -76,12 +76,12 @@ class ExerciseController < ApplicationController
|
|
|
|
|
if @exercise_user.nil?
|
|
|
|
|
@exercise_user = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false, :commit_status => 0)
|
|
|
|
|
if @exercise.exercise_level_settings.where("num != exercise_questions_count").count > 0
|
|
|
|
|
@exercise.create_user_question_list(@exercise_user)
|
|
|
|
|
@exercise.create_user_question_list(@exercise_user.id)
|
|
|
|
|
end
|
|
|
|
|
# @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
|
|
|
|
|
elsif @exercise_user.start_at.nil?
|
|
|
|
|
if @exercise.exercise_level_settings.where("num != exercise_questions_count").count > 0
|
|
|
|
|
@exercise.create_user_question_list(@exercise_user)
|
|
|
|
|
@exercise.create_user_question_list(@exercise_user.id)
|
|
|
|
|
end
|
|
|
|
|
@exercise_user.update_attributes(:start_at => Time.now)
|
|
|
|
|
end
|
|
|
|
@ -112,7 +112,7 @@ class ExerciseController < ApplicationController
|
|
|
|
|
@can_edit_excercise = false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@exercise_questions = user_question_list @exercise_user.id
|
|
|
|
|
@exercise_questions = @exercise.user_question_list @exercise_user.id
|
|
|
|
|
|
|
|
|
|
# @percent = get_percent(@exercise,User.current)
|
|
|
|
|
#@exercise_questions = @exercise.exercise_questions
|
|
|
|
@ -221,6 +221,10 @@ class ExerciseController < ApplicationController
|
|
|
|
|
@exercise.exercise_level_settings.destroy_all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def delete_choose_shixun
|
|
|
|
|
@exercise.exercise_questions.where(question_type: 5, exercise_level_setting_id: 0).destroy_all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
if params[:exercise]
|
|
|
|
|
exercise = Exercise.new
|
|
|
|
@ -1315,7 +1319,7 @@ class ExerciseController < ApplicationController
|
|
|
|
|
if @is_teacher || (User.current.member_of_course?(@exercise.course) && @exercise.exercise_status > 2)
|
|
|
|
|
@user = User.find params[:user_id]
|
|
|
|
|
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
|
|
|
|
|
@exercise_questions = @exercise.user_question_list @exercise_user.id
|
|
|
|
|
@exercise_questions = (@exercise.user_question_list @exercise_user.id).reorder("question_number = 0 asc, question_number asc")
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
if params[:pdf]
|
|
|
|
|
format.html { render :layout => "pdf" }
|
|
|
|
|