original_string: public static function update_submission($submissionid, $title, $content = '', $contentformat = FORMAT_MOODLE,
              $inlineattachmentsid = 0, $attachmentsid = 0) {
          global $USER, $DB;
  
          $params = self::validate_parameters(self::update_submission_parameters(), array(
              'submissionid' => $submissionid,
              'title' => $title,
              'content' => $content,
              'contentformat' => $contentformat,
              'inlineattachmentsid' => $inlineattachmentsid,
              'attachmentsid' => $attachmentsid,
          ));
          $warnings = array();
  
          // Get and validate the submission and workshop.
          $submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
          list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
          require_capability('mod/workshop:submit', $context);
  
          // Check if we can update the submission.
          $canupdatesubmission = $submission->authorid == $USER->id;
          $canupdatesubmission = $canupdatesubmission && $workshop->modifying_submission_allowed($USER->id);
          $canupdatesubmission = $canupdatesubmission && $workshop->check_examples_assessed_before_submission($USER->id);
          if (!$canupdatesubmission) {
              throw new moodle_exception('nopermissions', 'error', '', 'update submission');
          }
  
          // Prepare the submission object.
          $submission->title = trim($params['title']);
          if (empty($submission->title)) {
              throw new moodle_exception('errorinvalidparam', 'webservice', '', 'title');
          }
          $submission->content_editor = array(
              'text' => $params['content'],
              'format' => $params['contentformat'],
              'itemid' => $params['inlineattachmentsid'],
          );
          $submission->attachment_filemanager = $params['attachmentsid'];
  
          $errors = $workshop->validate_submission_data((array) $submission);
          // We can get several errors, return them in warnings.
          if (!empty($errors)) {
              $status = false;
              foreach ($errors as $itemname => $message) {
                  $warnings[] = array(
                      'item' => $itemname,
                      'itemid' => 0,
                      'warningcode' => 'fielderror',
                      'message' => s($message)
                  );
              }
          } else {
              $status = true;
              $submission->id = $workshop->edit_submission($submission);
          }
  
          return array(
              'status' => $status,
              'warnings' => $warnings
          );
      }
code: public static function update_submission($submissionid, $title, $content = '', $contentformat = FORMAT_MOODLE,
              $inlineattachmentsid = 0, $attachmentsid = 0) {
          global $USER, $DB;
  
          $params = self::validate_parameters(self::update_submission_parameters(), array(
              'submissionid' => $submissionid,
              'title' => $title,
              'content' => $content,
              'contentformat' => $contentformat,
              'inlineattachmentsid' => $inlineattachmentsid,
              'attachmentsid' => $attachmentsid,
          ));
          $warnings = array();
  
          // Get and validate the submission and workshop.
          $submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
          list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
          require_capability('mod/workshop:submit', $context);
  
          // Check if we can update the submission.
          $canupdatesubmission = $submission->authorid == $USER->id;
          $canupdatesubmission = $canupdatesubmission && $workshop->modifying_submission_allowed($USER->id);
          $canupdatesubmission = $canupdatesubmission && $workshop->check_examples_assessed_before_submission($USER->id);
          if (!$canupdatesubmission) {
              throw new moodle_exception('nopermissions', 'error', '', 'update submission');
          }
  
          // Prepare the submission object.
          $submission->title = trim($params['title']);
          if (empty($submission->title)) {
              throw new moodle_exception('errorinvalidparam', 'webservice', '', 'title');
          }
          $submission->content_editor = array(
              'text' => $params['content'],
              'format' => $params['contentformat'],
              'itemid' => $params['inlineattachmentsid'],
          );
          $submission->attachment_filemanager = $params['attachmentsid'];
  
          $errors = $workshop->validate_submission_data((array) $submission);
          // We can get several errors, return them in warnings.
          if (!empty($errors)) {
              $status = false;
              foreach ($errors as $itemname => $message) {
                  $warnings[] = array(
                      'item' => $itemname,
                      'itemid' => 0,
                      'warningcode' => 'fielderror',
                      'message' => s($message)
                  );
              }
          } else {
              $status = true;
              $submission->id = $workshop->edit_submission($submission);
          }
  
          return array(
              'status' => $status,
              'warnings' => $warnings
          );
      }
code_tokens: public static function update_submission ( $ submissionid , $ title , $ content = '' , $ contentformat = FORMAT_MOODLE , $ inlineattachmentsid = 0 , $ attachmentsid = 0 ) { global $ USER , $ DB ; $ params = self :: validate_parameters ( self :: update_submission_parameters ( ) , array ( 'submissionid' => $ submissionid , 'title' => $ title , 'content' => $ content , 'contentformat' => $ contentformat , 'inlineattachmentsid' => $ inlineattachmentsid , 'attachmentsid' => $ attachmentsid , ) ) ; $ warnings = array ( ) ; // Get and validate the submission and workshop. $ submission = $ DB -> get_record ( 'workshop_submissions' , array ( 'id' => $ params [ 'submissionid' ] ) , '*' , MUST_EXIST ) ; list ( $ workshop , $ course , $ cm , $ context ) = self :: validate_workshop ( $ submission -> workshopid ) ; require_capability ( 'mod/workshop:submit' , $ context ) ; // Check if we can update the submission. $ canupdatesubmission = $ submission -> authorid == $ USER -> id ; $ canupdatesubmission = $ canupdatesubmission && $ workshop -> modifying_submission_allowed ( $ USER -> id ) ; $ canupdatesubmission = $ canupdatesubmission && $ workshop -> check_examples_assessed_before_submission ( $ USER -> id ) ; if ( ! $ canupdatesubmission ) { throw new moodle_exception ( 'nopermissions' , 'error' , '' , 'update submission' ) ; } // Prepare the submission object. $ submission -> title = trim ( $ params [ 'title' ] ) ; if ( empty ( $ submission -> title ) ) { throw new moodle_exception ( 'errorinvalidparam' , 'webservice' , '' , 'title' ) ; } $ submission -> content_editor = array ( 'text' => $ params [ 'content' ] , 'format' => $ params [ 'contentformat' ] , 'itemid' => $ params [ 'inlineattachmentsid' ] , ) ; $ submission -> attachment_filemanager = $ params [ 'attachmentsid' ] ; $ errors = $ workshop -> validate_submission_data ( ( array ) $ submission ) ; // We can get several errors, return them in warnings. if ( ! empty ( $ errors ) ) { $ status = false ; foreach ( $ errors as $ itemname => $ message ) { $ warnings [ ] = array ( 'item' => $ itemname , 'itemid' => 0 , 'warningcode' => 'fielderror' , 'message' => s ( $ message ) ) ; } } else { $ status = true ; $ submission -> id = $ workshop -> edit_submission ( $ submission ) ; } return array ( 'status' => $ status , 'warnings' => $ warnings ) ; }
docstring: Updates the given submission.
  
  @param int $submissionid         the submission id
  @param string $title             the submission title
  @param string  $content          the submission text content
  @param int  $contentformat       the format used for the content
  @param int $inlineattachmentsid  the draft file area id for inline attachments in the content
  @param int $attachmentsid        the draft file area id for attachments
  @return array whether the submission was updated and warnings.
  @since Moodle 3.4
  @throws moodle_exception
docstring_tokens: Updates the given submission .