             store = get_store()
             if not @_store_is_initialized()
                 return finish("store not yet initialized")
+            grade = store.get_grade(assignment, student)
             if not student = store.get_student(student)
                 return finish("no student")
             if not assignment = store.get_assignment(assignment)

                @clear_activity(id)
            else
                @set_activity(id:id, desc:"Returning assignment to #{student_name}")
                salvus_client.copy_path_between_projects
                    src_project_id    : course_project_id
                    src_path          : assignment.get('collect_path') + '/' + student.get('student_id')
                    target_project_id : student_project_id
                    target_path       : assignment.get('graded_path')
                    overwrite_newer   : assignment.get('overwrite_newer')
                    delete_missing    : assignment.get('delete_missing')
                    exclude_history   : true
                    cb                : finish

        # Copy the given assignment to all non-deleted students, doing several copies in parallel at once.
        return_assignment_to_all_students: (assignment, new_only) =>

            @set_activity(id:id, desc:"Copying assignment to #{student_name}")
            student_project_id = student.get('project_id')
            student_id = student.get('student_id')
            src_path = assignment.get('path')
            async.series([
                (cb) =>
                    if not student_project_id?
