original_string: public function submit_for_grading($data, $notices) {
          global $USER;
  
          $userid = $USER->id;
          if (!empty($data->userid)) {
              $userid = $data->userid;
          }
          // Need submit permission to submit an assignment.
          if ($userid == $USER->id) {
              require_capability('mod/assign:submit', $this->context);
          } else {
              if (!$this->can_edit_submission($userid, $USER->id)) {
                  print_error('nopermission');
              }
          }
  
          $instance = $this->get_instance();
  
          if ($instance->teamsubmission) {
              $submission = $this->get_group_submission($userid, 0, true);
          } else {
              $submission = $this->get_user_submission($userid, true);
          }
  
          if (!$this->submissions_open($userid)) {
              $notices[] = get_string('submissionsclosed', 'assign');
              return false;
          }
  
          if ($instance->requiresubmissionstatement && empty($data->submissionstatement) && $USER->id == $userid) {
              return false;
          }
  
          if ($submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
              // Give each submission plugin a chance to process the submission.
              $plugins = $this->get_submission_plugins();
              foreach ($plugins as $plugin) {
                  if ($plugin->is_enabled() && $plugin->is_visible()) {
                      $plugin->submit_for_grading($submission);
                  }
              }
  
              $submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
              $this->update_submission($submission, $userid, true, $instance->teamsubmission);
              $completion = new completion_info($this->get_course());
              if ($completion->is_enabled($this->get_course_module()) && $instance->completionsubmit) {
                  $this->update_activity_completion_records($instance->teamsubmission,
                                                            $instance->requireallteammemberssubmit,
                                                            $submission,
                                                            $userid,
                                                            COMPLETION_COMPLETE,
                                                            $completion);
              }
  
              if (!empty($data->submissionstatement) && $USER->id == $userid) {
                  \mod_assign\event\statement_accepted::create_from_submission($this, $submission)->trigger();
              }
              $this->notify_graders($submission);
              $this->notify_student_submission_receipt($submission);
  
              \mod_assign\event\assessable_submitted::create_from_submission($this, $submission, false)->trigger();
  
              return true;
          }
          $notices[] = get_string('submissionsclosed', 'assign');
          return false;
      }
code: public function submit_for_grading($data, $notices) {
          global $USER;
  
          $userid = $USER->id;
          if (!empty($data->userid)) {
              $userid = $data->userid;
          }
          // Need submit permission to submit an assignment.
          if ($userid == $USER->id) {
              require_capability('mod/assign:submit', $this->context);
          } else {
              if (!$this->can_edit_submission($userid, $USER->id)) {
                  print_error('nopermission');
              }
          }
  
          $instance = $this->get_instance();
  
          if ($instance->teamsubmission) {
              $submission = $this->get_group_submission($userid, 0, true);
          } else {
              $submission = $this->get_user_submission($userid, true);
          }
  
          if (!$this->submissions_open($userid)) {
              $notices[] = get_string('submissionsclosed', 'assign');
              return false;
          }
  
          if ($instance->requiresubmissionstatement && empty($data->submissionstatement) && $USER->id == $userid) {
              return false;
          }
  
          if ($submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
              // Give each submission plugin a chance to process the submission.
              $plugins = $this->get_submission_plugins();
              foreach ($plugins as $plugin) {
                  if ($plugin->is_enabled() && $plugin->is_visible()) {
                      $plugin->submit_for_grading($submission);
                  }
              }
  
              $submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
              $this->update_submission($submission, $userid, true, $instance->teamsubmission);
              $completion = new completion_info($this->get_course());
              if ($completion->is_enabled($this->get_course_module()) && $instance->completionsubmit) {
                  $this->update_activity_completion_records($instance->teamsubmission,
                                                            $instance->requireallteammemberssubmit,
                                                            $submission,
                                                            $userid,
                                                            COMPLETION_COMPLETE,
                                                            $completion);
              }
  
              if (!empty($data->submissionstatement) && $USER->id == $userid) {
                  \mod_assign\event\statement_accepted::create_from_submission($this, $submission)->trigger();
              }
              $this->notify_graders($submission);
              $this->notify_student_submission_receipt($submission);
  
              \mod_assign\event\assessable_submitted::create_from_submission($this, $submission, false)->trigger();
  
              return true;
          }
          $notices[] = get_string('submissionsclosed', 'assign');
          return false;
      }
code_tokens: public function submit_for_grading ( $ data , $ notices ) { global $ USER ; $ userid = $ USER -> id ; if ( ! empty ( $ data -> userid ) ) { $ userid = $ data -> userid ; } // Need submit permission to submit an assignment. if ( $ userid == $ USER -> id ) { require_capability ( 'mod/assign:submit' , $ this -> context ) ; } else { if ( ! $ this -> can_edit_submission ( $ userid , $ USER -> id ) ) { print_error ( 'nopermission' ) ; } } $ instance = $ this -> get_instance ( ) ; if ( $ instance -> teamsubmission ) { $ submission = $ this -> get_group_submission ( $ userid , 0 , true ) ; } else { $ submission = $ this -> get_user_submission ( $ userid , true ) ; } if ( ! $ this -> submissions_open ( $ userid ) ) { $ notices [ ] = get_string ( 'submissionsclosed' , 'assign' ) ; return false ; } if ( $ instance -> requiresubmissionstatement && empty ( $ data -> submissionstatement ) && $ USER -> id == $ userid ) { return false ; } if ( $ submission -> status != ASSIGN_SUBMISSION_STATUS_SUBMITTED ) { // Give each submission plugin a chance to process the submission. $ plugins = $ this -> get_submission_plugins ( ) ; foreach ( $ plugins as $ plugin ) { if ( $ plugin -> is_enabled ( ) && $ plugin -> is_visible ( ) ) { $ plugin -> submit_for_grading ( $ submission ) ; } } $ submission -> status = ASSIGN_SUBMISSION_STATUS_SUBMITTED ; $ this -> update_submission ( $ submission , $ userid , true , $ instance -> teamsubmission ) ; $ completion = new completion_info ( $ this -> get_course ( ) ) ; if ( $ completion -> is_enabled ( $ this -> get_course_module ( ) ) && $ instance -> completionsubmit ) { $ this -> update_activity_completion_records ( $ instance -> teamsubmission , $ instance -> requireallteammemberssubmit , $ submission , $ userid , COMPLETION_COMPLETE , $ completion ) ; } if ( ! empty ( $ data -> submissionstatement ) && $ USER -> id == $ userid ) { \ mod_assign \ event \ statement_accepted :: create_from_submission ( $ this , $ submission ) -> trigger ( ) ; } $ this -> notify_graders ( $ submission ) ; $ this -> notify_student_submission_receipt ( $ submission ) ; \ mod_assign \ event \ assessable_submitted :: create_from_submission ( $ this , $ submission , false ) -> trigger ( ) ; return true ; } $ notices [ ] = get_string ( 'submissionsclosed' , 'assign' ) ; return false ; }
docstring: Submit a submission for grading.
  
  @param stdClass $data - The form data
  @param array $notices - List of error messages to display on an error condition.
  @return bool Return false if the submission was not submitted.
docstring_tokens: Submit a submission for grading .