original_string: public static function set_annotations($gradeid, $pageno, $annotations) {
          global $DB;
  
          $DB->delete_records('assignfeedback_editpdf_annot', array('gradeid' => $gradeid, 'pageno' => $pageno, 'draft' => 1));
          $added = 0;
          foreach ($annotations as $record) {
              // Force these.
              if (!($record instanceof annotation)) {
                  $annotation = new annotation($record);
              } else {
                  $annotation = $record;
              }
              $annotation->gradeid = $gradeid;
              $annotation->pageno = $pageno;
              $annotation->draft = 1;
              if (self::add_annotation($annotation)) {
                  $added++;
              }
          }
  
          return $added;
      }
code: public static function set_annotations($gradeid, $pageno, $annotations) {
          global $DB;
  
          $DB->delete_records('assignfeedback_editpdf_annot', array('gradeid' => $gradeid, 'pageno' => $pageno, 'draft' => 1));
          $added = 0;
          foreach ($annotations as $record) {
              // Force these.
              if (!($record instanceof annotation)) {
                  $annotation = new annotation($record);
              } else {
                  $annotation = $record;
              }
              $annotation->gradeid = $gradeid;
              $annotation->pageno = $pageno;
              $annotation->draft = 1;
              if (self::add_annotation($annotation)) {
                  $added++;
              }
          }
  
          return $added;
      }
code_tokens: public static function set_annotations ( $ gradeid , $ pageno , $ annotations ) { global $ DB ; $ DB -> delete_records ( 'assignfeedback_editpdf_annot' , array ( 'gradeid' => $ gradeid , 'pageno' => $ pageno , 'draft' => 1 ) ) ; $ added = 0 ; foreach ( $ annotations as $ record ) { // Force these. if ( ! ( $ record instanceof annotation ) ) { $ annotation = new annotation ( $ record ) ; } else { $ annotation = $ record ; } $ annotation -> gradeid = $ gradeid ; $ annotation -> pageno = $ pageno ; $ annotation -> draft = 1 ; if ( self :: add_annotation ( $ annotation ) ) { $ added ++ ; } } return $ added ; }
docstring: Set all annotations for a page.
  @param int $gradeid
  @param int $pageno
  @param annotation[] $annotations
  @return int - the number of annotations.
docstring_tokens: Set all annotations for a page .