Class: Gaku::ExamsController

Inherits:
GakuController show all
Defined in:
app/controllers/gaku/exams_controller.rb

Instance Method Summary collapse

Methods inherited from GakuController

#resolve_layout

Instance Method Details

#completedObject



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

#createObject



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

#destroyObject



55
56
57
58
59
# File 'app/controllers/gaku/exams_controller.rb', line 55

def destroy
  @exam.destroy
  set_count
  respond_with @exam
end

#editObject



46
47
48
# File 'app/controllers/gaku/exams_controller.rb', line 46

def edit
  respond_with @exam
end

#exportObject



61
62
63
# File 'app/controllers/gaku/exams_controller.rb', line 61

def export
  @course = Course.find(params[:course_id])
end

#indexObject



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

#newObject



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

#showObject



29
30
31
# File 'app/controllers/gaku/exams_controller.rb', line 29

def show
  respond_with @exam
end

#updateObject



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