Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-45582: Apply grades and feedback to entire group does not work wi…

…th Annotate PDF feature
  • Loading branch information...
commit 41b20b6e186446026eae091370c0186da3830360 1 parent ba05f57
@greg-or greg-or authored
View
32 mod/assign/feedback/editpdf/classes/page_editor.php
@@ -308,4 +308,36 @@ public static function remove_annotation($annotationid) {
return $DB->delete_records('assignfeedback_editpdf_annot', array('id'=>$annotationid));
}
+
+ /**
+ * This function copies annotations and comments from the source user
+ * to the current group member being processed when using applytoall.
+ * @param int|\assign $assignment
+ * @param stdClass $grade
+ * @param int $sourceuserid
+ * @return bool
+ */
+ public static function copy_drafts_from_to($assignment, $grade, $sourceuserid) {
+ global $DB;
+
+ // Delete any existing annotations and comments from current user.
+ $DB->delete_records('assignfeedback_editpdf_annot', array('gradeid' => $grade->id));
+ $DB->delete_records('assignfeedback_editpdf_cmnt', array('gradeid' => $grade->id));
+ // Get gradeid, annotations and comments from sourceuserid.
+ $sourceusergrade = $assignment->get_user_grade($sourceuserid, true, $grade->attemptnumber);
+ $annotations = $DB->get_records('assignfeedback_editpdf_annot', array('gradeid' => $sourceusergrade->id, 'draft' => 1));
+ $comments = $DB->get_records('assignfeedback_editpdf_cmnt', array('gradeid' => $sourceusergrade->id, 'draft' => 1));
+
+ // Add annotations and comments to current user to generate feedback file.
+ foreach ($annotations as $annotation) {
+ $annotation->gradeid = $grade->id;
+ $DB->insert_record('assignfeedback_editpdf_annot', $annotation);
+ }
+ foreach ($comments as $comment) {
+ $comment->gradeid = $grade->id;
+ $DB->insert_record('assignfeedback_editpdf_cmnt', $comment);
+ }
+
+ return true;
+ }
}
View
8 mod/assign/feedback/editpdf/locallib.php
@@ -178,6 +178,9 @@ public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdCl
$html = $renderer->render($widget);
$mform->addElement('static', 'editpdf', get_string('editpdf', 'assignfeedback_editpdf'), $html);
$mform->addHelpButton('editpdf', 'editpdf', 'assignfeedback_editpdf');
+ $mform->addElement('hidden', 'editpdf_source_userid', $userid);
+ $mform->setType('editpdf_source_userid', PARAM_INT);
+ $mform->setConstant('editpdf_source_userid', $userid);
}
}
@@ -189,6 +192,11 @@ public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdCl
* @return bool
*/
public function save(stdClass $grade, stdClass $data) {
+ $sourceuserid = $data->editpdf_source_userid;
+ // Copy drafts annotations and comments if current user is different to sourceuserid.
+ if ($sourceuserid != $grade->userid) {
+ page_editor::copy_drafts_from_to($this->assignment, $grade, $sourceuserid);
+ }
if (page_editor::has_annotations_or_comments($grade->id, true)) {
document_services::generate_feedback_document($this->assignment, $grade->userid, $grade->attemptnumber);
}
Please sign in to comment.
Something went wrong with that request. Please try again.