original_string: public static function export_question_attempt_steps(
              int $userid,
              \context $context,
              array $questionnocontext,
              \question_attempt $qa,
              \question_display_options $options,
              $isowner
          ) {
          $attemptdata = (object) [
                  'steps' => [],
              ];
          $stepno = 0;
          foreach ($qa->get_step_iterator() as $i => $step) {
              $stepno++;
  
              if ($isowner || ($step->get_user_id() != $userid)) {
                  // The user is the owner, or the author of the step.
  
                  $restrictedqa = new \question_attempt_with_restricted_history($qa, $i, null);
                  $stepdata = (object) [
                      // Note: Do not include the user here.
                      'time' => transform::datetime($step->get_timecreated()),
                      'action' => $qa->summarise_action($step),
                  ];
  
                  if ($options->marks >= \question_display_options::MARK_AND_MAX) {
                      $stepdata->mark = $qa->format_fraction_as_mark($step->get_fraction(), $options->markdp);
                  }
  
                  if ($options->correctness != \question_display_options::HIDDEN) {
                      $stepdata->state = $restrictedqa->get_state_string($options->correctness);
                  }
  
                  if ($step->has_behaviour_var('comment')) {
                      $behaviour = $qa->get_behaviour();
                      $comment = $step->get_behaviour_var('comment');
                      $commentformat = $step->get_behaviour_var('commentformat');
  
                      if (empty(trim($comment))) {
                          // Skip empty comments.
                          continue;
                      }
  
                      // Format the comment.
                      $comment = writer::with_context($context)
                          ->rewrite_pluginfile_urls(
                              $questionnocontext,
                              'question',
                              'response_bf_comment',
                              $step->get_id(),
                              $comment
                          );
  
                      // Export any files associated with the comment files area.
                      writer::with_context($context)
                          ->export_area_files(
                              $questionnocontext,
                              'question',
                              "response_bf_comment",
                              $step->get_id()
                          );
  
                      $stepdata->comment = $behaviour->format_comment($comment, $commentformat);
                  }
  
                  // Export any response files associated with this step.
                  foreach (\question_engine::get_all_response_file_areas() as $filearea) {
                      writer::with_context($context)
                          ->export_area_files(
                                  $questionnocontext,
                                  'question',
                                  $filearea,
                                  $step->get_id()
                              );
                  }
  
                  $attemptdata->steps[$stepno] = $stepdata;
              }
          }
  
          if (!empty($attemptdata->steps)) {
              writer::with_context($context)
                  ->export_related_data($questionnocontext, 'steps', $attemptdata);
          }
      }
code: public static function export_question_attempt_steps(
              int $userid,
              \context $context,
              array $questionnocontext,
              \question_attempt $qa,
              \question_display_options $options,
              $isowner
          ) {
          $attemptdata = (object) [
                  'steps' => [],
              ];
          $stepno = 0;
          foreach ($qa->get_step_iterator() as $i => $step) {
              $stepno++;
  
              if ($isowner || ($step->get_user_id() != $userid)) {
                  // The user is the owner, or the author of the step.
  
                  $restrictedqa = new \question_attempt_with_restricted_history($qa, $i, null);
                  $stepdata = (object) [
                      // Note: Do not include the user here.
                      'time' => transform::datetime($step->get_timecreated()),
                      'action' => $qa->summarise_action($step),
                  ];
  
                  if ($options->marks >= \question_display_options::MARK_AND_MAX) {
                      $stepdata->mark = $qa->format_fraction_as_mark($step->get_fraction(), $options->markdp);
                  }
  
                  if ($options->correctness != \question_display_options::HIDDEN) {
                      $stepdata->state = $restrictedqa->get_state_string($options->correctness);
                  }
  
                  if ($step->has_behaviour_var('comment')) {
                      $behaviour = $qa->get_behaviour();
                      $comment = $step->get_behaviour_var('comment');
                      $commentformat = $step->get_behaviour_var('commentformat');
  
                      if (empty(trim($comment))) {
                          // Skip empty comments.
                          continue;
                      }
  
                      // Format the comment.
                      $comment = writer::with_context($context)
                          ->rewrite_pluginfile_urls(
                              $questionnocontext,
                              'question',
                              'response_bf_comment',
                              $step->get_id(),
                              $comment
                          );
  
                      // Export any files associated with the comment files area.
                      writer::with_context($context)
                          ->export_area_files(
                              $questionnocontext,
                              'question',
                              "response_bf_comment",
                              $step->get_id()
                          );
  
                      $stepdata->comment = $behaviour->format_comment($comment, $commentformat);
                  }
  
                  // Export any response files associated with this step.
                  foreach (\question_engine::get_all_response_file_areas() as $filearea) {
                      writer::with_context($context)
                          ->export_area_files(
                                  $questionnocontext,
                                  'question',
                                  $filearea,
                                  $step->get_id()
                              );
                  }
  
                  $attemptdata->steps[$stepno] = $stepdata;
              }
          }
  
          if (!empty($attemptdata->steps)) {
              writer::with_context($context)
                  ->export_related_data($questionnocontext, 'steps', $attemptdata);
          }
      }
code_tokens: public static function export_question_attempt_steps ( int $ userid , \ context $ context , array $ questionnocontext , \ question_attempt $ qa , \ question_display_options $ options , $ isowner ) { $ attemptdata = ( object ) [ 'steps' => [ ] , ] ; $ stepno = 0 ; foreach ( $ qa -> get_step_iterator ( ) as $ i => $ step ) { $ stepno ++ ; if ( $ isowner || ( $ step -> get_user_id ( ) != $ userid ) ) { // The user is the owner, or the author of the step. $ restrictedqa = new \ question_attempt_with_restricted_history ( $ qa , $ i , null ) ; $ stepdata = ( object ) [ // Note: Do not include the user here. 'time' => transform :: datetime ( $ step -> get_timecreated ( ) ) , 'action' => $ qa -> summarise_action ( $ step ) , ] ; if ( $ options -> marks >= \ question_display_options :: MARK_AND_MAX ) { $ stepdata -> mark = $ qa -> format_fraction_as_mark ( $ step -> get_fraction ( ) , $ options -> markdp ) ; } if ( $ options -> correctness != \ question_display_options :: HIDDEN ) { $ stepdata -> state = $ restrictedqa -> get_state_string ( $ options -> correctness ) ; } if ( $ step -> has_behaviour_var ( 'comment' ) ) { $ behaviour = $ qa -> get_behaviour ( ) ; $ comment = $ step -> get_behaviour_var ( 'comment' ) ; $ commentformat = $ step -> get_behaviour_var ( 'commentformat' ) ; if ( empty ( trim ( $ comment ) ) ) { // Skip empty comments. continue ; } // Format the comment. $ comment = writer :: with_context ( $ context ) -> rewrite_pluginfile_urls ( $ questionnocontext , 'question' , 'response_bf_comment' , $ step -> get_id ( ) , $ comment ) ; // Export any files associated with the comment files area. writer :: with_context ( $ context ) -> export_area_files ( $ questionnocontext , 'question' , "response_bf_comment" , $ step -> get_id ( ) ) ; $ stepdata -> comment = $ behaviour -> format_comment ( $ comment , $ commentformat ) ; } // Export any response files associated with this step. foreach ( \ question_engine :: get_all_response_file_areas ( ) as $ filearea ) { writer :: with_context ( $ context ) -> export_area_files ( $ questionnocontext , 'question' , $ filearea , $ step -> get_id ( ) ) ; } $ attemptdata -> steps [ $ stepno ] = $ stepdata ; } } if ( ! empty ( $ attemptdata -> steps ) ) { writer :: with_context ( $ context ) -> export_related_data ( $ questionnocontext , 'steps' , $ attemptdata ) ; } }
docstring: Export the data for each step transition for each question in each question attempt.
  
  Where a user is the owner of the usage, then all steps in the question usage will be exported.
  Where a user is not the owner, but has been involved in the usage, then only their specific
  involvement will be exported.
  
  @param   int                 $userid     The user to export for
  @param   \context            $context    The context that the question was used within.
  @param   array               $questionnocontext  The subcontext of this question number.
  @param   \question_attempt   $qa         The attempt being checked
  @param   \question_display_options   $options    The display options used for formatting.
  @param   bool                $isowner    Whether the user being exported is the user who used the question.
docstring_tokens: Export the data for each step transition for each question in each question attempt .