Commit c7fc66f2 authored by David Monllaó's avatar David Monllaó
Browse files

Merge branch 'MDL-45969-master' of git://github.com/damyon/moodle

parents 2a864ee9 f5ba9ac9
......@@ -72,7 +72,7 @@ if ($action == 'loadallpages') {
$response->pagecount = count($pages);
$response->pages = array();
$grade = $assignment->get_user_grade($userid, true);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
// The readonly files are stored in a different file area.
$filearea = document_services::PAGE_IMAGE_FILEAREA;
......@@ -111,7 +111,7 @@ if ($action == 'loadallpages') {
$response = new stdClass();
$response->errors = array();
$grade = $assignment->get_user_grade($userid, true);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$pagejson = required_param('page', PARAM_RAW);
$page = json_decode($pagejson);
......@@ -132,7 +132,7 @@ if ($action == 'loadallpages') {
require_capability('mod/assign:grade', $context);
$response = new stdClass();
$grade = $assignment->get_user_grade($userid, true);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$file = document_services::generate_feedback_document($assignment, $userid, $attemptnumber);
$response->url = '';
......@@ -172,7 +172,7 @@ if ($action == 'loadallpages') {
} else if ($action == 'revertchanges') {
require_capability('mod/assign:grade', $context);
$grade = $assignment->get_user_grade($userid, true);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$result = page_editor::revert_drafts($gradeid);
......@@ -190,7 +190,7 @@ if ($action == 'loadallpages') {
} else if ($action == 'deletefeedbackdocument') {
require_capability('mod/assign:grade', $context);
$grade = $assignment->get_user_grade($userid, true);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$result = document_services::delete_feedback_document($assignment, $userid, $attemptnumber);
$result = $result && page_editor::unrelease_drafts($grade->id);
......
......@@ -161,9 +161,9 @@ EOD;
$files = array();
if ($assignment->get_instance()->teamsubmission) {
$submission = $assignment->get_group_submission($userid, 0, false);
$submission = $assignment->get_group_submission($userid, 0, false, $attemptnumber);
} else {
$submission = $assignment->get_user_submission($userid, false);
$submission = $assignment->get_user_submission($userid, false, $attemptnumber);
}
$user = $DB->get_record('user', array('id' => $userid));
......@@ -230,9 +230,9 @@ EOD;
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
if ($assignment->get_instance()->teamsubmission) {
$submission = $assignment->get_group_submission($userid, 0, false);
$submission = $assignment->get_group_submission($userid, 0, false, $attemptnumber);
} else {
$submission = $assignment->get_user_submission($userid, false);
$submission = $assignment->get_user_submission($userid, false, $attemptnumber);
}
$contextid = $assignment->get_context()->id;
......@@ -486,9 +486,9 @@ EOD;
}
if ($assignment->get_instance()->teamsubmission) {
$submission = $assignment->get_group_submission($userid, 0, false);
$submission = $assignment->get_group_submission($userid, 0, false, $attemptnumber);
} else {
$submission = $assignment->get_user_submission($userid, false);
$submission = $assignment->get_user_submission($userid, false, $attemptnumber);
}
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
......
......@@ -58,7 +58,7 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
*/
public function get_widget($userid, $grade, $readonly) {
$attempt = -1;
if ($grade && $grade->attemptnumber) {
if ($grade) {
$attempt = $grade->attemptnumber;
} else {
$grade = $this->assignment->get_user_grade($userid, true);
......
@mod @mod_assign @assignfeedback @assignfeedback_editpdf @_file_upload
Feature: In an assignment, teacher can view the feedback for a previous attempt.
In order to see the history of attempts
As a teacher
I need to see the previous annotations.
@javascript
Scenario: Submit a PDF file as a student and annotate the PDF as a teacher, allowing another attempt
Given ghostscript is installed
And the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assignment name |
| Description | Submit your PDF file |
| assignsubmission_file_enabled | 1 |
| Maximum number of uploaded files | 2 |
| Attempts reopened | Manually |
| Maximum attempts | Unlimited |
And I log out
And I log in as "student1"
And I follow "Course 1"
And I follow "Test assignment name"
And I press "Add submission"
And I upload "mod/assign/feedback/editpdf/tests/fixtures/submission.pdf" file to "File submissions" filemanager
And I upload "mod/assign/feedback/editpdf/tests/fixtures/testgs.pdf" file to "File submissions" filemanager
And I press "Save changes"
And I should see "Submitted for grading"
And I should see "submission.pdf"
And I should see "Not graded"
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I follow "Test assignment name"
And I follow "View all submissions"
And I click on "Edit" "link" in the "Submitted for grading" "table_row"
And I click on "Grade" "link" in the "Submitted for grading" "table_row"
And I should see "Page 1 of 3"
And I click on ".navigate-next-button" "css_element"
And I should see "Page 2 of 3"
And I click on ".stampbutton" "css_element"
And I draw on the pdf
And I wait until the page is ready
And I set the field "Allow another attempt" to "Yes"
And I press "Save changes"
And I wait until the page is ready
And I should see "The changes to the grade and feedback were saved"
And I press "Ok"
And I follow "View a different attempt"
And I click on "//div[contains(@class, 'moodle-dialogue-bd')]//label[2]" "xpath_element"
And I press "View"
And I wait until the page is ready
And I should see "You are editing the feedback for a previous attempt. This is attempt 1 out of 2."
And I should see "Page 1 of 3"
......@@ -6666,7 +6666,9 @@ class assign {
}
$userid = $useridlist[$rownum];
$grade = $this->get_user_grade($userid, false, $attemptnumber);
// We need to create a grade record matching this attempt number
// or the feedback plugin will have no way to know what is the correct attempt.
$grade = $this->get_user_grade($userid, true, $attemptnumber);
$submission = null;
if ($this->get_instance()->teamsubmission) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment