-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lml#341: Add sidebar nav for assignment exercises.
- Add link to the class. - Add link to the assignment. - Add a helper class for getting previous and next assignments. - Add prev / next links in nav.
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
# License version 3 or later. See the COPYRIGHT file for details. | ||
|
||
module AssignmentExerciseHelper | ||
|
||
def assignment_exercise_index(assignment_exercise) | ||
assignment_exercise.number - 1 | ||
end | ||
|
||
def prev_assignment_exercise(assignment_exercise) | ||
index = assignment_exercise_index(assignment_exercise) | ||
if index > 0 | ||
assignment_exercise.assignment.assignment_exercises[index-1] | ||
end | ||
end | ||
|
||
def next_assignment_exercise(assignment_exercise) | ||
index = assignment_exercise_index(assignment_exercise) | ||
if index < assignment_exercise.assignment.assignment_exercises.count - 1 | ||
assignment_exercise.assignment.assignment_exercises[index+1] | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters