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