ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExGradesTableGUI.php
Go to the documentation of this file.
1<?php
2
21
28{
31 protected ?ilObjExercise $exc;
32 protected int $exc_id;
37 protected array $ass_data;
38
42 public function __construct(
43 object $a_parent_obj,
44 string $a_parent_cmd,
46 ilExerciseMembers $a_mem_obj
47 ) {
48 global $DIC;
49
50 $this->ctrl = $DIC->ctrl();
51 $this->lng = $DIC->language();
52 $ilCtrl = $DIC->ctrl();
53 $lng = $DIC->language();
54 $request = $DIC->exercise()->internal()->gui()->request();
55
56 $this->exc = $request->getExercise();
57 $this->service = $service;
58 $this->random_ass_manager = $service->domain()->assignment()->randomAssignments($this->exc);
59
60 $this->exc_id = $this->exc->getId();
61
62 $this->setId("exc_grades_" . $this->exc_id);
63
64 $this->mem_obj = $a_mem_obj;
65
66 $mems = $this->mem_obj->getMembers();
67 $mems = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
68 'edit_submissions_grades',
69 'edit_submissions_grades',
70 $this->exc->getRefId(),
71 $mems
72 );
73
74 $data = array();
75 foreach ($mems as $d) {
77 $data[$d]["user_id"] = $d;
78 $data[$d]["name"] = $data[$d]["lastname"] . ", " . $data[$d]["firstname"];
79 }
80
81 parent::__construct($a_parent_obj, $a_parent_cmd);
82 $this->setData($data);
83 $this->ass_data = ilExAssignment::getInstancesByExercise($this->exc_id);
84
85 //var_dump($data);
86 $this->setTitle($lng->txt("exc_grades"));
87 $this->setTopCommands(true);
88 //$this->setLimit(9999);
89
90 // $this->addColumn("", "", "1", true);
91 $this->addColumn($this->lng->txt("name"), "name");
92 $cnt = 1;
93 foreach ($this->ass_data as $ass) {
94 $ilCtrl->setParameter($this->parent_obj, "ass_id", $ass->getId());
95 $cnt_str = '<a href="' . $ilCtrl->getLinkTarget($this->parent_obj, "members") . '">' . $cnt . '</a>';
96 if (!$this->random_ass_manager->isActivated() && $ass->getMandatory()) {
97 $this->addColumn("<u>" . $cnt_str . "</u>", "", "", false, "", $ass->getTitle() . " " .
98 "(" . $lng->txt("exc_mandatory") . ")");
99 } else {
100 $this->addColumn($cnt_str, "", "", false, "", $ass->getTitle());
101 }
102 $cnt++;
103 }
104 $ilCtrl->setParameter($this->parent_obj, "ass_id", "");
105
106 $this->addColumn($this->lng->txt("exc_total_exc"), "");
107 $this->lng->loadLanguageModule("trac");
108 $this->addColumn($this->lng->txt("trac_comment"));
109
110 // $this->addColumn($this->lng->txt("exc_grading"), "solved_time");
111 // $this->addColumn($this->lng->txt("mail"), "feedback_time");
112
113 $this->setDefaultOrderField("name");
114 $this->setDefaultOrderDirection("asc");
115
116 $this->setEnableHeader(true);
117 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
118 $this->setRowTemplate("tpl.exc_grades_row.html", "components/ILIAS/Exercise");
119 //$this->disable("footer");
120 $this->setEnableTitle(true);
121 // $this->setSelectAllCheckbox("assid");
122
123 if (count($mems) > 0) {
124 $this->addCommandButton("saveGrades", $lng->txt("exc_save_changes"));
125 }
126 }
127
128 public function numericOrdering(string $a_field): bool
129 {
130 if ($a_field === "order_val") {
131 return true;
132 }
133 return false;
134 }
135
139 protected function getIconForStatus(string $status): string
140 {
143
144 switch ($status) {
145 case "passed":
146 return $icons->renderIcon(
147 $icons->getImagePathCompleted(),
148 $lng->txt("exc_" . $status)
149 );
150
151 case "failed":
152 return $icons->renderIcon(
153 $icons->getImagePathFailed(),
154 $lng->txt("exc_" . $status)
155 );
156
157 default:
158 return $icons->renderIcon(
159 $icons->getImagePathNotAttempted(),
160 $lng->txt("exc_" . $status)
161 );
162 }
163 }
164
165 protected function fillRow(array $a_set): void
166 {
168 $ilCtrl = $this->ctrl;
169
170 $user_id = $a_set["user_id"];
171
172 foreach ($this->ass_data as $ass) {
173 $member_status = new ilExAssignmentMemberStatus($ass->getId(), $user_id);
174
175 // grade
176 $this->tpl->setCurrentBlock("grade");
177 $status = $member_status->getStatus();
178 $this->tpl->setVariable("SEL_" . strtoupper($status), ' selected="selected" ');
179 $this->tpl->setVariable("TXT_NOTGRADED", $lng->txt("exc_notgraded"));
180 $this->tpl->setVariable("TXT_PASSED", $lng->txt("exc_passed"));
181 $this->tpl->setVariable("TXT_FAILED", $lng->txt("exc_failed"));
182 $this->tpl->setVariable(
183 "ICON_STATUS",
184 $this->getIconForStatus($member_status->getStatus())
185 );
186
187 // mark
188 $mark = $member_status->getMark();
189 $this->tpl->setVariable("VAL_ONLY_MARK", $mark);
190
191 $this->tpl->parseCurrentBlock();
192 }
193
194 // exercise total
195
196 // mark input
197 $this->tpl->setCurrentBlock("mark_input");
198 $this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
199 $this->tpl->setVariable(
200 "NAME_MARK",
201 "mark[" . $user_id . "]"
202 );
203 $mark = ilLPMarks::_lookupMark($user_id, $this->exc_id);
204 $this->tpl->setVariable(
205 "VAL_MARK",
207 );
208 $this->tpl->parseCurrentBlock();
209
210 $this->tpl->setCurrentBlock("grade");
211 $status = ilExerciseMembers::_lookupStatus($this->exc_id, $user_id);
212 $this->tpl->setVariable("SEL_" . strtoupper($status), ' selected="selected" ');
213
214 $this->tpl->setVariable(
215 "ICON_STATUS",
216 $this->getIconForStatus($status)
217 );
218
219 // mark
220 /*$this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
221 $this->tpl->setVariable("NAME_MARK",
222 "mark[".$d["id"]."]");
223 $mark = ilExAssignment::lookupMarkOfUser($ass["id"], $user_id);
224 $this->tpl->setVariable("VAL_MARK",
225 ilUtil::prepareFormOutput($mark));*/
226
227 $this->tpl->parseCurrentBlock();
228
229 // name
230 $this->tpl->setVariable(
231 "TXT_NAME",
232 $a_set["lastname"] . ", " . $a_set["firstname"] . " [" . $a_set["login"] . "]"
233 );
234 $this->tpl->setVariable("VAL_ID", $user_id);
235
236 // #17679
237 $ilCtrl->setParameter($this->parent_obj, "part_id", $user_id);
238 $url = $ilCtrl->getLinkTarget($this->parent_obj, "showParticipant");
239 $ilCtrl->setParameter($this->parent_obj, "part_id", "");
240
241 $this->tpl->setVariable("LINK_NAME", $url);
242
243 // comment
244 $this->tpl->setVariable("ID_COMMENT", $user_id);
245 $c = ilLPMarks::_lookupComment($user_id, $this->exc_id);
246 $this->tpl->setVariable(
247 "VAL_COMMENT",
249 );
250 }
251}
Manages random mandatory assignments of an exercise (business logic)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstancesByExercise(int $a_exc_id)
Exercise participant table.
__construct(object $a_parent_obj, string $a_parent_cmd, InternalService $service, ilExerciseMembers $a_mem_obj)
getIconForStatus(string $status)
Get the rendered icon for a status (failed, passed or not graded).
numericOrdering(string $a_field)
Should this field be sorted numeric?
Mandatory RandomAssignmentsManager $random_ass_manager
fillRow(array $a_set)
Standard Version of Fill Row.
Class ilExerciseMembers.
static _lookupStatus(int $a_obj_id, int $a_user_id)
Lookup current status (notgraded|passed|failed)
static _lookupComment(int $a_usr_id, int $a_obj_id)
static _lookupMark(int $a_usr_id, int $a_obj_id)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static prepareFormOutput($a_str, bool $a_strip=false)
Class ilObjExercise.
static _lookupName(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setEnableTitle(bool $a_enabletitle)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setTopCommands(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
ilLanguage $lng
$c
Definition: deliver.php:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68
$GLOBALS["DIC"]
Definition: wac.php:54