ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssignmentsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
6
16{
20 protected $types;
21
25 public function __construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
26 {
27 global $DIC;
28
29 $this->ctrl = $DIC->ctrl();
30 $this->lng = $DIC->language();
31 $ilCtrl = $DIC->ctrl();
32 $lng = $DIC->language();
33 include_once("./Modules/Exercise/AssignmentTypes/classes/class.ilExAssignmentTypes.php");
34 $this->types = ilExAssignmentTypes::getInstance();
35
36 $this->exc_id = $a_exc_id;
37 $this->setId("excass" . $this->exc_id);
38
39 parent::__construct($a_parent_obj, $a_parent_cmd);
40
41 $this->setTitle($lng->txt("exc_assignments"));
42 $this->setTopCommands(true);
43
44 // if you add pagination and disable the unlimited setting:
45 // fix saving of ordering of single pages!
46 $this->setLimit(9999);
47
48 $this->addColumn("", "", "1", true);
49 $this->addColumn($this->lng->txt("title"), "title");
50 $this->addColumn($this->lng->txt("exc_assignment_type"), "type");
51 $this->addColumn($this->lng->txt("exc_presentation_order"), "order_val");
52 $this->addColumn($this->lng->txt("exc_start_time"), "start_time");
53 $this->addColumn($this->lng->txt("exc_deadline"), "deadline");
54 $this->addColumn($this->lng->txt("exc_mandatory"), "mandatory");
55 $this->addColumn($this->lng->txt("exc_peer_review"), "peer");
56 $this->addColumn($this->lng->txt("exc_instruction"), "", "30%");
57 $this->addColumn($this->lng->txt("actions"));
58
59 $this->setDefaultOrderField("val_order");
60 $this->setDefaultOrderDirection("asc");
61
62 //$this->setDefaultOrderField("name");
63 //$this->setDefaultOrderDirection("asc");
64
65 $this->setEnableHeader(true);
66 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
67 $this->setRowTemplate("tpl.exc_assignments_row.html", "Modules/Exercise");
68 //$this->disable("footer");
69 $this->setEnableTitle(true);
70 $this->setSelectAllCheckbox("id");
71
72 $this->addMultiCommand("confirmAssignmentsDeletion", $lng->txt("delete"));
73
74 $this->addCommandButton("orderAssignmentsByDeadline", $lng->txt("exc_order_by_deadline"));
75 $this->addCommandButton("saveAssignmentOrder", $lng->txt("exc_save_order"));
76 //$this->addCommandButton("addAssignment", $lng->txt("exc_add_assignment"));
77
78 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
79 include_once("./Modules/Exercise/classes/class.ilExPeerReview.php");
81 foreach ($data as $idx => $row) {
82 // #14450
83 if ($row["peer"]) {
84 $data[$idx]["peer_invalid"] = true;
85 $peer_review = new ilExPeerReview(new ilExAssignment($row["id"]));
86 $peer_reviews = $peer_review->validatePeerReviewGroups();
87 $data[$idx]["peer_invalid"] = $peer_reviews["invalid"];
88 }
89 $data[$idx]["ass_type"] = $this->types->getById($row["type"]);
90 $data[$idx]["type"] = $data[$idx]["ass_type"]->getTitle();
91 }
92
93 $this->setData($data);
94 }
95
96 public function numericOrdering($a_field)
97 {
98 // #12000
99 if (in_array($a_field, array("order_val", "deadline", "start_time"))) {
100 return true;
101 }
102 return false;
103 }
104
108 protected function fillRow($d)
109 {
112
113 $this->tpl->setVariable("ID", $d["id"]);
114
115 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
116 $ass = new ilExAssignment($d["id"]);
117
118 if ($d["deadline"] > 0) {
120 if ($d["deadline2"] > 0) {
121 $dl .= "<br />(" . ilDatePresentation::formatDate(new ilDateTime($d["deadline2"], IL_CAL_UNIX)) . ")";
122 }
123 $this->tpl->setVariable("TXT_DEADLINE", $dl);
124 }
125 if ($d["start_time"] > 0) {
126 $this->tpl->setVariable(
127 "TXT_START_TIME",
129 );
130 }
131 $this->tpl->setVariable(
132 "TXT_INSTRUCTIONS",
133 nl2br(trim(ilUtil::shortenText(strip_tags($d["instruction"]), 200, true)))
134 );
135
136 if ($d["mandatory"]) {
137 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("yes"));
138 } else {
139 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("no"));
140 }
141
142 $ilCtrl->setParameter($this->parent_obj, "ass_id", $d["id"]);
143
144 if ($d["peer"]) {
145 $this->tpl->setVariable("TXT_PEER", $lng->txt("yes") . " (" . $d["peer_min"] . ")");
146
147 if ($d["peer_invalid"]) {
148 $this->tpl->setVariable("TXT_PEER_INVALID", $lng->txt("exc_peer_reviews_invalid_warning"));
149 }
150
151 if ($ass->afterDeadlineStrict()) { // see #22246
152 $this->tpl->setVariable("TXT_PEER_OVERVIEW", $lng->txt("exc_peer_review_overview"));
153 $this->tpl->setVariable(
154 "CMD_PEER_OVERVIEW",
155 $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showPeerReviewOverview")
156 );
157 }
158 } else {
159 $this->tpl->setVariable("TXT_PEER", $lng->txt("no"));
160 }
161
162 $this->tpl->setVariable("TXT_TITLE", $d["title"]);
163 $this->tpl->setVariable("TXT_TYPE", $d["type"]);
164 $this->tpl->setVariable("ORDER_VAL", $d["order_val"]);
165
166 $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
167 $this->tpl->setVariable(
168 "CMD_EDIT",
169 $ilCtrl->getLinkTarget($this->parent_obj, "editAssignment")
170 );
171 }
172}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
__construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
Constructor.
numericOrdering($a_field)
Should this field be sorted numeric?
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static getInstance()
Get instance.
Exercise assignment.
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
Exercise peer review.
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.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
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 shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $ilCtrl
Definition: ilias.php:18
$row
global $DIC
Definition: saml.php:7