| Línea 30... |
Línea 30... |
| 30 |
*
|
30 |
*
|
| 31 |
* @param array $args
|
31 |
* @param array $args
|
| 32 |
* @return string rendered output
|
32 |
* @return string rendered output
|
| 33 |
*/
|
33 |
*/
|
| 34 |
function qbank_usage_output_fragment_question_usage(array $args): string {
|
34 |
function qbank_usage_output_fragment_question_usage(array $args): string {
|
| 35 |
global $USER, $PAGE, $CFG, $DB;
|
35 |
global $PAGE, $CFG;
|
| 36 |
require_once($CFG->dirroot . '/question/engine/bank.php');
|
36 |
require_once($CFG->dirroot . '/question/engine/bank.php');
|
| 37 |
$displaydata = [];
|
37 |
$displaydata = [];
|
| Línea 38... |
Línea 38... |
| 38 |
|
38 |
|
| 39 |
$question = question_bank::load_question($args['questionid']);
|
- |
|
| 40 |
$quba = question_engine::make_questions_usage_by_activity('core_question_preview', context_user::instance($USER->id));
|
- |
|
| 41 |
|
- |
|
| 42 |
$options = new \qbank_previewquestion\question_preview_options($question);
|
- |
|
| 43 |
$quba->set_preferred_behaviour($options->behaviour);
|
- |
|
| 44 |
$slot = $quba->add_question($question, $options->maxmark);
|
- |
|
| 45 |
$quba->start_question($slot, $options->variant);
|
- |
|
| 46 |
$transaction = $DB->start_delegated_transaction();
|
- |
|
| 47 |
question_engine::save_questions_usage_by_activity($quba);
|
- |
|
| 48 |
$transaction->allow_commit();
|
39 |
$question = question_bank::load_question($args['questionid']);
|
| Línea 49... |
Línea 40... |
| 49 |
$displaydata['question'] = $quba->render_question($slot, $options, '1');
|
40 |
$displaydata['question'] = question_bank::render_preview_of_question($question);
|
| 50 |
|
41 |
|
| 51 |
$specificversion = clean_param($args['specificversion'] ?? false, PARAM_BOOL);
|
42 |
$specificversion = clean_param($args['specificversion'] ?? false, PARAM_BOOL);
|
| 52 |
$questionusagetable = new \qbank_usage\tables\question_usage_table('question_usage_table', $question, $specificversion);
|
43 |
$questionusagetable = new \qbank_usage\tables\question_usage_table('question_usage_table', $question, $specificversion);
|