Línea 107... |
Línea 107... |
107 |
*
|
107 |
*
|
108 |
* @param array $args
|
108 |
* @param array $args
|
109 |
* @return string rendered output
|
109 |
* @return string rendered output
|
110 |
*/
|
110 |
*/
|
111 |
function qbank_comment_output_fragment_question_comment($args): string {
|
111 |
function qbank_comment_output_fragment_question_comment($args): string {
|
112 |
global $USER, $PAGE, $CFG, $DB;
|
112 |
global $PAGE, $CFG;
|
113 |
$displaydata = [];
|
113 |
$displaydata = [];
|
114 |
require_once($CFG->dirroot . '/question/engine/bank.php');
|
114 |
require_once($CFG->dirroot . '/question/engine/bank.php');
|
115 |
$question = question_bank::load_question($args['questionid']);
|
115 |
$question = question_bank::load_question($args['questionid']);
|
116 |
$quba = question_engine::make_questions_usage_by_activity(
|
116 |
$displaydata['question'] = question_bank::render_preview_of_question($question);
|
117 |
'core_question_preview', context_user::instance($USER->id));
|
- |
|
Línea 118... |
Línea -... |
118 |
|
- |
|
119 |
// Just in case of any regression, it should not break the modal, just show the comments.
|
- |
|
120 |
if (class_exists('\\qbank_previewquestion\\question_preview_options')) {
|
- |
|
121 |
$options = new \qbank_previewquestion\question_preview_options($question);
|
- |
|
122 |
$quba->set_preferred_behaviour($options->behaviour);
|
- |
|
123 |
$slot = $quba->add_question($question, $options->maxmark);
|
- |
|
124 |
$quba->start_question($slot, $options->variant);
|
- |
|
125 |
$transaction = $DB->start_delegated_transaction();
|
- |
|
126 |
question_engine::save_questions_usage_by_activity($quba);
|
- |
|
127 |
$transaction->allow_commit();
|
- |
|
128 |
$displaydata['question'] = $quba->render_question($slot, $options, '1');
|
- |
|
129 |
}
|
117 |
|
130 |
$displaydata['comment'] = qbank_comment_preview_display($question, $args['courseid']);
|
118 |
$displaydata['comment'] = qbank_comment_preview_display($question, $args['courseid']);
|
131 |
$displaydata['commenstdisabled'] = false;
|
119 |
$displaydata['commenstdisabled'] = false;
|
132 |
if (empty($displaydata['comment']) && !$CFG->usecomments) {
|
120 |
if (empty($displaydata['comment']) && !$CFG->usecomments) {
|
133 |
$displaydata['commenstdisabled'] = true;
|
121 |
$displaydata['commenstdisabled'] = true;
|