42 protected \ILIAS\Exercise\Team\TeamManager
$team;
67 $this->
lng = $DIC->language();
68 $this->
lng->loadLanguageModule(
'exc');
70 $this->ass_types_with_files = array(
77 $this->
logger = $DIC->logger()->exc();
78 $this->team = $DIC->exercise()->internal()->domain()->team();
119 $this->exercise_id = $input[0]->getValue();
120 $this->exercise_ref_id = $input[1]->getValue();
121 $assignment_id = $input[2]->getValue();
122 $participant_id = $input[3]->getValue();
123 $this->user_id = $input[4]->getValue();
124 $selected_participants = $input[5]->getValue();
125 $this->
logger->debug(
"Collect files. assignment id: " . $assignment_id .
", selected participants: " . $selected_participants);
126 if (trim($selected_participants) ===
"") {
127 $this->selected_participants = null;
129 $this->selected_participants = explode(
",", $selected_participants);
131 $final_directory =
"";
134 if ($assignment_id > 0) {
139 if ($participant_id > 0) {
142 foreach ($assignments as $assignment) {
149 $out->setValue($final_directory);
159 $dir = $this->target_directory .
"/" . $a_directory;
165 copy($a_file, $dir .
"/" . basename($a_file));
185 foreach ($this->title_columns as $title) {
186 $this->excel->setCell(1, $col, $title);
206 $path = $this->temp_dir . DIRECTORY_SEPARATOR;
207 if ($this->participant_id > 0) {
209 $path .= $user_dir . DIRECTORY_SEPARATOR;
220 $this->
logger->dump(
"lang key => " . $this->
lng->getLangKey());
221 $this->submissions_directory = $this->target_directory . DIRECTORY_SEPARATOR . $this->
lng->txt(
"exc_ass_submission_zip");
233 public function collectSubmissionFiles():
void 239 if ($this->participant_id > 0) {
240 $exc_members_id = array($this->participant_id);
242 $exc_members_id =
$exercise->members_obj->getMembers();
246 $exc_members_id = $filter->filterParticipantsByAccess();
248 foreach ($exc_members_id as $member_id) {
249 if (!is_null($this->selected_participants) && !in_array($member_id, $this->selected_participants)) {
253 $submission->updateTutorDownloadTime();
258 foreach ($submission->getFiles() as $file) {
259 $members[$file[
"user_id"]][
"files"][$file[
"returned_id"]] = $file;
264 $members[$member_id][
"name"] = $tmp_obj->getFirstname() .
" " . $tmp_obj->getLastname();
286 protected function addCriteriaToExcel(
292 $submission =
new ilExSubmission($this->assignment, $participant_id);
297 $values = $submission->getPeerReview()->getPeerReviewValues($feedback_giver, $participant_id);
299 foreach ($this->criteria_items as $item) {
303 $crit_id = $item->getId();
304 $crit_type = $item->getType();
305 $crit_title = $item->getTitle();
306 if ($crit_title ==
"") {
307 $crit_title = $item->getTranslatedType();
310 if (!in_array($crit_title, $this->title_columns)) {
311 $this->title_columns[] = $crit_title;
313 switch ($crit_type) {
315 if ($values[$crit_id] == 1) {
316 $this->excel->setCell($row, $col, $this->
lng->txt(
"yes"));
317 } elseif ($values[$crit_id] == -1) {
318 $this->excel->setCell($row, $col, $this->
lng->txt(
"no"));
332 $sub_obj_type =
"peer";
334 $sub_obj_type .=
"_" . $crit_id;
337 $this->assignment->getId(),
343 if ($rating_int = round((
int) $rating)) {
344 $this->excel->setCell($row, $col, $rating_int);
350 $this->excel->setCell($row, $col, $values[$crit_id]);
352 $this->excel->setCell($row, $col, $values[
'text']);
362 $crit_file_obj->setPeerReviewContext($this->assignment, $feedback_giver, $participant_id);
363 $files = $crit_file_obj->getFiles();
365 $extra_crit_column = 0;
366 foreach ($files as $file) {
367 if ($extra_crit_column !== 0) {
368 $this->title_columns[] = $crit_title .
"_" . $extra_crit_column;
370 $extra_crit_column++;
373 $this->excel->setCell($row, $col,
"./" . $dir . DIRECTORY_SEPARATOR . basename($file));
374 $this->excel->addLink($row, $col,
'./' . $dir . DIRECTORY_SEPARATOR . basename($file));
375 $this->excel->setColors($this->excel->getCoordByColumnAndRow($col, $row), self::BG_COLOR, self::LINK_COLOR);
387 $dir = self::FBK_DIRECTORY . DIRECTORY_SEPARATOR .
400 $ilDB = $DIC->database();
403 if ($this->participant_id > 0) {
407 $query =
"SELECT MAX(max_num) AS max" .
408 " FROM (SELECT COUNT(user_id) AS max_num FROM exc_returned" .
409 " WHERE obj_id=" . $a_obj_id .
". AND ass_id=" . $a_ass_id . $and .
" AND mimetype IS NOT NULL" .
410 " GROUP BY user_id) AS COUNTS";
412 $set =
$ilDB->query($query);
413 $row =
$ilDB->fetchAssoc($set);
414 return (
int) $row[
'max'];
421 array $a_submission_file
423 $user_id = $a_submission_file[
'user_id'];
426 $filepath =
'./' . $this->
lng->txt(
"exc_ass_submission_zip") . DIRECTORY_SEPARATOR . $targetdir . DIRECTORY_SEPARATOR;
427 switch ($this->assignment->getType()) {
429 $filepath .= $a_submission_file[
'filetitle'];
435 if (!$wsp_tree->getRootId()) {
436 $wsp_tree->createTreeForUser($user_id);
438 $node = $wsp_tree->getNodeData((
int) $a_submission_file[
'filetitle']);
439 $filepath .=
"blog_" . $node[
'obj_id'] . DIRECTORY_SEPARATOR .
"index.html";
443 $filepath .=
"prt_" . $a_submission_file[
'filetitle'] . DIRECTORY_SEPARATOR .
"index.html";
449 $this->excel->addLink($a_row, $a_col, $filepath);
463 $ass_has_feedback =
false;
464 $ass_has_criteria =
false;
468 $assignment_type = $this->assignment->getType();
474 if (!isset($this->temp_dir)) {
480 if (in_array($assignment_type, $this->ass_types_with_files)) {
482 $this->collectSubmissionFiles();
485 $first_excel_column_for_review = 0;
488 if ($this->assignment->getPeerReview()) {
489 $ass_has_feedback =
true;
493 $first_excel_column_for_review = self::FIRST_DEFAULT_REVIEW_COLUMN;
496 if ($this->
isExcelNeeded($assignment_type, $ass_has_feedback)) {
501 $this->excel->addSheet($this->sanitized_title);
505 $this->title_columns = array(
506 $this->
lng->txt(
'lastname'),
507 $this->
lng->txt(
'firstname'),
508 $this->
lng->txt(
'login'),
509 $this->
lng->txt(
'exc_last_submission')
511 switch ($assignment_type) {
513 $this->title_columns[] = $this->
lng->txt(
"exc_submission_text");
518 $first_excel_column_for_review++;
519 $this->title_columns[] = $this->
lng->txt(
"exc_team");
522 if ($num_columns_submission > 1) {
523 for ($i = 1; $i <= $num_columns_submission; $i++) {
524 $this->title_columns[] = $this->
lng->txt(
"exc_submission_file") .
" " . $i;
527 $this->title_columns[] = $this->
lng->txt(
"exc_submission_file");
530 $first_excel_column_for_review += $num_columns_submission - 1;
533 $this->title_columns[] = $this->
lng->txt(
"exc_submission");
536 if ($ass_has_feedback) {
537 $this->title_columns[] = $this->
lng->txt(
"exc_peer_review_giver");
538 $this->title_columns[] = $this->
lng->txt(
'exc_last_submission');
543 if ($this->criteria_items = $this->assignment->getPeerReviewCriteriaCatalogueItems()) {
544 $ass_has_criteria =
true;
547 if ($this->participant_id > 0) {
548 $participants = array($this->participant_id);
554 $participants = $filter->filterParticipantsByAccess();
558 foreach ($participants as $participant_id) {
559 if (!is_null($this->selected_participants) && !in_array($participant_id, $this->selected_participants)) {
562 $submission =
new ilExSubmission($this->assignment, $participant_id);
563 $submission_files = $submission->getFiles();
565 if ($submission_files !== []) {
567 $this->excel->setCell($row, self::PARTICIPANT_LASTNAME_COLUMN, $participant_name[
'lastname']);
568 $this->excel->setCell($row, self::PARTICIPANT_FIRSTNAME_COLUMN, $participant_name[
'firstname']);
569 $this->excel->setCell($row, self::PARTICIPANT_LOGIN_COLUMN, $participant_name[
'login']);
572 if (!in_array($assignment_type, $this->ass_types_with_files)) {
573 foreach ($submission_files as $submission_file) {
574 $this->excel->setCell($row, self::SUBMISSION_DATE_COLUMN, $submission_file[
'timestamp']);
575 $this->excel->setCell($row, self::FIRST_DEFAULT_SUBMIT_COLUMN, $submission_file[
'atext']);
578 $col = self::FIRST_DEFAULT_SUBMIT_COLUMN;
580 $team_id = $this->team->getTeamForMember($this->assignment->getId(),
$participant_id);
581 $this->excel->setCell($row, $col, (
string) $team_id);
584 foreach ($submission_files as $submission_file) {
585 $this->excel->setCell($row, self::SUBMISSION_DATE_COLUMN, $submission_file[
'timestamp']);
588 $this->excel->setCell($row, $col, $this->
lng->txt(
"open"));
590 $this->excel->setCell($row, $col, $submission_file[
'filetitle']);
592 $this->excel->setColors($this->excel->getCoordByColumnAndRow($col, $row), self::BG_COLOR, self::LINK_COLOR);
594 $this->
addLink($row, $col, $submission_file);
600 if ($ass_has_feedback) {
601 if ($col < $first_excel_column_for_review) {
602 $col = $first_excel_column_for_review;
605 if ($peer_review !== null) {
606 $reviews = $peer_review->getPeerReviewsByPeerId($participant_id);
610 $current_review_row = 0;
611 foreach ($reviews as $review) {
613 if ($review[
'tstamp']) {
614 $current_review_row++;
615 if ($current_review_row > 1) {
616 for ($i = 0; $i < $first_excel_column_for_review; $i++) {
617 $cell_to_copy = $this->excel->getCell($row, $i);
618 $this->excel->setCell($row + 1, $i, $cell_to_copy);
619 if ($i >= self::FIRST_DEFAULT_SUBMIT_COLUMN) {
620 $this->excel->setColors($this->excel->getCoordByColumnAndRow($i, $row + 1), self::BG_COLOR, self::LINK_COLOR);
626 $feedback_giver = $review[
'giver_id'];
630 $this->excel->setCell(
633 $feedback_giver_name[
'lastname'] .
", " . $feedback_giver_name[
'firstname'] .
" [" . $feedback_giver_name[
'login'] .
"]" 636 $this->excel->setCell($row, $col + 1, $review[
'tstamp']);
638 if ($ass_has_criteria) {
639 $this->addCriteriaToExcel($feedback_giver, $participant_id, $row, $col + 1);
650 $this->excel->writeToFile($this->target_directory .
"/" . $this->sanitized_title);
662 $ilDB = $DIC->database();
665 $set =
$ilDB->query(
"SELECT usr_id" .
666 " FROM exc_mem_ass_status" .
667 " WHERE ass_id = " .
$ilDB->quote($this->assignment->getId(),
"integer"));
669 while ($rec =
$ilDB->fetchAssoc($set)) {
673 $members[] = $rec[
'usr_id'];
ILIAS Exercise Team TeamManager $team
getAssignmentMembersIds()
get ONLY the members ids for this assignment
static downloadAllAssignmentFiles(ilExAssignment $a_ass, array $members, string $to_path)
Download all submitted files of an assignment (all user)
ilExAssignment $assignment
__construct()
Constructor.
isExcelNeeded(int $a_ass_type, bool $a_has_fbk)
static _lookupName(int $a_user_id)
lookup user name
collectAssignmentData(int $assignment_id)
write assignment data to excel file
const PARTICIPANT_LASTNAME_COLUMN
const FIRST_DEFAULT_SUBMIT_COLUMN
static getInstanceByType(string $a_type)
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...
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
createSubmissionsDirectory()
Create the directory with the assignment title.
const TYPE_UPLOAD
direct checks against const should be avoided, use type objects instead
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getASCIIFilename(string $a_filename)
createTargetDirectory()
Create the directory with the assignment title.
const SUBMISSION_DATE_COLUMN
array $ass_types_with_files
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static userExists(array $a_usr_ids=[])
addLink(int $a_row, int $a_col, array $a_submission_file)
addColumnTitles()
Set the Excel column titles.
static createDirectory(string $a_dir, int $a_mod=0755)
create directory
array $selected_participants
string $submissions_directory
run(array $input, Observer $observer)
run the job
createUniqueTempDirectory()
copyFileToSubDirectory(string $a_directory, string $a_file)
Copy a file in the Feedback_files directory TODO use the new filesystem.
getFeedbackDirectory(int $participant_id, int $feedback_giver)
see also bug https://mantis.ilias.de/view.php?id=30999
getExpectedTimeOfTaskInSeconds()
static getDirectoryNameFromUserData(int $a_user_id)
static getInstancesByExercise(int $a_exc_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
const FIRST_DEFAULT_REVIEW_COLUMN
static getRatingForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id, int $a_category_id=null)
Get rating for a user and an object.
const PARTICIPANT_LOGIN_COLUMN
const PARTICIPANT_FIRSTNAME_COLUMN
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getExtraColumnsForSubmissionFiles(int $a_obj_id, int $a_ass_id)
Get the number of max amount of files submitted by a single user in the assignment.
static getInstanceById(int $a_id)