Class: Gaku::ExamsController
- Inherits:
-
GakuController
- Object
- GakuController
- Gaku::ExamsController
- Includes:
- Grading::Calculations
- Defined in:
- app/controllers/gaku/exams_controller.rb
Instance Method Summary collapse
-
#completed ⇒ Object
respond_to do |format| format.json do render json: { student_total_scores: @student_total_scores.as_json, exams: @exams.as_json(include: {include: :exam_portion_scores },root: false), course: @course.as_json(root: false), exam_averages: @exam_averages.as_json(root: false), deviation: @deviation.as_json(root: false), students: @students.to_json(root: false), grades: @grades.as_json(root: false), ranks: @ranks.as_json(root: false), attendances: @student_portion_attendance.as_json(root: true, include: :attendance_type), path_to_exam: @path_to_exam.to_json, completion: @completion }end format.html { render ‘gaku/exams/grading’ } end end.
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #export ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #recovery ⇒ Object
- #show ⇒ Object
- #soft_delete ⇒ Object
- #update ⇒ Object
Instance Method Details
#completed ⇒ Object
respond_to do |format|
format.json do render json: {
student_total_scores: @student_total_scores.as_json,
exams: @exams.as_json(include: {exam_portions: {include: :exam_portion_scores }},root: false),
course: @course.as_json(root: false),
exam_averages: @exam_averages.as_json(root: false),
deviation: @deviation.as_json(root: false),
students: @students.to_json(root: false),
grades: @grades.as_json(root: false),
ranks: @ranks.as_json(root: false),
attendances: @student_portion_attendance.as_json(root: true, include: :attendance_type),
path_to_exam: @path_to_exam.to_json,
completion: @completion
}end
format.html { render 'gaku/exams/grading' }
end
end
112 113 114 115 116 117 118 119 |
# File 'app/controllers/gaku/exams_controller.rb', line 112 def completed @exam = Exam.find(params[:id]) @course = Course.find(params[:course_id]) @students = @course.students respond_with @exam.completed_by_students(@students) end |
#create ⇒ Object
39 40 41 42 43 44 |
# File 'app/controllers/gaku/exams_controller.rb', line 39 def create @exam = Exam.create(exam_params) @exam.save set_count respond_with @exam end |
#destroy ⇒ Object
55 56 57 58 59 |
# File 'app/controllers/gaku/exams_controller.rb', line 55 def destroy @exam.destroy set_count respond_with @exam end |
#edit ⇒ Object
46 47 48 |
# File 'app/controllers/gaku/exams_controller.rb', line 46 def edit respond_with @exam end |
#export ⇒ Object
71 72 73 |
# File 'app/controllers/gaku/exams_controller.rb', line 71 def export @course = Course.find(params[:course_id]) end |
#index ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/gaku/exams_controller.rb', line 13 def index if params[:course_id] @exams = Course.find(params[:course_id]).syllabus.exams else @exams = Exam.all @exam = Exam.new end @exam.exam_portions.build set_count respond_to do |format| format.html format.json { render json: @exams.as_json(include: {exam_portions: {include: :exam_portion_scores}})} end end |
#new ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/gaku/exams_controller.rb', line 33 def new @exam = Exam.new @master_portion = @exam.exam_portions.new respond_with @exam end |
#recovery ⇒ Object
61 62 63 64 |
# File 'app/controllers/gaku/exams_controller.rb', line 61 def recovery @exam.recover respond_with @exam end |
#show ⇒ Object
29 30 31 |
# File 'app/controllers/gaku/exams_controller.rb', line 29 def show respond_with @exam end |
#soft_delete ⇒ Object
66 67 68 69 |
# File 'app/controllers/gaku/exams_controller.rb', line 66 def soft_delete @exam.soft_delete respond_with @exam, location: exams_path end |
#update ⇒ Object
50 51 52 53 |
# File 'app/controllers/gaku/exams_controller.rb', line 50 def update @exam.update(exam_params) respond_with @exam, location: [:edit, @exam] end |