original_string: protected static function export_user_data_lti_submissions(approved_contextlist $contextlist) {
          global $DB;
  
          // Filter out any contexts that are not related to modules.
          $cmids = array_reduce($contextlist->get_contexts(), function($carry, $context) {
              if ($context->contextlevel == CONTEXT_MODULE) {
                  $carry[] = $context->instanceid;
              }
              return $carry;
          }, []);
  
          if (empty($cmids)) {
              return;
          }
  
          $user = $contextlist->get_user();
  
          // Get all the LTI activities associated with the above course modules.
          $ltiidstocmids = self::get_lti_ids_to_cmids_from_cmids($cmids);
          $ltiids = array_keys($ltiidstocmids);
  
          list($insql, $inparams) = $DB->get_in_or_equal($ltiids, SQL_PARAMS_NAMED);
          $params = array_merge($inparams, ['userid' => $user->id]);
          $recordset = $DB->get_recordset_select('lti_submission', "ltiid $insql AND userid = :userid", $params, 'dateupdated, id');
          self::recordset_loop_and_export($recordset, 'ltiid', [], function($carry, $record) use ($user, $ltiidstocmids) {
              $carry[] = [
                  'gradepercent' => $record->gradepercent,
                  'originalgrade' => $record->originalgrade,
                  'datesubmitted' => transform::datetime($record->datesubmitted),
                  'dateupdated' => transform::datetime($record->dateupdated)
              ];
              return $carry;
          }, function($ltiid, $data) use ($user, $ltiidstocmids) {
              $context = \context_module::instance($ltiidstocmids[$ltiid]);
              $contextdata = helper::get_context_data($context, $user);
              $finaldata = (object) array_merge((array) $contextdata, ['submissions' => $data]);
              helper::export_context_files($context, $user);
              writer::with_context($context)->export_data([], $finaldata);
          });
      }
code: protected static function export_user_data_lti_submissions(approved_contextlist $contextlist) {
          global $DB;
  
          // Filter out any contexts that are not related to modules.
          $cmids = array_reduce($contextlist->get_contexts(), function($carry, $context) {
              if ($context->contextlevel == CONTEXT_MODULE) {
                  $carry[] = $context->instanceid;
              }
              return $carry;
          }, []);
  
          if (empty($cmids)) {
              return;
          }
  
          $user = $contextlist->get_user();
  
          // Get all the LTI activities associated with the above course modules.
          $ltiidstocmids = self::get_lti_ids_to_cmids_from_cmids($cmids);
          $ltiids = array_keys($ltiidstocmids);
  
          list($insql, $inparams) = $DB->get_in_or_equal($ltiids, SQL_PARAMS_NAMED);
          $params = array_merge($inparams, ['userid' => $user->id]);
          $recordset = $DB->get_recordset_select('lti_submission', "ltiid $insql AND userid = :userid", $params, 'dateupdated, id');
          self::recordset_loop_and_export($recordset, 'ltiid', [], function($carry, $record) use ($user, $ltiidstocmids) {
              $carry[] = [
                  'gradepercent' => $record->gradepercent,
                  'originalgrade' => $record->originalgrade,
                  'datesubmitted' => transform::datetime($record->datesubmitted),
                  'dateupdated' => transform::datetime($record->dateupdated)
              ];
              return $carry;
          }, function($ltiid, $data) use ($user, $ltiidstocmids) {
              $context = \context_module::instance($ltiidstocmids[$ltiid]);
              $contextdata = helper::get_context_data($context, $user);
              $finaldata = (object) array_merge((array) $contextdata, ['submissions' => $data]);
              helper::export_context_files($context, $user);
              writer::with_context($context)->export_data([], $finaldata);
          });
      }
code_tokens: protected static function export_user_data_lti_submissions ( approved_contextlist $ contextlist ) { global $ DB ; // Filter out any contexts that are not related to modules. $ cmids = array_reduce ( $ contextlist -> get_contexts ( ) , function ( $ carry , $ context ) { if ( $ context -> contextlevel == CONTEXT_MODULE ) { $ carry [ ] = $ context -> instanceid ; } return $ carry ; } , [ ] ) ; if ( empty ( $ cmids ) ) { return ; } $ user = $ contextlist -> get_user ( ) ; // Get all the LTI activities associated with the above course modules. $ ltiidstocmids = self :: get_lti_ids_to_cmids_from_cmids ( $ cmids ) ; $ ltiids = array_keys ( $ ltiidstocmids ) ; list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( $ ltiids , SQL_PARAMS_NAMED ) ; $ params = array_merge ( $ inparams , [ 'userid' => $ user -> id ] ) ; $ recordset = $ DB -> get_recordset_select ( 'lti_submission' , "ltiid $insql AND userid = :userid" , $ params , 'dateupdated, id' ) ; self :: recordset_loop_and_export ( $ recordset , 'ltiid' , [ ] , function ( $ carry , $ record ) use ( $ user , $ ltiidstocmids ) { $ carry [ ] = [ 'gradepercent' => $ record -> gradepercent , 'originalgrade' => $ record -> originalgrade , 'datesubmitted' => transform :: datetime ( $ record -> datesubmitted ) , 'dateupdated' => transform :: datetime ( $ record -> dateupdated ) ] ; return $ carry ; } , function ( $ ltiid , $ data ) use ( $ user , $ ltiidstocmids ) { $ context = \ context_module :: instance ( $ ltiidstocmids [ $ ltiid ] ) ; $ contextdata = helper :: get_context_data ( $ context , $ user ) ; $ finaldata = ( object ) array_merge ( ( array ) $ contextdata , [ 'submissions' => $ data ] ) ; helper :: export_context_files ( $ context , $ user ) ; writer :: with_context ( $ context ) -> export_data ( [ ] , $ finaldata ) ; } ) ; }
docstring: Export personal data for the given approved_contextlist related to LTI submissions.
  
  @param approved_contextlist $contextlist a list of contexts approved for export.
docstring_tokens: Export personal data for the given approved_contextlist related to LTI submissions .