Skip to content
This repository was archived by the owner on May 10, 2022. It is now read-only.
This repository was archived by the owner on May 10, 2022. It is now read-only.

Let instructors view all responses to one exercise #341

@jpslav

Description

@jpslav

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:

  1. 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".
  2. 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')
  3. 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!".
  4. At this point you should be able to navigate to localhost:3000/assignment_exercises/23892 and see "Howdy Lakshmi!"
  5. 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.
  6. 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.
  7. 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:

  1. 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.
  2. 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.
  3. We'll need to chat about all of this of course, because this is a lot all at the beginning :-)

cc @Dantemss @kjdav

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions