original_string: public static function save_attempt($attemptid, $data, $preflightdata = array()) {
          global $DB;
  
          $warnings = array();
  
          $params = array(
              'attemptid' => $attemptid,
              'data' => $data,
              'preflightdata' => $preflightdata,
          );
          $params = self::validate_parameters(self::save_attempt_parameters(), $params);
  
          // Add a page, required by validate_attempt.
          list($attemptobj, $messages) = self::validate_attempt($params);
  
          $transaction = $DB->start_delegated_transaction();
          // Create the $_POST object required by the question engine.
          $_POST = array();
          foreach ($data as $element) {
              $_POST[$element['name']] = $element['value'];
          }
          $timenow = time();
          // Update the timemodifiedoffline field.
          $attemptobj->set_offline_modified_time($timenow);
          $attemptobj->process_auto_save($timenow);
          $transaction->allow_commit();
  
          $result = array();
          $result['status'] = true;
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function save_attempt($attemptid, $data, $preflightdata = array()) {
          global $DB;
  
          $warnings = array();
  
          $params = array(
              'attemptid' => $attemptid,
              'data' => $data,
              'preflightdata' => $preflightdata,
          );
          $params = self::validate_parameters(self::save_attempt_parameters(), $params);
  
          // Add a page, required by validate_attempt.
          list($attemptobj, $messages) = self::validate_attempt($params);
  
          $transaction = $DB->start_delegated_transaction();
          // Create the $_POST object required by the question engine.
          $_POST = array();
          foreach ($data as $element) {
              $_POST[$element['name']] = $element['value'];
          }
          $timenow = time();
          // Update the timemodifiedoffline field.
          $attemptobj->set_offline_modified_time($timenow);
          $attemptobj->process_auto_save($timenow);
          $transaction->allow_commit();
  
          $result = array();
          $result['status'] = true;
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function save_attempt ( $ attemptid , $ data , $ preflightdata = array ( ) ) { global $ DB ; $ warnings = array ( ) ; $ params = array ( 'attemptid' => $ attemptid , 'data' => $ data , 'preflightdata' => $ preflightdata , ) ; $ params = self :: validate_parameters ( self :: save_attempt_parameters ( ) , $ params ) ; // Add a page, required by validate_attempt. list ( $ attemptobj , $ messages ) = self :: validate_attempt ( $ params ) ; $ transaction = $ DB -> start_delegated_transaction ( ) ; // Create the $_POST object required by the question engine. $ _POST = array ( ) ; foreach ( $ data as $ element ) { $ _POST [ $ element [ 'name' ] ] = $ element [ 'value' ] ; } $ timenow = time ( ) ; // Update the timemodifiedoffline field. $ attemptobj -> set_offline_modified_time ( $ timenow ) ; $ attemptobj -> process_auto_save ( $ timenow ) ; $ transaction -> allow_commit ( ) ; $ result = array ( ) ; $ result [ 'status' ] = true ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Processes save requests during the quiz. This function is intended for the quiz auto-save feature.
  
  @param int $attemptid attempt id
  @param array $data the data to be saved
  @param  array $preflightdata preflight required data (like passwords)
  @return array of warnings and execution result
  @since Moodle 3.1
docstring_tokens: Processes save requests during the quiz . This function is intended for the quiz auto - save feature .