original_string: 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));
          $contextid = $assignment->get_context()->id;
          $sourceitemid = $sourceusergrade->id;
  
          // 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);
          }
  
          $fs = get_file_storage();
  
          // Copy the stamp files.
          self::replace_files_from_to($fs, $contextid, $sourceitemid, $grade->id, document_services::STAMPS_FILEAREA, true);
  
          // Copy the PAGE_IMAGE_FILEAREA files.
          self::replace_files_from_to($fs, $contextid, $sourceitemid, $grade->id, document_services::PAGE_IMAGE_FILEAREA);
  
          return true;
      }
code: 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));
          $contextid = $assignment->get_context()->id;
          $sourceitemid = $sourceusergrade->id;
  
          // 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);
          }
  
          $fs = get_file_storage();
  
          // Copy the stamp files.
          self::replace_files_from_to($fs, $contextid, $sourceitemid, $grade->id, document_services::STAMPS_FILEAREA, true);
  
          // Copy the PAGE_IMAGE_FILEAREA files.
          self::replace_files_from_to($fs, $contextid, $sourceitemid, $grade->id, document_services::PAGE_IMAGE_FILEAREA);
  
          return true;
      }
code_tokens: 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 ) ) ; $ contextid = $ assignment -> get_context ( ) -> id ; $ sourceitemid = $ sourceusergrade -> id ; // 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 ) ; } $ fs = get_file_storage ( ) ; // Copy the stamp files. self :: replace_files_from_to ( $ fs , $ contextid , $ sourceitemid , $ grade -> id , document_services :: STAMPS_FILEAREA , true ) ; // Copy the PAGE_IMAGE_FILEAREA files. self :: replace_files_from_to ( $ fs , $ contextid , $ sourceitemid , $ grade -> id , document_services :: PAGE_IMAGE_FILEAREA ) ; return true ; }
docstring: Copy annotations, comments, pages, and other required content from the source user to the current group member
  being procssed when using applytoall.
  
  @param int|\assign $assignment
  @param stdClass $grade
  @param int $sourceuserid
  @return bool
docstring_tokens: Copy annotations comments pages and other required content from the source user to the current group member being procssed when using applytoall .