ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExAssignmentListTextTableGUI.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  protected ilExAssignment $ass;
27  protected bool $show_peer_review;
29 
30  public function __construct(
31  object $a_parent_obj,
32  string $a_parent_cmd,
33  ilExAssignment $a_ass,
34  bool $a_show_peer_review = false,
35  bool $a_disable_peer_review = false
36  ) {
37  global $DIC;
38 
39  $this->ctrl = $DIC->ctrl();
40  $this->lng = $DIC->language();
41  $ilCtrl = $DIC->ctrl();
42  $lng = $DIC->language();
43 
44  $this->ass = $a_ass;
45  $this->show_peer_review = $a_show_peer_review;
46  $this->setId("excassltxt" . $this->ass->getId());
47 
48  parent::__construct($a_parent_obj, $a_parent_cmd);
49 
50  $this->setTitle(
51  $lng->txt("exc_list_text_assignment") .
52  ": \"" . $this->ass->getTitle() . "\""
53  );
54 
55  // if you add pagination and disable the unlimited setting:
56  // fix saving of ordering of single pages!
57  $this->setLimit(9999);
58 
59  $this->addColumn($this->lng->txt("user"), "uname", "15%");
60  $this->addColumn($this->lng->txt("exc_last_submission"), "udate", "10%");
61 
62  if ($this->show_peer_review) {
63  $this->addColumn($this->lng->txt("exc_files_returned_text"), "", "45%");
64  $this->addColumn($this->lng->txt("exc_peer_review"), "", "30%");
65 
66  $this->peer_review = new ilExPeerReview($this->ass);
67  } else {
68  $this->addColumn($this->lng->txt("exc_files_returned_text"), "", "75%");
69  }
70 
71  $this->setDefaultOrderField("uname");
72  $this->setDefaultOrderDirection("asc");
73 
74  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
75  $this->setRowTemplate("tpl.exc_list_text_assignment_row.html", "Modules/Exercise");
76 
77  if (!$a_disable_peer_review &&
78  $this->ass->getPeerReview() &&
79  !$a_show_peer_review) {
80  $this->addCommandButton("listTextAssignment", $lng->txt("exc_show_peer_review"));
81  }
82 
83  $this->parse();
84  }
85 
86  public function numericOrdering(string $a_field): bool
87  {
88  return ($a_field == "udate");
89  }
90 
91  protected function parse(): void
92  {
93  $peer_data = array();
94  if ($this->show_peer_review) {
95  $peer_data = $this->peer_review->getAllPeerReviews();
96  }
97  $data = [];
98  foreach (ilExSubmission::getAllAssignmentFiles($this->ass->getExerciseId(), $this->ass->getId()) as $file) {
99  if (trim($file["atext"])) {
100  $data[$file["user_id"]] = array(
101  "uid" => $file["user_id"],
102  "uname" => ilUserUtil::getNamePresentation($file["user_id"]),
103  "udate" => $file["ts"],
104  "utext" => ilRTE::_replaceMediaObjectImageSrc($file["atext"], 1) // mob id to mob src
105  );
106 
107  if (isset($peer_data[$file["user_id"]])) {
108  $data[$file["user_id"]]["peer"] = array_keys($peer_data[$file["user_id"]]);
109  }
110  }
111  }
112 
113  $this->setData($data);
114  }
115 
116  protected function fillRow(array $a_set): void
117  {
118  if ($this->show_peer_review) {
119  $peer_data = "&nbsp;";
120  if (isset($a_set["peer"])) {
121  $acc = new ilAccordionGUI();
122  $acc->setId($this->ass->getId() . "_" . $a_set["uid"]);
123 
124  foreach ($a_set["peer"] as $peer_id) {
125  $submission = new ilExSubmission($this->ass, $a_set["uid"]);
126  $values = $submission->getPeerReview()->getPeerReviewValues($peer_id, $a_set["uid"]);
127 
128  $acc_html = array();
129  foreach ($this->ass->getPeerReviewCriteriaCatalogueItems() as $crit) {
130  $crit_id = $crit->getId()
131  ? $crit->getId()
132  : $crit->getType();
133  $crit->setPeerReviewContext($this->ass, $peer_id, $a_set["uid"]);
134 
135  // see ilWikiAdvMetaDataBlockGUI
136  $acc_html[] = '<p>' .
137  '<div class="ilBlockPropertyCaption">' . $crit->getTitle() . '</div>' .
138  '<div>' . $crit->getHTML($values[$crit_id]) . '</div>' .
139  '</p>';
140  }
141 
142  $acc->addItem(
143  ilUserUtil::getNamePresentation($peer_id, false, false, "", true),
144  '<div style="margin-left:10px;">' . implode("\n", $acc_html) . '</div>'
145  );
146  }
147 
148  $peer_data = $acc->getHTML();
149  }
150  $this->tpl->setCurrentBlock("peer_bl");
151  $this->tpl->setVariable("PEER_REVIEW", $peer_data);
152  $this->tpl->parseCurrentBlock();
153  }
154 
155  $this->tpl->setVariable("USER_NAME", $a_set["uname"]);
156  $this->tpl->setVariable(
157  "USER_DATE",
159  );
160  $this->tpl->setVariable("USER_TEXT", nl2br($a_set["utext"]));
161  }
162 }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setData(array $a_data)
Exercise assignment.
const IL_CAL_DATETIME
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
ilLanguage $lng
setId(string $a_val)
global $DIC
Definition: feed.php:28
Exercise peer review.
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, ilExAssignment $a_ass, bool $a_show_peer_review=false, bool $a_disable_peer_review=false)
static getAllAssignmentFiles(int $a_exc_id, int $a_ass_id)