Proyectos de Subversion Moodle

Rev

Rev 725 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 725 Rev 1441
Línea 17... Línea 17...
17
defined('MOODLE_INTERNAL') || die();
17
defined('MOODLE_INTERNAL') || die();
Línea 18... Línea 18...
18
 
18
 
19
 
19
 
20
// Quiz.
20
// Quiz.
21
require_once($CFG->dirroot . "/mod/quiz/renderer.php");
-
 
22
class theme_universe_mod_quiz_renderer extends mod_quiz\output\renderer
21
require_once($CFG->dirroot . "/mod/quiz/renderer.php");
23
{
22
class theme_universe_mod_quiz_renderer extends mod_quiz\output\renderer {
24
    /**
23
    /**
25
     * Outputs a box.
24
     * Outputs a box.
26
     *
25
     *
27
     * @param string $contents The contents of the box
26
     * @param string $contents The contents of the box
28
     * @param string $classes A space-separated list of CSS classes
27
     * @param string $classes A space-separated list of CSS classes
29
     * @param string $id An optional ID
28
     * @param string $id An optional ID
30
     * @param array $attributes An array of other attributes to give the box.
29
     * @param array $attributes An array of other attributes to give the box.
31
     * @return string the HTML to output.
30
     * @return string the HTML to output.
32
     */
-
 
33
    public function space_box($contents, $classes = 'generalbox', $id = null, $attributes = array())
31
     */
34
    {
32
    public function space_box($contents, $classes = 'generalbox', $id = null, $attributes = array()) {
Línea 35... Línea 33...
35
        return $this->space_box_start($classes, $id, $attributes) . $contents . $this->space_box_end();
33
        return $this->space_box_start($classes, $id, $attributes) . $contents . $this->space_box_end();
36
    }
34
    }
Línea 41... Línea 39...
41
     * @param string $classes A space-separated list of CSS classes
39
     * @param string $classes A space-separated list of CSS classes
42
     * @param string $id An optional ID
40
     * @param string $id An optional ID
43
     * @param array $attributes An array of other attributes to give the box.
41
     * @param array $attributes An array of other attributes to give the box.
44
     * @return string the HTML to output.
42
     * @return string the HTML to output.
45
     */
43
     */
46
    public function space_box_start($classes = 'generalbox', $id = null, $attributes = array())
44
    public function space_box_start($classes = 'generalbox', $id = null, $attributes = array()) {
47
    {
-
 
48
        $this->opencontainers->push('box', html_writer::end_tag('div'));
45
        $this->opencontainers->push('box', html_writer::end_tag('div'));
49
        $attributes['id'] = $id;
46
        $attributes['id'] = $id;
50
        $attributes['class'] = 'box ' . renderer_base::prepare_classes($classes);
47
        $attributes['class'] = 'box ' . renderer_base::prepare_classes($classes);
51
        return html_writer::start_tag('div', $attributes);
48
        return html_writer::start_tag('div', $attributes);
52
    }
49
    }
Línea 54... Línea 51...
54
    /**
51
    /**
55
     * Outputs the closing section of a box.
52
     * Outputs the closing section of a box.
56
     *
53
     *
57
     * @return string the HTML to output.
54
     * @return string the HTML to output.
58
     */
55
     */
59
    public function space_box_end()
56
    public function space_box_end() {
60
    {
-
 
61
        return $this->opencontainers->pop('box');
57
        return $this->opencontainers->pop('box');
62
    }
58
    }
Línea 63... Línea 59...
63
 
59
 
64
    /**
60
    /**
Línea 69... Línea 65...
69
     * @param context $context the quiz context.
65
     * @param context $context the quiz context.
70
     * @param array $messages any access messages that should be described.
66
     * @param array $messages any access messages that should be described.
71
     * @param bool $quizhasquestions does quiz has questions added.
67
     * @param bool $quizhasquestions does quiz has questions added.
72
     * @return string HTML to output.
68
     * @return string HTML to output.
73
     */
69
     */
74
    public function view_information($quiz, $cm, $context, $messages, bool $quizhasquestions = false)
70
    public function view_information($quiz, $cm, $context, $messages, bool $quizhasquestions = false) {
75
    {
-
 
76
        $output = '';
71
        $output = '';
Línea 77... Línea 72...
77
 
72
 
78
        // Output any access messages.
73
        // Output any access messages.
79
        if ($messages) {
74
        if ($messages) {
Línea 111... Línea 106...
111
     *
106
     *
112
     * @param array $quiz Array contining quiz data
107
     * @param array $quiz Array contining quiz data
113
     * @param int $context The page context ID
108
     * @param int $context The page context ID
114
     * @param mod_quiz_view_object $viewobj
109
     * @param mod_quiz_view_object $viewobj
115
     */
110
     */
116
    public function view_table($quiz, $context, $viewobj)
111
    public function view_table($quiz, $context, $viewobj) {
117
    {
-
 
118
        if (!$viewobj->attempts) {
112
        if (!$viewobj->attempts) {
119
            return '';
113
            return '';
120
        }
114
        }
Línea 121... Línea 115...
121
 
115
 
Línea 136... Línea 130...
136
            $table->head[] = get_string('marks', 'quiz') . ' / ' .
130
            $table->head[] = get_string('marks', 'quiz') . ' / ' .
137
                quiz_format_grade($quiz, $quiz->sumgrades);
131
                quiz_format_grade($quiz, $quiz->sumgrades);
138
            $table->size[] = '';
132
            $table->size[] = '';
139
        }
133
        }
140
        if ($viewobj->gradecolumn) {
134
        if ($viewobj->gradecolumn) {
141
            $table->head[] = get_string('grade', 'quiz') . ' / ' .
135
            $table->head[] = get_string('gradenoun') . ' / ' .
142
                quiz_format_grade($quiz, $quiz->grade);
136
                    quiz_format_grade($quiz, $quiz->grade);
-
 
137
            $table->align[] = 'center';
143
            $table->size[] = '';
138
            $table->size[] = '';
144
        }
139
        }
145
        if ($viewobj->canreviewmine) {
140
        if ($viewobj->canreviewmine) {
146
            $table->head[] = get_string('review', 'quiz');
141
            $table->head[] = get_string('review', 'quiz');
147
            $table->size[] = '';
142
            $table->size[] = '';
Línea 228... Línea 223...
228
            }
223
            }
229
        } // End. of loop over attempts.
224
        } // End. of loop over attempts.
Línea 230... Línea 225...
230
 
225
 
231
        $output = '';
226
        $output = '';
232
        $output .= $this->view_table_heading();
227
        $output .= $this->view_table_heading();
233
        $output .= html_writer::start_tag('div', array('class' => 'table-overflow'));
228
        $output .= html_writer::start_tag('div', array('class' => 'table-overflow mb-4'));
234
        $output .= html_writer::table($table);
229
        $output .= html_writer::table($table);
235
        $output .= html_writer::end_tag('div');
230
        $output .= html_writer::end_tag('div');
236
        return $output;
231
        return $output;
Línea 247... Línea 242...
247
     * @param stdClass $cm the course_module settings row from the database.
242
     * @param stdClass $cm the course_module settings row from the database.
248
     * @param context_module $context the quiz context.
243
     * @param context_module $context the quiz context.
249
     * @param mod_quiz_view_object $viewobj
244
     * @param mod_quiz_view_object $viewobj
250
     * @return string HTML to display
245
     * @return string HTML to display
251
     */
246
     */
252
    public function view_page($course, $quiz, $cm, $context, $viewobj)
247
    public function view_page($course, $quiz, $cm, $context, $viewobj) {
253
    {
-
 
254
        $output = '';
248
        $output = '';
Línea 255... Línea 249...
255
 
249
 
256
        $output .= $this->view_page_tertiary_nav($viewobj);
250
        $output .= $this->view_page_tertiary_nav($viewobj);
257
        $output .= $this->view_information($quiz, $cm, $context, $viewobj->infomessages);
251
        $output .= $this->view_information($quiz, $cm, $context, $viewobj->infomessages);
Línea 265... Línea 259...
265
     * Outputs the table containing data from summary data array
259
     * Outputs the table containing data from summary data array
266
     *
260
     *
267
     * @param array $summarydata contains row data for table
261
     * @param array $summarydata contains row data for table
268
     * @param int $page contains the current page number
262
     * @param int $page contains the current page number
269
     */
263
     */
270
    public function review_summary_table($summarydata, $page)
264
    public function review_summary_table($summarydata, $page) {
271
    {
-
 
272
        $summarydata = $this->filter_review_summary_table($summarydata, $page);
265
        $summarydata = $this->filter_review_summary_table($summarydata, $page);
273
        if (empty($summarydata)) {
266
        if (empty($summarydata)) {
274
            return '';
267
            return '';
275
        }
268
        }
Línea 323... Línea 316...
323
     * Generates the table of summarydata
316
     * Generates the table of summarydata
324
     *
317
     *
325
     * @param quiz_attempt $attemptobj
318
     * @param quiz_attempt $attemptobj
326
     * @param mod_quiz_display_options $displayoptions
319
     * @param mod_quiz_display_options $displayoptions
327
     */
320
     */
328
    public function summary_table($attemptobj, $displayoptions)
321
    public function summary_table($attemptobj, $displayoptions) {
329
    {
-
 
330
        // Prepare the summary table header.
322
        // Prepare the summary table header.
331
        $table = new html_table();
323
        $table = new html_table();
332
        $table->attributes['class'] = 'generaltable quizsummaryofattempt';
324
        $table->attributes['class'] = 'generaltable quizsummaryofattempt';
333
        $table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
325
        $table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
334
        $table->align = array('left', 'left');
326
        $table->align = array('left', 'left');
Línea 374... Línea 366...
374
            $flag = '';
366
            $flag = '';
Línea 375... Línea 367...
375
 
367
 
376
            // Real question, show it.
368
            // Real question, show it.
377
            if ($attemptobj->is_question_flagged($slot)) {
369
            if ($attemptobj->is_question_flagged($slot)) {
378
                // Quiz has custom JS manipulating these image tags - so we can't use the pix_icon method here.
370
                // Quiz has custom JS manipulating these image tags - so we can't use the pix_icon method here.
379
                $flag = '<svg class="ml-2"
371
                $flag = '<svg class="ms-2"
380
                    width="20"
372
                    width="20"
381
                    height="20"
373
                    height="20"
382
                    viewBox="0 0 24 24"
374
                    viewBox="0 0 24 24"
383
                    fill="none"
375
                    fill="none"
Línea 428... Línea 420...
428
        return $output;
420
        return $output;
429
    }
421
    }
430
}
422
}
Línea 431... Línea 423...
431
 
423
 
432
require_once($CFG->dirroot . "/question/engine/renderer.php");
424
require_once($CFG->dirroot . "/question/engine/renderer.php");
433
class theme_universe_core_question_renderer extends core_question_renderer
-
 
434
{
425
class theme_universe_core_question_renderer extends core_question_renderer {
435
    /**
426
    /**
436
     * Generate the information bit of the question display that contains the
427
     * Generate the information bit of the question display that contains the
437
     * metadata like the question number, current state, and mark.
428
     * metadata like the question number, current state, and mark.
438
     * @param question_attempt $qa the question attempt to display.
429
     * @param question_attempt $qa the question attempt to display.
Línea 470... Línea 461...
470
     * Generate the display of the question number.
461
     * Generate the display of the question number.
471
     * @param string|null $number The question number to display. 'i' is a special
462
     * @param string|null $number The question number to display. 'i' is a special
472
     *      value that gets displayed as Information. Null means no number is displayed.
463
     *      value that gets displayed as Information. Null means no number is displayed.
473
     * @return HTML fragment.
464
     * @return HTML fragment.
474
     */
465
     */
475
    protected function number($number)
466
    protected function number($number) {
476
    {
-
 
477
        if (trim($number) === '') {
467
        if (trim($number) === '') {
478
            return '';
468
            return '';
479
        }
469
        }
480
        $numbertext = '';
470
        $numbertext = '';
481
        if (trim($number) === 'i') {
471
        if (trim($number) === 'i') {
Línea 506... Línea 496...
506
        question_display_options $options
496
        question_display_options $options
507
    ) {
497
    ) {
508
        return html_writer::tag(
498
        return html_writer::tag(
509
            'div',
499
            'div',
510
            $qa->get_state_string($options->correctness),
500
            $qa->get_state_string($options->correctness),
511
            array('class' => 'state mr-2')
501
            array('class' => 'state me-2 my-2')
512
        );
502
        );
513
    }
503
    }
Línea 514... Línea 504...
514
 
504
 
515
    /**
505
    /**
516
     * Render the question flag, assuming $flagsoption allows it.
506
     * Render the question flag, assuming $flagsoption allows it.
517
     *
507
     *
518
     * @param question_attempt $qa the question attempt to display.
508
     * @param question_attempt $qa the question attempt to display.
519
     * @param int $flagsoption the option that says whether flags should be displayed.
509
     * @param int $flagsoption the option that says whether flags should be displayed.
520
     */
510
     */
521
    protected function question_flag(question_attempt $qa, $flagsoption)
-
 
522
    {
511
    protected function question_flag(question_attempt $qa, $flagsoption) {
Línea 523... Línea 512...
523
        global $CFG;
512
        global $CFG;
Línea 524... Línea 513...
524
 
513
 
Línea 572... Línea 561...
572
 
561
 
573
        return html_writer::nonempty_tag('div', $flagcontent, $divattributes);
562
        return html_writer::nonempty_tag('div', $flagcontent, $divattributes);
Línea 574... Línea 563...
574
    }
563
    }
575
 
-
 
576
 
564
 
Línea 577... Línea 565...
577
    protected function edit_question_link(question_attempt $qa, question_display_options $options)
565
 
578
    {
566
    protected function edit_question_link(question_attempt $qa, question_display_options $options) {
579
        global $CFG;
567
        global $CFG;
Línea 604... Línea 592...
604
            stroke-width="2"
592
            stroke-width="2"
605
            d="M19.25 19.25H13.75">
593
            d="M19.25 19.25H13.75">
606
        </path>
594
        </path>
607
        </svg>';
595
        </svg>';
Línea 608... Línea 596...
608
 
596
 
609
        return html_writer::link(
-
 
610
            $editurl,
-
 
611
            $icon,
597
        return html_writer::link($editurl, $icon,
612
            array('class' => 'btn btn-icon btn-secondary editquestion line-height-1 ml-sm-2')
-
 
613
        );
598
        array('class' => 'btn btn-icon btn-secondary editquestion line-height-1 ml-sm-2'));
614
    }
599
    }
-
 
600
}