-
Notifications
You must be signed in to change notification settings - Fork 8
Let instructors view all responses to one exercise #341
Description
Currently, when an educator wants to review student work in Tutor, their only option is to visit a page that lists all of the responses from one student for one exercise.
It has often been requested that we add a page that shows the responses from everyone in the class for one particular exercise. Such a page would let an educator quickly scan through the responses to see if there were any trends in them.
All of the data is available to make this happen, we just need to add the page.
First a quick word about relevant models. An Assignment record in the database has_many AssignmentExercises (each of which connect that Assignment to a particular Exercise). An AssignmentExercise has_many StudentExercises, each of which represent one Student's work for a particular Exercise.
A StudentAssignment is a linking of an Assignment with a particular Student (a way to get all of the StudentExercises for that particular Student).
Right now, the page mentioned above that shows all of the work for one student and one assignment makes use of the StudentAssignment. The URL is localhost:3000/student_assignments/27218, where the number at the end is the db ID of the student assignment in question.
The page we want to add is focused on a particular AssignmentExercise, since we want to see all StudentExercises for that AssignmentExercise in one page. AssignmentExercise has a has_many relation to StudentExercise objects, so getting the data should be straightforward.
The approach is as follows:
- There is no controller for assignment exercises yet. Create it in
app/controllers/assignment_exercises_controller.rb. It should have one method (one "action") called "show". - You'll need to set up a route in
config/routes.rbthat will take an incoming URL and "route" it to this controller action.resources :assignment_exercises, only: [:show]should do the trick. (shortcut for `get 'assignment_exercises/:id', to: 'assignment_exercises#show') - You'll need a view file (the HTML template to render). Create
app/views/assignment_exercises/show.html.erband put some dummy text in there like "Howdy Lakshmi!". - At this point you should be able to navigate to
localhost:3000/assignment_exercises/23892and see "Howdy Lakshmi!" - Now, in the "show" method in the controller, you'll need to query the
AssignmentExerciseobject (storing it in an@assignment_exercisevariable) and freak out if thecurrent_userdoesn't have permission to read it. See here for an example. - Note that the
AssignmentExercisemodel doesn't yet have the permission methods thatStudentAssignmentdoes. You'll need something like this inapp/models/assignment_exercise.rbto restrict access only to class educators. - Now in the view (the
show.html.erbtemplate file from above), you can iterate through the assignment exercise's student exercises with something like<% @assignment_exercise.student_exercises.each do |student_exercise| %> html stuff here <% end %>.
Notes:
- We should make sure we have obvious links to these pages from the other instructor views. One idea is to make links out of the exercise numbers in the student result grids on the assignment page. We can also make the exercise numbers on the existing
StudentAssignmentsummary page link to this new page. - For research purposes, we often split a class into multiple cohorts of students. Each cohort gets a different set of problems each week. An
AssignmentExerciseis attached to aCohort, and different cohorts' different assignment exercises can refer to different Exercises. (that is confusing but @kjdav can explain). The bottom line is that if an instructor wants to see all of the responses toExercise42 (available via anAssignment'sAssignmentExercise87), then sayingAssignmentExercise.find(87).student_exercisesis only going to return the work for exercise 42 in one of the possibly several cohorts in a class. If we want to be more advanced and show all work related to exercise 42 regardless of which cohort or assignment it was worked by students, we'd need a more complex query which we can discuss. - We'll need to chat about all of this of course, because this is a lot all at the beginning :-)