58 $this->lng = $DIC->language();
59 $this->lng->loadLanguageModule(
'exc');
61 $this->ass_types_with_files = array(
67 $this->logger = $DIC->logger()->exc();
106 $this->exercise_id = $input[0]->getValue();
107 $this->exercise_ref_id = $input[1]->getValue();
108 $assignment_id = $input[2]->getValue();
110 $this->user_id = $input[4]->getValue();
113 if ($assignment_id > 0) {
128 $out->setValue($final_directory);
140 $dir = $this->target_directory .
"/" . $a_directory;
146 copy($a_file, $dir .
"/" . basename($a_file));
168 foreach ($this->title_columns as
$title) {
169 $this->excel->setCell(1, $col, $title);
189 $path = $this->temp_dir . DIRECTORY_SEPARATOR;
190 if ($this->participant_id > 0) {
192 $path .= $user_dir . DIRECTORY_SEPARATOR;
203 $this->logger->debug(
"lang key => " . $this->lng->getLangKey());
204 $this->submissions_directory = $this->target_directory . DIRECTORY_SEPARATOR . $this->lng->txt(
"exc_ass_submission_zip");
219 if ($this->participant_id > 0) {
220 $exc_members_id = array($this->participant_id);
222 $exc_members_id =
$exercise->members_obj->getMembers();
226 $exc_members_id = $filter->filterParticipantsByAccess();
228 foreach ($exc_members_id as $member_id) {
230 $submission->updateTutorDownloadTime();
235 foreach ($submission->getFiles() as $file) {
236 $members[$file[
"user_id"]][
"files"][$file[
"returned_id"]] = $file;
240 $members[$member_id][
"name"] = $tmp_obj->getFirstname() .
" " . $tmp_obj->getLastname();
279 foreach ($this->criteria_items as $item) {
283 $crit_id = $item->getId();
284 $crit_type = $item->getType();
285 $crit_title = $item->getTitle();
286 if ($crit_title ==
"") {
287 $crit_title = $item->getTranslatedType();
290 if (!in_array($crit_title, $this->title_columns)) {
291 $this->title_columns[] = $crit_title;
293 switch ($crit_type) {
296 $this->excel->setCell(
$row, $col, $this->lng->txt(
"yes"));
297 } elseif (
$values[$crit_id] == -1) {
298 $this->excel->setCell(
$row, $col, $this->lng->txt(
"no"));
312 $sub_obj_type =
"peer";
314 $sub_obj_type .=
"_" . $crit_id;
317 $this->assignment->getId(),
323 if ($rating_int = round((
int) $rating)) {
324 $this->excel->setCell(
$row, $col, $rating_int);
330 $this->excel->setCell(
$row, $col,
$values[$crit_id]);
332 $this->excel->setCell(
$row, $col,
$values[
'text']);
341 $crit_file_obj->setPeerReviewContext($this->assignment, $feedback_giver,
$participant_id);
342 $files = $crit_file_obj->getFiles();
344 $extra_crit_column = 0;
345 foreach (
$files as $file) {
346 if ($extra_crit_column) {
347 $this->title_columns[] = $crit_title .
"_" . $extra_crit_column;
349 $extra_crit_column++;
351 $this->excel->setCell(
$row, $col,
"./" . self::FBK_DIRECTORY . DIRECTORY_SEPARATOR . basename($file));
352 $this->excel->addLink(
$row, $col,
'./' . self::FBK_DIRECTORY . DIRECTORY_SEPARATOR . basename($file));
353 $this->excel->setColors($this->excel->getCoordByColumnAndRow($col,
$row), self::BG_COLOR, self::LINK_COLOR);
370 $ilDB = $DIC->database();
373 if ($this->participant_id > 0) {
377 $query =
"SELECT MAX(max_num) AS max" .
378 " FROM (SELECT COUNT(user_id) AS max_num FROM exc_returned" .
379 " WHERE obj_id=" . $a_obj_id .
". AND ass_id=" . $a_ass_id . $and .
" AND mimetype IS NOT NULL" .
380 " GROUP BY user_id) AS COUNTS";
394 public function addLink($a_row, $a_col, $a_submission_file)
396 $user_id = $a_submission_file[
'user_id'];
399 $filepath =
'./' . $this->lng->txt(
"exc_ass_submission_zip") . DIRECTORY_SEPARATOR . $targetdir . DIRECTORY_SEPARATOR;
400 switch ($this->assignment->getType()) {
402 $filepath .= $a_submission_file[
'filetitle'];
406 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
409 if (!$wsp_tree->getRootId()) {
410 $wsp_tree->createTreeForUser(
$user_id);
412 $node = $wsp_tree->getNodeData((
int) $a_submission_file[
'filetitle']);
413 $filepath .=
"blog_" . $node[
'obj_id'] . DIRECTORY_SEPARATOR .
"index.html";
417 $filepath .=
"prt_" . $a_submission_file[
'filetitle'] . DIRECTORY_SEPARATOR .
"index.html";
423 $this->excel->addLink($a_row, $a_col, $filepath);
428 $ass_has_feedback =
false;
429 $ass_has_criteria =
false;
433 $assignment_type = $this->assignment->getType();
439 if (!isset($this->temp_dir)) {
445 if (in_array($assignment_type, $this->ass_types_with_files)) {
450 if ($this->assignment->getPeerReview()) {
451 $ass_has_feedback =
true;
455 $first_excel_column_for_review = self::FIRST_DEFAULT_REVIEW_COLUMN;
463 if ($this->
isExcelNeeded($assignment_type, $ass_has_feedback)) {
465 include_once
"./Services/Excel/classes/class.ilExcel.php";
469 $this->excel->addSheet($this->sanitized_title);
473 $this->title_columns = array(
474 $this->lng->txt(
'lastname'),
475 $this->lng->txt(
'firstname'),
476 $this->lng->txt(
'login'),
477 $this->lng->txt(
'exc_last_submission')
479 switch ($assignment_type) {
481 $this->title_columns[] = $this->lng->txt(
"exc_submission_text");
485 if ($num_columns_submission > 1) {
486 for (
$i = 1;
$i <= $num_columns_submission;
$i++) {
487 $this->title_columns[] = $this->lng->txt(
"exc_submission_file") .
" " .
$i;
490 $this->title_columns[] = $this->lng->txt(
"exc_submission_file");
493 $first_excel_column_for_review += $num_columns_submission - 1;
496 $this->title_columns[] = $this->lng->txt(
"exc_submission");
499 if ($ass_has_feedback) {
500 $this->title_columns[] = $this->lng->txt(
"exc_peer_review_giver");
501 $this->title_columns[] = $this->lng->txt(
'exc_last_submission');
506 if ($this->criteria_items = $this->assignment->getPeerReviewCriteriaCatalogueItems()) {
507 $ass_has_criteria =
true;
510 if ($this->participant_id > 0) {
511 $participants = array($this->participant_id);
517 $participants = $filter->filterParticipantsByAccess();
523 $submission =
new ilExSubmission($this->assignment, $participant_id);
524 $submission_files = $submission->getFiles();
526 if ($submission_files) {
528 $this->excel->setCell(
$row, self::PARTICIPANT_LASTNAME_COLUMN, $participant_name[
'lastname']);
529 $this->excel->setCell(
$row, self::PARTICIPANT_FIRSTNAME_COLUMN, $participant_name[
'firstname']);
530 $this->excel->setCell(
$row, self::PARTICIPANT_LOGIN_COLUMN, $participant_name[
'login']);
533 if (!in_array($assignment_type, $this->ass_types_with_files)) {
534 foreach ($submission_files as $submission_file) {
535 $this->excel->setCell(
$row, self::SUBMISSION_DATE_COLUMN, $submission_file[
'timestamp']);
536 $this->excel->setCell(
$row, self::FIRST_DEFAULT_SUBMIT_COLUMN, $submission_file[
'atext']);
539 $col = self::FIRST_DEFAULT_SUBMIT_COLUMN;
540 foreach ($submission_files as $submission_file) {
541 $this->excel->setCell(
$row, self::SUBMISSION_DATE_COLUMN, $submission_file[
'timestamp']);
544 $this->excel->setCell(
$row, $col, $this->lng->txt(
"open"));
546 $this->excel->setCell(
$row, $col, $submission_file[
'filetitle']);
548 $this->excel->setColors($this->excel->getCoordByColumnAndRow($col + 1,
$row), self::BG_COLOR, self::LINK_COLOR);
554 if ($ass_has_feedback) {
555 if ($col < $first_excel_column_for_review) {
556 $col = $first_excel_column_for_review;
558 $reviews = $peer_review->getPeerReviewsByPeerId($participant_id);
561 $current_review_row = 0;
562 foreach ($reviews as $review) {
564 if ($review[
'tstamp']) {
565 $current_review_row++;
566 if ($current_review_row > 1) {
567 for (
$i = 0;
$i < $first_excel_column_for_review;
$i++) {
568 $cell_to_copy = $this->excel->getCell(
$row,
$i);
570 $this->excel->setCell(
$row + 1,
$i - 1, $cell_to_copy);
571 if (
$i > self::FIRST_DEFAULT_SUBMIT_COLUMN) {
572 $this->excel->setColors($this->excel->getCoordByColumnAndRow(
$i,
$row + 1), self::BG_COLOR, self::LINK_COLOR);
578 $feedback_giver = $review[
'giver_id'];
582 $this->excel->setCell(
585 $feedback_giver_name[
'lastname'] .
", " . $feedback_giver_name[
'firstname'] .
" [" . $feedback_giver_name[
'login'] .
"]" 588 $this->excel->setCell(
$row, $col + 1, $review[
'tstamp']);
590 if ($ass_has_criteria) {
602 $this->excel->writeToFile($this->target_directory .
"/" . $this->sanitized_title);
611 $ilDB = $DIC->database();
614 $set =
$ilDB->query(
"SELECT usr_id" .
615 " FROM exc_mem_ass_status" .
616 " WHERE ass_id = " .
$ilDB->quote($this->assignment->getId(),
"integer"));
618 while ($rec =
$ilDB->fetchAssoc($set)) {
619 $members[] = $rec[
'usr_id'];
static getInstanceByType($a_type)
static _lookupName($a_user_id)
lookup user name
getAssignmentMembersIds()
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static getInstanceById($a_id)
__construct()
Constructor.
static downloadAllAssignmentFiles(ilExAssignment $a_ass, array $members, $to_path)
Download all submitted files of an assignment (all user)
copyFileToSubDirectory($a_directory, $a_file)
Copy a file in the Feedback_files directory TODO use the new filesystem.
const PARTICIPANT_LASTNAME_COLUMN
const FIRST_DEFAULT_SUBMIT_COLUMN
Class ilExerciseMembersFilter.
createSubmissionsDirectory()
Create the directory with the assignment title.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static getDirectoryNameFromUserData($a_user_id)
Tree handler for personal workspace.
createTargetDirectory()
Create the directory with the assignment title.
const SUBMISSION_DATE_COLUMN
static getRatingForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_category_id=null)
Get rating for a user and an object.
collectAssignmentData($assignment_id)
addLink($a_row, $a_col, $a_submission_file)
Mapping the links to use them on the excel.
static getInstancesByExercise($a_exc_id)
addColumnTitles()
Set the Excel column titles.
run(array $input, Observer $observer)
run the job
static createDirectory($a_dir, $a_mod=0755)
create directory
isExcelNeeded($a_ass_type, $a_has_fbk)
createUniqueTempDirectory()
Description of class class.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getExpectedTimeOfTaskInSeconds()
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount ...
collectSubmissionFiles()
Store the zip file which contains all submission files in the target directory.
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
const FIRST_DEFAULT_REVIEW_COLUMN
const PARTICIPANT_LOGIN_COLUMN
const PARTICIPANT_FIRSTNAME_COLUMN
Exercise submission //TODO: This class has to much static methods related to delivered "files"...
getExtraColumnsForSubmissionFiles($a_obj_id, $a_ass_id)
Get the number of max amount of files submitted by a single user in the assignment.
addCriteriaToExcel($feedback_giver, $participant_id, $row, $col)
Add criteria data to the excel.