ILIAS  release_4-4 Revision
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 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 include_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  if($this->show_peer_review && isset($a_set["peer"]))
109  {
110  $acc_data = array();
111 
112  foreach($a_set["peer"] as $peer_id => $peer_review)
113  {
114  $peer_name = ilUserUtil::getNamePresentation($peer_id);
115  $acc_item = $peer_name;
116 
117  if($peer_review[1])
118  {
119  $rating = new ilRatingGUI();
120  $rating->setObject($this->ass->getId(), "ass", $a_set["uid"], "peer");
121  $rating->setUserId($peer_id);
122  $acc_item .= " ".$rating->getHTML(false, false);
123  }
124 
125  if($peer_review[0])
126  {
127  $acc_item .= '<div class="small">'.nl2br($peer_review[0])."</div>";
128  }
129 
130  $acc_data[$peer_id] = array("name" => $peer_name, "review" => $acc_item);
131  }
132 
133  if($acc_data)
134  {
135  $acc_data = ilUtil::sortArray($acc_data, "name", "asc");
136 
137  $acc = new ilAccordionGUI();
138  $acc->setId($this->ass->getId()."_".$a_set["uid"]);
139 
140  $acc_html = "<ul>";
141  foreach($acc_data as $acc_item)
142  {
143  $acc_html .= "<li>".$acc_item["review"]."</li>";
144  }
145  $acc_html .= "</ul>";
146  $acc->addItem($this->lng->txt("show")." (".sizeof($acc_data).")", $acc_html);
147 
148  $this->tpl->setCurrentBlock("peer_bl");
149  $this->tpl->setVariable("PEER_REVIEW", $acc->getHTML());
150  $this->tpl->parseCurrentBlock();
151  }
152  }
153 
154  $this->tpl->setVariable("USER_NAME", $a_set["uname"]);
155  $this->tpl->setVariable("USER_DATE",
156  ilDatePresentation::formatDate(new ilDate($a_set["udate"], IL_CAL_DATETIME)));
157  $this->tpl->setVariable("USER_TEXT", $a_set["utext"]);
158  }
159 }
160 
161 ?>
print $file
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Exercise assignment.
const IL_CAL_DATETIME
getAllDeliveredFiles($a_exc_id, $a_ass_id)
was: getAllDeliveredFiles()
__construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_show_peer_review=false, $a_disable_peer_review=false)
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
setId($a_val)
Set id.
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 countGivenFeedback($a_ass_id)
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.
setLimit($a_limit=0, $a_default_limit=0)
set max.
Class ilTable2GUI.
Class ilRatingGUI.
Class for single dates.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
static formatDate(ilDateTime $date)
Format a date public.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="")
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
global $lng
Definition: privfeed.php:40
setFormAction($a_form_action)
Set Form action parameter.
Accordion user interface class.