Class: Gaku::ExamsController
- Inherits:
-
GakuController
- Object
- CoreController
- GakuController
- Gaku::ExamsController
- Defined in:
- app/controllers/gaku/exams_controller.rb
Instance Method Summary collapse
- #completed ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #export ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from GakuController
Instance Method Details
#completed ⇒ Object
65 66 67 68 69 70 71 |
# File 'app/controllers/gaku/exams_controller.rb', line 65 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.new(exam_params) @exam.use_primary_grading_method_set if @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
61 62 63 |
# File 'app/controllers/gaku/exams_controller.rb', line 61 def export @course = Course.find(params[:course_id]) end |
#index ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/gaku/exams_controller.rb', line 10 def index if params[:course_id] @exams = Course.find(params[:course_id]).syllabus.exams else @search = Exam.includes(:department).search(params[:q]) results = @search.result(distinct: true) @exams = results.page(params[:page]) @exam = Exam.new @exam_sessions = ExamSession.all 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 |
#show ⇒ Object
29 30 31 |
# File 'app/controllers/gaku/exams_controller.rb', line 29 def show respond_with @exam 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 |