ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDownloadSubmissionsBackgroundTask.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
5
11{
15 protected $exc_ref_id;
16
20 protected $exc_id;
21
25 protected $ass_id;
26
30 protected $participant_id;
31
35 protected $user_id;
36
40 protected $task_factory = null;
41
45 protected $task_manager = null;
46
50 protected $lng;
51
55 private $logger = null;
56
65 public function __construct($a_usr_id, $a_exc_ref_id, $a_exc_id, $a_ass_id, $a_participant_id)
66 {
67 global $DIC;
68
69 $this->user_id = $a_usr_id;
70 $this->exc_ref_id = $a_exc_ref_id;
71 $this->exc_id = $a_exc_id;
72 $this->ass_id = $a_ass_id;
73 $this->participant_id = $a_participant_id;
74
75 $this->task_factory = $DIC->backgroundTasks()->taskFactory();
76 $this->task_manager = $DIC->backgroundTasks()->taskManager();
77 $this->logger = $DIC->logger()->exc();
78 }
79
80 public function run()
81 {
82 $bucket = new BasicBucket();
83 $bucket->setUserId($this->user_id);
84
85 $this->logger->debug("* Create task 'collect_data_job' using the following values:");
86 $this->logger->debug("job class = " . ilExerciseManagementCollectFilesJob::class);
87 $this->logger->debug("exc_id = " . $this->exc_id . ", exc_ref_id = " . $this->exc_ref_id . ", ass_id = " . (int) $this->ass_id . ", participant_id = " . (int) $this->participant_id . ", user_id = " . (int) $this->user_id);
88
89 $collect_data_job = $this->task_factory->createTask(
90 ilExerciseManagementCollectFilesJob::class,
91 [
92 (int) $this->exc_id,
93 (int) $this->exc_ref_id,
94 (int) $this->ass_id,
95 (int) $this->participant_id,
96 (int) $this->user_id
97 ]
98 );
99
100 $this->logger->debug("* Create task 'zip job' using the following values:");
101 $this->logger->debug("job class = " . ilSubmissionsZipJob::class);
102 $this->logger->debug("sending as input the task called->collect_data_job");
103
104 $zip_job = $this->task_factory->createTask(ilSubmissionsZipJob::class, [$collect_data_job]);
105
106 if ($this->participant_id > 0) {
107 $download_name = ilExSubmission::getDirectoryNameFromUserData($this->participant_id);
108 $bucket->setTitle($this->getParticipantBucketTitle());
109 } else {
110 $download_name = ilUtil::getASCIIFilename(ilExAssignment::lookupTitle($this->ass_id));
111 $bucket->setTitle($download_name);
112 }
113
114
115 $this->logger->debug("* Create task 'download_interaction' using the following values:");
116 $this->logger->debug("job class = " . ilExDownloadSubmissionsZipInteraction::class);
117 $this->logger->debug("download_name which is the same as bucket title = " . $download_name . " + the zip_job task");
118 // see comments here -> https://github.com/leifos-gmbh/ILIAS/commit/df6fc44a4c85da33bd8dd5b391a396349e7fa68f
119 $download_interaction = $this->task_factory->createTask(ilExDownloadSubmissionsZipInteraction::class, [$zip_job, $download_name]);
120
121 //download name
122 $bucket->setTask($download_interaction);
123 $this->task_manager->run($bucket);
124 return true;
125 }
126
127 protected function getParticipantBucketTitle()
128 {
129 $name = ilObjUser::_lookupName($this->participant_id);
130 $title = ucfirst($name['lastname']) . ", " . ucfirst($name['firstname']);
131 return $title;
132 }
133}
An exception for terminatinating execution or to throw for unit testing.
Download submissions and feedback for exercises.
__construct($a_usr_id, $a_exc_ref_id, $a_exc_id, $a_ass_id, $a_participant_id)
Constructor.
static lookupTitle($a_id)
Lookup title.
static getDirectoryNameFromUserData($a_user_id)
static _lookupName($a_user_id)
lookup user name
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
global $DIC
Definition: goto.php:24
if($format !==null) $name
Definition: metadata.php:230