original_string: public static function get_random_question_summaries(
          $categoryid,
          $includesubcategories,
          $tagids,
          $contextid,
          $limit = 0,
          $offset = 0
      ) {
          global $DB, $PAGE;
  
          // Parameter validation.
          $params = self::validate_parameters(
              self::get_random_question_summaries_parameters(),
              [
                  'categoryid' => $categoryid,
                  'includesubcategories' => $includesubcategories,
                  'tagids' => $tagids,
                  'contextid' => $contextid,
                  'limit' => $limit,
                  'offset' => $offset
              ]
          );
          $categoryid = $params['categoryid'];
          $includesubcategories = $params['includesubcategories'];
          $tagids = $params['tagids'];
          $contextid = $params['contextid'];
          $limit = $params['limit'];
          $offset = $params['offset'];
  
          $context = \context::instance_by_id($contextid);
          self::validate_context($context);
  
          $categorycontextid = $DB->get_field('question_categories', 'contextid', ['id' => $categoryid], MUST_EXIST);
          $categorycontext = \context::instance_by_id($categorycontextid);
          $editcontexts = new \question_edit_contexts($categorycontext);
          // The user must be able to view all questions in the category that they are requesting.
          $editcontexts->require_cap('moodle/question:viewall');
  
          $loader = new \core_question\bank\random_question_loader(new qubaid_list([]));
          // Only load the properties we require from the DB.
          $properties = \core_question\external\question_summary_exporter::get_mandatory_properties();
          $questions = $loader->get_questions($categoryid, $includesubcategories, $tagids, $limit, $offset, $properties);
          $totalcount = $loader->count_questions($categoryid, $includesubcategories, $tagids);
          $renderer = $PAGE->get_renderer('core');
  
          $formattedquestions = array_map(function($question) use ($context, $renderer) {
              $exporter = new \core_question\external\question_summary_exporter($question, ['context' => $context]);
              return $exporter->export($renderer);
          }, $questions);
  
          return [
              'totalcount' => $totalcount,
              'questions' => $formattedquestions
          ];
      }
code: public static function get_random_question_summaries(
          $categoryid,
          $includesubcategories,
          $tagids,
          $contextid,
          $limit = 0,
          $offset = 0
      ) {
          global $DB, $PAGE;
  
          // Parameter validation.
          $params = self::validate_parameters(
              self::get_random_question_summaries_parameters(),
              [
                  'categoryid' => $categoryid,
                  'includesubcategories' => $includesubcategories,
                  'tagids' => $tagids,
                  'contextid' => $contextid,
                  'limit' => $limit,
                  'offset' => $offset
              ]
          );
          $categoryid = $params['categoryid'];
          $includesubcategories = $params['includesubcategories'];
          $tagids = $params['tagids'];
          $contextid = $params['contextid'];
          $limit = $params['limit'];
          $offset = $params['offset'];
  
          $context = \context::instance_by_id($contextid);
          self::validate_context($context);
  
          $categorycontextid = $DB->get_field('question_categories', 'contextid', ['id' => $categoryid], MUST_EXIST);
          $categorycontext = \context::instance_by_id($categorycontextid);
          $editcontexts = new \question_edit_contexts($categorycontext);
          // The user must be able to view all questions in the category that they are requesting.
          $editcontexts->require_cap('moodle/question:viewall');
  
          $loader = new \core_question\bank\random_question_loader(new qubaid_list([]));
          // Only load the properties we require from the DB.
          $properties = \core_question\external\question_summary_exporter::get_mandatory_properties();
          $questions = $loader->get_questions($categoryid, $includesubcategories, $tagids, $limit, $offset, $properties);
          $totalcount = $loader->count_questions($categoryid, $includesubcategories, $tagids);
          $renderer = $PAGE->get_renderer('core');
  
          $formattedquestions = array_map(function($question) use ($context, $renderer) {
              $exporter = new \core_question\external\question_summary_exporter($question, ['context' => $context]);
              return $exporter->export($renderer);
          }, $questions);
  
          return [
              'totalcount' => $totalcount,
              'questions' => $formattedquestions
          ];
      }
code_tokens: public static function get_random_question_summaries ( $ categoryid , $ includesubcategories , $ tagids , $ contextid , $ limit = 0 , $ offset = 0 ) { global $ DB , $ PAGE ; // Parameter validation. $ params = self :: validate_parameters ( self :: get_random_question_summaries_parameters ( ) , [ 'categoryid' => $ categoryid , 'includesubcategories' => $ includesubcategories , 'tagids' => $ tagids , 'contextid' => $ contextid , 'limit' => $ limit , 'offset' => $ offset ] ) ; $ categoryid = $ params [ 'categoryid' ] ; $ includesubcategories = $ params [ 'includesubcategories' ] ; $ tagids = $ params [ 'tagids' ] ; $ contextid = $ params [ 'contextid' ] ; $ limit = $ params [ 'limit' ] ; $ offset = $ params [ 'offset' ] ; $ context = \ context :: instance_by_id ( $ contextid ) ; self :: validate_context ( $ context ) ; $ categorycontextid = $ DB -> get_field ( 'question_categories' , 'contextid' , [ 'id' => $ categoryid ] , MUST_EXIST ) ; $ categorycontext = \ context :: instance_by_id ( $ categorycontextid ) ; $ editcontexts = new \ question_edit_contexts ( $ categorycontext ) ; // The user must be able to view all questions in the category that they are requesting. $ editcontexts -> require_cap ( 'moodle/question:viewall' ) ; $ loader = new \ core_question \ bank \ random_question_loader ( new qubaid_list ( [ ] ) ) ; // Only load the properties we require from the DB. $ properties = \ core_question \ external \ question_summary_exporter :: get_mandatory_properties ( ) ; $ questions = $ loader -> get_questions ( $ categoryid , $ includesubcategories , $ tagids , $ limit , $ offset , $ properties ) ; $ totalcount = $ loader -> count_questions ( $ categoryid , $ includesubcategories , $ tagids ) ; $ renderer = $ PAGE -> get_renderer ( 'core' ) ; $ formattedquestions = array_map ( function ( $ question ) use ( $ context , $ renderer ) { $ exporter = new \ core_question \ external \ question_summary_exporter ( $ question , [ 'context' => $ context ] ) ; return $ exporter -> export ( $ renderer ) ; } , $ questions ) ; return [ 'totalcount' => $ totalcount , 'questions' => $ formattedquestions ] ; }
docstring: Gets the list of random questions for the given criteria. The questions
  will be exported in a summaries format and won't include all of the
  question data.
  
  @param int $categoryid Category id to find random questions
  @param bool $includesubcategories Include the subcategories in the search
  @param int[] $tagids Only include questions with these tags
  @param int $contextid The context id where the questions will be rendered
  @param int $limit Maximum number of results to return
  @param int $offset Number of items to skip from the beginning of the result set.
  @return array The list of questions and total question count.
docstring_tokens: Gets the list of random questions for the given criteria . The questions will be exported in a summaries format and won t include all of the question data .