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.rb that 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.erb and put some dummy text in there like "Howdy Lakshmi!".
- At this point you should be able to navigate to
localhost:3000/assignment_exercises/23892 and see "Howdy Lakshmi!"
- Now, in the "show" method in the controller, you'll need to query the
AssignmentExercise object (storing it in an @assignment_exercise variable) and freak out if the current_user doesn't have permission to read it. See here for an example.
- Note that the
AssignmentExercise model doesn't yet have the permission methods that StudentAssignment does. You'll need something like this in app/models/assignment_exercise.rb to restrict access only to class educators.
- Now in the view (the
show.html.erb template 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
StudentAssignment summary 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
AssignmentExercise is attached to a Cohort, 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 to Exercise 42 (available via an Assignment's AssignmentExercise 87), then saying AssignmentExercise.find(87).student_exercises is 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 :-)
cc @Dantemss @kjdav
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
Assignmentrecord in the databasehas_manyAssignmentExercises(each of which connect that Assignment to a particular Exercise). AnAssignmentExercisehas_manyStudentExercises, each of which represent oneStudent's work for a particularExercise.A
StudentAssignmentis a linking of anAssignmentwith a particularStudent(a way to get all of theStudentExercisesfor that particularStudent).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 islocalhost: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 allStudentExercisesfor thatAssignmentExercisein one page.AssignmentExercisehas ahas_manyrelation toStudentExerciseobjects, so getting the data should be straightforward.The approach is as follows:
app/controllers/assignment_exercises_controller.rb. It should have one method (one "action") called "show".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')app/views/assignment_exercises/show.html.erband put some dummy text in there like "Howdy Lakshmi!".localhost:3000/assignment_exercises/23892and see "Howdy Lakshmi!"AssignmentExerciseobject (storing it in an@assignment_exercisevariable) and freak out if thecurrent_userdoesn't have permission to read it. See here for an example.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.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:
StudentAssignmentsummary page link to this new page.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.cc @Dantemss @kjdav