ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilExGradesTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
16 protected $service;
17
22
26 protected $exc;
27
31 protected $exc_id;
32
36 public function __construct($a_parent_obj, $a_parent_cmd, ilExerciseInternalService $service, $a_mem_obj)
37 {
38 global $DIC;
39
40 $this->ctrl = $DIC->ctrl();
41 $this->lng = $DIC->language();
42 $ilCtrl = $DIC->ctrl();
43 $lng = $DIC->language();
44 $request = $DIC->exercise()->internal()->request();
45
46 $this->exc = $request->getRequestedExercise();
47 $this->service = $service;
48 $this->random_ass_manager = $service->getRandomAssignmentManager($this->exc);
49
50 $this->exc_id = $this->exc->getId();
51
52 $this->setId("exc_grades_" . $this->exc_id);
53
54 $this->mem_obj = $a_mem_obj;
55
56 $mems = $this->mem_obj->getMembers();
57 $mems = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
58 'edit_submissions_grades',
59 'edit_submissions_grades',
60 $this->exc->getRefId(),
61 $mems
62 );
63
64 $data = array();
65 foreach ($mems as $d) {
67 $data[$d]["user_id"] = $d;
68 $data[$d]["name"] = $data[$d]["lastname"] . ", " . $data[$d]["firstname"];
69 }
70
71 parent::__construct($a_parent_obj, $a_parent_cmd);
72 $this->setData($data);
73 $this->ass_data = ilExAssignment::getInstancesByExercise($this->exc_id);
74
75 //var_dump($data);
76 $this->setTitle($lng->txt("exc_grades"));
77 $this->setTopCommands(true);
78 //$this->setLimit(9999);
79
80 // $this->addColumn("", "", "1", true);
81 $this->addColumn($this->lng->txt("name"), "name");
82 $cnt = 1;
83 foreach ($this->ass_data as $ass) {
84 $ilCtrl->setParameter($this->parent_obj, "ass_id", $ass->getId());
85 $cnt_str = '<a href="' . $ilCtrl->getLinkTarget($this->parent_obj, "members") . '">' . $cnt . '</a>';
86 if (!$this->random_ass_manager->isActivated() && $ass->getMandatory()) {
87 $this->addColumn("<u>" . $cnt_str . "</u>", "", "", false, "", $ass->getTitle() . " " .
88 "(" . $lng->txt("exc_mandatory") . ")");
89 } else {
90 $this->addColumn($cnt_str, "", "", false, "", $ass->getTitle());
91 }
92 $cnt++;
93 }
94 $ilCtrl->setParameter($this->parent_obj, "ass_id", "");
95
96 $this->addColumn($this->lng->txt("exc_total_exc"), "");
97 $this->lng->loadLanguageModule("trac");
98 $this->addColumn($this->lng->txt("trac_comment"));
99
100 // $this->addColumn($this->lng->txt("exc_grading"), "solved_time");
101 // $this->addColumn($this->lng->txt("mail"), "feedback_time");
102
103 $this->setDefaultOrderField("name");
104 $this->setDefaultOrderDirection("asc");
105
106 $this->setEnableHeader(true);
107 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
108 $this->setRowTemplate("tpl.exc_grades_row.html", "Modules/Exercise");
109 //$this->disable("footer");
110 $this->setEnableTitle(true);
111 // $this->setSelectAllCheckbox("assid");
112
113 if (count($mems) > 0) {
114 $this->addCommandButton("saveGrades", $lng->txt("exc_save_changes"));
115 }
116 }
117
121 public function numericOrdering($a_f)
122 {
123 if (in_array($a_f, array("order_val"))) {
124 return true;
125 }
126 return false;
127 }
128
132 protected function getIconForStatus(string $status) : string
133 {
136
137 switch ($status) {
138 case "passed":
139 return $icons->renderIcon(
140 $icons->getImagePathCompleted(),
141 $lng->txt("exc_" . $status)
142 );
143
144 case "failed":
145 return $icons->renderIcon(
146 $icons->getImagePathFailed(),
147 $lng->txt("exc_" . $status)
148 );
149
150 default:
151 return $icons->renderIcon(
152 $icons->getImagePathNotAttempted(),
153 $lng->txt("exc_" . $status)
154 );
155 }
156 }
157
158
162 protected function fillRow($d)
163 {
165 $ilCtrl = $this->ctrl;
166
167 $user_id = $d["user_id"];
168
169 foreach ($this->ass_data as $ass) {
170 $member_status = new ilExAssignmentMemberStatus($ass->getId(), $user_id);
171
172 // grade
173 $this->tpl->setCurrentBlock("grade");
174 $status = $member_status->getStatus();
175 $this->tpl->setVariable("SEL_" . strtoupper($status), ' selected="selected" ');
176 $this->tpl->setVariable("TXT_NOTGRADED", $lng->txt("exc_notgraded"));
177 $this->tpl->setVariable("TXT_PASSED", $lng->txt("exc_passed"));
178 $this->tpl->setVariable("TXT_FAILED", $lng->txt("exc_failed"));
179 $this->tpl->setVariable(
180 "ICON_STATUS",
181 $this->getIconForStatus($member_status->getStatus())
182 );
183
184 // mark
185 $mark = $member_status->getMark();
186 $this->tpl->setVariable("VAL_ONLY_MARK", $mark);
187
188 $this->tpl->parseCurrentBlock();
189 }
190
191 // exercise total
192
193 // mark input
194 $this->tpl->setCurrentBlock("mark_input");
195 $this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
196 $this->tpl->setVariable(
197 "NAME_MARK",
198 "mark[" . $user_id . "]"
199 );
200 $mark = ilLPMarks::_lookupMark($user_id, $this->exc_id);
201 $this->tpl->setVariable(
202 "VAL_MARK",
204 );
205 $this->tpl->parseCurrentBlock();
206
207 $this->tpl->setCurrentBlock("grade");
208 $status = ilExerciseMembers::_lookupStatus($this->exc_id, $user_id);
209 $this->tpl->setVariable("SEL_" . strtoupper($status), ' selected="selected" ');
210
211 $this->tpl->setVariable(
212 "ICON_STATUS",
213 $this->getIconForStatus($status)
214 );
215
216 // mark
217 /*$this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
218 $this->tpl->setVariable("NAME_MARK",
219 "mark[".$d["id"]."]");
220 $mark = ilExAssignment::lookupMarkOfUser($ass["id"], $user_id);
221 $this->tpl->setVariable("VAL_MARK",
222 ilUtil::prepareFormOutput($mark));*/
223
224 $this->tpl->parseCurrentBlock();
225
226 // name
227 $this->tpl->setVariable(
228 "TXT_NAME",
229 $d["lastname"] . ", " . $d["firstname"] . " [" . $d["login"] . "]"
230 );
231 $this->tpl->setVariable("VAL_ID", $user_id);
232
233 // #17679
234 $ilCtrl->setParameter($this->parent_obj, "part_id", $user_id);
235 $url = $ilCtrl->getLinkTarget($this->parent_obj, "showParticipant");
236 $ilCtrl->setParameter($this->parent_obj, "part_id", "");
237
238 $this->tpl->setVariable("LINK_NAME", $url);
239
240 // comment
241 $this->tpl->setVariable("ID_COMMENT", $user_id);
242 $c = ilLPMarks::_lookupComment($user_id, $this->exc_id);
243 $this->tpl->setVariable(
244 "VAL_COMMENT",
246 );
247 }
248}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Exercise assignment member status.
static getInstancesByExercise($a_exc_id)
Exercise participant table.
getIconForStatus(string $status)
Get the rendered icon for a status (failed, passed or not graded).
numericOrdering($a_f)
Check whether field is numeric.
__construct($a_parent_obj, $a_parent_cmd, ilExerciseInternalService $service, $a_mem_obj)
Constructor.
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
static _lookupMark($a_usr_id, $a_obj_id)
static _lookupComment($a_usr_id, $a_obj_id)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
static _lookupName($a_user_id)
lookup user name
Class ilTable2GUI.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$c
Definition: cli.php:37
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url