original_string: public function process_submitted_actions($timestamp, $becomingoverdue = false, $simulatedresponses = null) {
          global $DB;
  
          $transaction = $DB->start_delegated_transaction();
  
          if ($simulatedresponses !== null) {
              if (is_int(key($simulatedresponses))) {
                  // Legacy approach. Should be removed one day.
                  $simulatedpostdata = $this->quba->prepare_simulated_post_data($simulatedresponses);
              } else {
                  $simulatedpostdata = $simulatedresponses;
              }
          } else {
              $simulatedpostdata = null;
          }
  
          $this->quba->process_all_actions($timestamp, $simulatedpostdata);
          question_engine::save_questions_usage_by_activity($this->quba);
  
          $this->attempt->timemodified = $timestamp;
          if ($this->attempt->state == self::FINISHED) {
              $this->attempt->sumgrades = $this->quba->get_total_mark();
          }
          if ($becomingoverdue) {
              $this->process_going_overdue($timestamp, true);
          } else {
              $DB->update_record('quiz_attempts', $this->attempt);
          }
  
          if (!$this->is_preview() && $this->attempt->state == self::FINISHED) {
              quiz_save_best_grade($this->get_quiz(), $this->get_userid());
          }
  
          $transaction->allow_commit();
      }
code: public function process_submitted_actions($timestamp, $becomingoverdue = false, $simulatedresponses = null) {
          global $DB;
  
          $transaction = $DB->start_delegated_transaction();
  
          if ($simulatedresponses !== null) {
              if (is_int(key($simulatedresponses))) {
                  // Legacy approach. Should be removed one day.
                  $simulatedpostdata = $this->quba->prepare_simulated_post_data($simulatedresponses);
              } else {
                  $simulatedpostdata = $simulatedresponses;
              }
          } else {
              $simulatedpostdata = null;
          }
  
          $this->quba->process_all_actions($timestamp, $simulatedpostdata);
          question_engine::save_questions_usage_by_activity($this->quba);
  
          $this->attempt->timemodified = $timestamp;
          if ($this->attempt->state == self::FINISHED) {
              $this->attempt->sumgrades = $this->quba->get_total_mark();
          }
          if ($becomingoverdue) {
              $this->process_going_overdue($timestamp, true);
          } else {
              $DB->update_record('quiz_attempts', $this->attempt);
          }
  
          if (!$this->is_preview() && $this->attempt->state == self::FINISHED) {
              quiz_save_best_grade($this->get_quiz(), $this->get_userid());
          }
  
          $transaction->allow_commit();
      }
code_tokens: public function process_submitted_actions ( $ timestamp , $ becomingoverdue = false , $ simulatedresponses = null ) { global $ DB ; $ transaction = $ DB -> start_delegated_transaction ( ) ; if ( $ simulatedresponses !== null ) { if ( is_int ( key ( $ simulatedresponses ) ) ) { // Legacy approach. Should be removed one day. $ simulatedpostdata = $ this -> quba -> prepare_simulated_post_data ( $ simulatedresponses ) ; } else { $ simulatedpostdata = $ simulatedresponses ; } } else { $ simulatedpostdata = null ; } $ this -> quba -> process_all_actions ( $ timestamp , $ simulatedpostdata ) ; question_engine :: save_questions_usage_by_activity ( $ this -> quba ) ; $ this -> attempt -> timemodified = $ timestamp ; if ( $ this -> attempt -> state == self :: FINISHED ) { $ this -> attempt -> sumgrades = $ this -> quba -> get_total_mark ( ) ; } if ( $ becomingoverdue ) { $ this -> process_going_overdue ( $ timestamp , true ) ; } else { $ DB -> update_record ( 'quiz_attempts' , $ this -> attempt ) ; } if ( ! $ this -> is_preview ( ) && $ this -> attempt -> state == self :: FINISHED ) { quiz_save_best_grade ( $ this -> get_quiz ( ) , $ this -> get_userid ( ) ) ; } $ transaction -> allow_commit ( ) ; }
docstring: Process all the actions that were submitted as part of the current request.
  
  @param int  $timestamp  the timestamp that should be stored as the modifed
  time in the database for these actions. If null, will use the current time.
  @param bool $becomingoverdue
  @param array|null $simulatedresponses If not null, then we are testing, and this is an array of simulated data.
  There are two formats supported here, for historical reasons. The newer approach is to pass an array created by
  {@link core_question_generator::get_simulated_post_data_for_questions_in_usage()}.
  the second is to pass an array slot no => contains arrays representing student
  responses which will be passed to {@link question_definition::prepare_simulated_post_data()}.
  This second method will probably get deprecated one day.
docstring_tokens: Process all the actions that were submitted as part of the current request .