From 321d55d1fbc1fc475ead60dfc2e7e1379bdc7066 Mon Sep 17 00:00:00 2001 From: lakshmivyas Date: Tue, 20 May 2014 23:54:42 +0530 Subject: [PATCH] lml/ost#341: Add multiple cohort support. --- .../assignment_exercises_controller.rb | 5 +-- .../_response_list.html.erb | 2 +- app/views/assignment_exercises/show.html.erb | 42 +++++++++++-------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/app/controllers/assignment_exercises_controller.rb b/app/controllers/assignment_exercises_controller.rb index 16535b72..0e93bf9b 100644 --- a/app/controllers/assignment_exercises_controller.rb +++ b/app/controllers/assignment_exercises_controller.rb @@ -5,9 +5,8 @@ class AssignmentExercisesController < ApplicationController def show - @assignment_exercise = AssignmentExercise.find(params[:id]) - raise SecurityTransgression unless present_user.can_read?(@assignment_exercise) - @exercises = @assignment_exercise.exercises_by_student_status(present_user) + @assignment_exercises = AssignmentExercise.find(params[:id]).topic_exercise.assignment_exercises + raise SecurityTransgression unless present_user.can_read?(@assignment_exercises.first) @include_mathjax = true end diff --git a/app/views/assignment_exercises/_response_list.html.erb b/app/views/assignment_exercises/_response_list.html.erb index c5dcde88..89ebf3d1 100644 --- a/app/views/assignment_exercises/_response_list.html.erb +++ b/app/views/assignment_exercises/_response_list.html.erb @@ -11,7 +11,7 @@ Params: Student - Response + Response Choice Score Times diff --git a/app/views/assignment_exercises/show.html.erb b/app/views/assignment_exercises/show.html.erb index 7214f40c..1379f1b6 100644 --- a/app/views/assignment_exercises/show.html.erb +++ b/app/views/assignment_exercises/show.html.erb @@ -1,14 +1,15 @@ <%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file for details. %> -<% read_errors(@assignment_exercise) %> - +<% + assignment_exercise = @assignment_exercises.first + exercise = assignment_exercise.topic_exercise.exercise +%> <%= pageHeading("Student responses for - Assignment: #{@assignment_exercise.assignment.assignment_plan.name}, - Exercise: #{@assignment_exercise.number}", - {:sub_heading_text => full_class_name(@assignment_exercise.assignment)}) %> + Assignment: #{assignment_exercise.assignment.assignment_plan.name}, + Exercise: #{assignment_exercise.number}", + {:sub_heading_text => full_class_name(assignment_exercise.assignment)}) %> -<% exercise = @assignment_exercise.topic_exercise.exercise %> <%= render 'exercises/exercise_blurb', :exercise => exercise, :show_correct_answer => true, @@ -21,24 +22,29 @@ gray below the free responses. In both cases, a missing response will be depicted by the string '(blank)'. - <% @exercises.each do |status, lst| %> - <% if !lst.nil? && lst.count > 0 %> - <% message = "From #{status} students" %> - <%= render :partial => 'response_list', - :layout => 'layouts/section', - :locals => {:responses => lst, - :classes => 'no_bar', - :section_name => message } %> + <% @assignment_exercises.each do |ae| %> + <%= section "Cohort: #{ae.assignment.cohort.name}" do %> + <% exercises = ae.exercises_by_student_status(present_user) %> + <% exercises.each do |status, lst| %> + <% if !lst.nil? && lst.count > 0 %> + <% message = "From #{status} students" %> + <%= render :partial => 'response_list', + :layout => 'layouts/section', + :locals => {:responses => lst, + :classes => 'no_bar', + :section_name => message } %> + <% end %> + <% end %> <% end %> <% end %> <% end %> -<% prev_ae = prev_assignment_exercise(@assignment_exercise) %> -<% next_ae = next_assignment_exercise(@assignment_exercise) %> +<% prev_ae = prev_assignment_exercise(assignment_exercise) %> +<% next_ae = next_assignment_exercise(assignment_exercise) %> <% - navitem { link_to "Go to Assignment", assignment_path(@assignment_exercise.assignment) } - navitem { link_to "Go to Class", klass_path(@assignment_exercise.assignment.klass) } + navitem { link_to "Go to Assignment", assignment_path(assignment_exercise.assignment) } + navitem { link_to "Go to Class", klass_path(assignment_exercise.assignment.klass) } if !prev_ae.nil? navitem { link_to_if !prev_ae.nil?, "Previous Exercise", assignment_exercise_path(prev_ae) } end