ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
129 
133  protected function fillRow($d)
134  {
135  $lng = $this->lng;
137 
138  $user_id = $d["user_id"];
139 
140  foreach ($this->ass_data as $ass) {
141  $member_status = new ilExAssignmentMemberStatus($ass->getId(), $user_id);
142 
143  // grade
144  $this->tpl->setCurrentBlock("grade");
145  $status = $member_status->getStatus();
146  $this->tpl->setVariable("SEL_" . strtoupper($status), ' selected="selected" ');
147  $this->tpl->setVariable("TXT_NOTGRADED", $lng->txt("exc_notgraded"));
148  $this->tpl->setVariable("TXT_PASSED", $lng->txt("exc_passed"));
149  $this->tpl->setVariable("TXT_FAILED", $lng->txt("exc_failed"));
150  $pic = $member_status->getStatusIcon();
151  $this->tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
152  $this->tpl->setVariable("ALT_STATUS", $lng->txt("exc_" . $status));
153 
154  // mark
155  $mark = $member_status->getMark();
156  $this->tpl->setVariable("VAL_ONLY_MARK", $mark);
157 
158  $this->tpl->parseCurrentBlock();
159  }
160 
161  // exercise total
162 
163  // mark input
164  $this->tpl->setCurrentBlock("mark_input");
165  $this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
166  $this->tpl->setVariable(
167  "NAME_MARK",
168  "mark[" . $user_id . "]"
169  );
170  $mark = ilLPMarks::_lookupMark($user_id, $this->exc_id);
171  $this->tpl->setVariable(
172  "VAL_MARK",
174  );
175  $this->tpl->parseCurrentBlock();
176 
177  $this->tpl->setCurrentBlock("grade");
178  $status = ilExerciseMembers::_lookupStatus($this->exc_id, $user_id);
179  $this->tpl->setVariable("SEL_" . strtoupper($status), ' selected="selected" ');
180  switch ($status) {
181  case "passed": $pic = "scorm/passed.svg"; break;
182  case "failed": $pic = "scorm/failed.svg"; break;
183  default: $pic = "scorm/not_attempted.svg"; break;
184  }
185  $this->tpl->setVariable("IMG_STATUS", ilUtil::getImagePath($pic));
186  $this->tpl->setVariable("ALT_STATUS", $lng->txt("exc_" . $status));
187 
188  // mark
189  /*$this->tpl->setVariable("TXT_MARK", $lng->txt("exc_mark"));
190  $this->tpl->setVariable("NAME_MARK",
191  "mark[".$d["id"]."]");
192  $mark = ilExAssignment::lookupMarkOfUser($ass["id"], $user_id);
193  $this->tpl->setVariable("VAL_MARK",
194  ilUtil::prepareFormOutput($mark));*/
195 
196  $this->tpl->parseCurrentBlock();
197 
198  // name
199  $this->tpl->setVariable(
200  "TXT_NAME",
201  $d["lastname"] . ", " . $d["firstname"] . " [" . $d["login"] . "]"
202  );
203  $this->tpl->setVariable("VAL_ID", $user_id);
204 
205  // #17679
206  $ilCtrl->setParameter($this->parent_obj, "part_id", $user_id);
207  $url = $ilCtrl->getLinkTarget($this->parent_obj, "showParticipant");
208  $ilCtrl->setParameter($this->parent_obj, "part_id", "");
209 
210  $this->tpl->setVariable("LINK_NAME", $url);
211 
212  // comment
213  $this->tpl->setVariable("ID_COMMENT", $user_id);
214  $c = ilLPMarks::_lookupComment($user_id, $this->exc_id);
215  $this->tpl->setVariable(
216  "VAL_COMMENT",
218  );
219  }
220 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static _lookupName($a_user_id)
lookup user name
Exercise assignment member status.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setId($a_val)
Set id.
numericOrdering($a_f)
Check whether field is numeric.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
__construct($a_parent_obj, $a_parent_cmd, ilExerciseInternalService $service, $a_mem_obj)
Constructor.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
static getInstancesByExercise($a_exc_id)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
__construct(Container $dic, ilPlugin $plugin)
fillRow($d)
Fill table row.
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.
$DIC
Definition: xapitoken.php:46
setEnableHeader($a_enableheader)
Set Enable Header.
$url
getRandomAssignmentManager(ilObjExercise $exc, $user=null)
Get random assignment manager.
static _lookupMark($a_usr_id, $a_obj_id)
static _lookupComment($a_usr_id, $a_obj_id)
setEnableTitle($a_enabletitle)
Set Enable Title.
Exercise participant table.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296