Skip to content

Commit

Permalink
lml#341: Add multiple cohort support.
Browse files Browse the repository at this point in the history
  • Loading branch information
navilan committed May 20, 2014
1 parent 98b2966 commit 321d55d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
5 changes: 2 additions & 3 deletions app/controllers/assignment_exercises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/views/assignment_exercises/_response_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Params:
<thead>
<tr>
<th width="8%">Student</th>
<th width="56%">Response</th>
<th width="60%">Response</th>
<th width="8%">Choice</th>
<th width="8%">Score</th>
<th width="8%">Times</th>
Expand Down
42 changes: 24 additions & 18 deletions app/views/assignment_exercises/show.html.erb
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 321d55d

Please sign in to comment.