Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
94.74% covered (success)
94.74%
36 / 38
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
marker_list
94.74% covered (success)
94.74%
36 / 38
50.00% covered (danger)
50.00%
1 / 2
9.01
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 export_for_template
94.59% covered (success)
94.59%
35 / 37
0.00% covered (danger)
0.00%
0 / 1
8.01
1<?php
2// This file is part of Moodle - https://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle.  If not, see <https://www.gnu.org/licenses/>.
16
17namespace local_doublemark\output;
18
19use core\output\renderable;
20use core\output\renderer_base;
21use core\output\templatable;
22use local_doublemark\local\display;
23use local_doublemark\local\double_marking;
24
25/**
26 * One marker's students: their own mark, and the other marker's once both are in.
27 *
28 * @package    local_doublemark
29 * @copyright  2026 DevLMS <contact@devlms.com>
30 * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31 */
32class marker_list implements renderable, templatable {
33    /**
34     * Create the list.
35     *
36     * @param double_marking $dm
37     * @param int $markerid
38     */
39    public function __construct(
40        /** @var float*/
41        private readonly double_marking $dm,
42        /** @var int The marker. */
43        private readonly int $markerid,
44    ) {
45    }
46
47    /**
48     * Data for local_doublemark/marker_list.
49     *
50     * @param renderer_base $output
51     * @return array
52     */
53    public function export_for_template(renderer_base $output): array {
54        $rows = [];
55        $todo = 0;
56        foreach ($this->dm->for_marker($this->markerid) as $userid => $item) {
57            $row = $item->row;
58            if ($row->status === double_marking::RELEASED) {
59                $label = display::status_label($row->status);
60                $badge = display::badge($row->status);
61            } else if (!$item->own) {
62                $label = get_string('mine:todo', 'local_doublemark');
63                $badge = 'badge bg-warning text-dark';
64                $todo++;
65            } else if (!$item->other) {
66                $label = get_string('mine:waiting', 'local_doublemark');
67                $badge = 'badge bg-light text-dark border';
68            } else {
69                $label = display::status_label($row->status);
70                $badge = display::badge($row->status);
71            }
72            $rows[] = [
73                'userid' => $userid,
74                'name' => $row->name,
75                'picture' => $row->anonymous ? '' : $output->user_picture($row->user, ['size' => 30, 'link' => false,
76                    'alttext' => false]),
77                'role' => get_string($item->position === 1 ? 'firstmarker' : 'secondmarker', 'local_doublemark'),
78                'own' => display::grade($item->own?->grade),
79                'other' => display::grade($item->other?->grade),
80                'statuslabel' => $label,
81                'badge' => $badge,
82                'locked' => $row->status === double_marking::RELEASED,
83                'markurl' => (new \moodle_url('/local/doublemark/mark.php', ['cmid' => $this->dm->cmid, 'userid' => $userid]))
84                    ->out(false),
85            ];
86        }
87        return [
88            'rows' => $rows,
89            'hasrows' => !empty($rows),
90            'todo' => $todo,
91            'summary' => get_string($todo ? 'mine:summary' : 'mine:alldone', 'local_doublemark', $todo),
92            'maxgrade' => display::grade($this->dm->max_grade()),
93        ];
94    }
95}