ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilExAssignmentListTextTableGUI.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{
17 protected $ass; // [ilExAssignment]
18 protected $show_peer_review; // [bool]
19
20 function __construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_show_peer_review = false, $a_disable_peer_review = false)
21 {
22 global $ilCtrl, $lng;
23
24 $this->ass = $a_ass;
25 $this->show_peer_review = (bool)$a_show_peer_review;
26 $this->setId("excassltxt".$this->ass->getId());
27
28 parent::__construct($a_parent_obj, $a_parent_cmd);
29
30 $this->setTitle($lng->txt("exc_list_text_assignment").
31 ": \"".$this->ass->getTitle()."\"");
32
33 // if you add pagination and disable the unlimited setting:
34 // fix saving of ordering of single pages!
35 $this->setLimit(9999);
36
37 $this->addColumn($this->lng->txt("user"), "uname", "15%");
38 $this->addColumn($this->lng->txt("exc_last_submission"), "udate", "10%");
39
40 if($this->show_peer_review)
41 {
42 $this->addColumn($this->lng->txt("exc_files_returned_text"), "", "45%");
43 $this->addColumn($this->lng->txt("exc_peer_review"), "", "30%");
44
45 include_once './Services/Rating/classes/class.ilRatingGUI.php';
46 include_once './Services/Accordion/classes/class.ilAccordionGUI.php';
47 }
48 else
49 {
50 $this->addColumn($this->lng->txt("exc_files_returned_text"), "", "75%");
51 }
52
53 $this->setDefaultOrderField("uname");
54 $this->setDefaultOrderDirection("asc");
55
56 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
57 $this->setRowTemplate("tpl.exc_list_text_assignment_row.html", "Modules/Exercise");
58
59 if(!$a_disable_peer_review &&
60 $this->ass->getPeerReview() &&
61 !$a_show_peer_review &&
62 ilExAssignment::countGivenFeedback($this->ass->getId()))
63 {
64 $this->addCommandButton("listTextAssignmentWithPeerReview", $lng->txt("exc_show_peer_review"));
65 }
66
67 $this->parse();
68 }
69
70 public function numericOrdering($a_field)
71 {
72 return ($a_field == "udate");
73 }
74
75 protected function parse()
76 {
77 $peer_data = array();
78 if($this->show_peer_review)
79 {
80 $peer_data = $this->ass->getAllPeerReviews();
81 }
82
83 include_once "Services/User/classes/class.ilUserUtil.php";
84 include_once "Services/RTE/classes/class.ilRTE.php";
85 foreach(ilExAssignment::getAllDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId()) as $file)
86 {
87 if(trim($file["atext"]))
88 {
89 $data[$file["user_id"]] = array(
90 "uid" => $file["user_id"],
91 "uname" => ilUserUtil::getNamePresentation($file["user_id"]),
92 "udate" => $file["ts"],
93 "utext" => ilRTE::_replaceMediaObjectImageSrc($file["atext"], 1) // mob id to mob src
94 );
95
96 if(isset($peer_data[$file["user_id"]]))
97 {
98 $data[$file["user_id"]]["peer"] = $peer_data[$file["user_id"]];
99 }
100 }
101 }
102
103 $this->setData($data);
104 }
105
106 protected function fillRow($a_set)
107 {
108 global $ilCtrl;
109
110 if($this->show_peer_review && isset($a_set["peer"]))
111 {
112 $acc_data = array();
113
114 foreach($a_set["peer"] as $peer_id => $peer_review)
115 {
116 $peer_name = ilUserUtil::getNamePresentation($peer_id);
117 $acc_item = $peer_name;
118
119 if($peer_review[1])
120 {
121 $rating = new ilRatingGUI();
122 $rating->setObject($this->ass->getId(), "ass", $a_set["uid"], "peer");
123 $rating->setUserId($peer_id);
124 $acc_item .= " ".$rating->getHTML(false, false);
125 }
126
127 if($peer_review[0])
128 {
129 $acc_item .= '<div class="small">'.nl2br($peer_review[0])."</div>";
130 }
131
132 $uploads = $this->ass->getPeerUploadFiles($a_set["uid"], $peer_id);
133 if($uploads)
134 {
135 $acc_item .= '<div class="small">';
136
137 $ilCtrl->setParameter($this->parent_obj, "fu", $peer_id."__".$a_set["uid"]);
138
139 foreach($uploads as $file)
140 {
141 $ilCtrl->setParameter($this->parent_obj, "fuf", md5($file));
142 $dl = $ilCtrl->getLinkTarget($this->parent_obj, "downloadPeerReview");
143 $ilCtrl->setParameter($this->parent_obj, "fuf", "");
144
145 $acc_item .= '<a href="'.$dl.'">'.basename($file).'</a><br />';
146 }
147
148 $ilCtrl->setParameter($this->parent_obj, "fu", "");
149
150 $acc_item .= '</div>';
151 }
152
153 $acc_data[$peer_id] = array("name" => $peer_name, "review" => $acc_item);
154 }
155
156 if($acc_data)
157 {
158 $acc_data = ilUtil::sortArray($acc_data, "name", "asc");
159
160 $acc = new ilAccordionGUI();
161 $acc->setId($this->ass->getId()."_".$a_set["uid"]);
162
163 $acc_html = "<ul>";
164 foreach($acc_data as $acc_item)
165 {
166 $acc_html .= "<li>".$acc_item["review"]."</li>";
167 }
168 $acc_html .= "</ul>";
169 $acc->addItem($this->lng->txt("show")." (".sizeof($acc_data).")", $acc_html);
170
171 $this->tpl->setCurrentBlock("peer_bl");
172 $this->tpl->setVariable("PEER_REVIEW", $acc->getHTML());
173 $this->tpl->parseCurrentBlock();
174 }
175 }
176
177 $this->tpl->setVariable("USER_NAME", $a_set["uname"]);
178 $this->tpl->setVariable("USER_DATE",
180 $this->tpl->setVariable("USER_TEXT", $a_set["utext"]);
181 }
182}
183
184?>
print $file
const IL_CAL_DATETIME
Accordion user interface class.
static formatDate(ilDateTime $date)
Format a date @access public.
Class for single dates.
fillRow($a_set)
Standard Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_show_peer_review=false, $a_disable_peer_review=false)
numericOrdering($a_field)
Should this field be sorted numeric?
Exercise assignment.
getAllDeliveredFiles($a_exc_id, $a_ass_id)
was: getAllDeliveredFiles()
static countGivenFeedback($a_ass_id)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Class ilRatingGUI.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setLimit($a_limit=0, $a_default_limit=0)
set max.
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40