/** * @see ilSubItemListGUI::getHTML() */ public function getHTML() { global $lng; $lng->loadLanguageModule('exc'); $valid = false; foreach ($this->getSubItemIds(true) as $sub_item) { if (!$this->isAssignmentVisible($sub_item)) { continue; } $valid = true; if (is_object($this->getHighlighter()) and strlen($this->getHighlighter()->getContent($this->getObjId(), $sub_item))) { $this->tpl->setCurrentBlock('sea_fragment'); $this->tpl->setVariable('TXT_FRAGMENT', $this->getHighlighter()->getContent($this->getObjId(), $sub_item)); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock('subitem'); $this->tpl->setVariable('SUBITEM_TYPE', $lng->txt('exc_assignment')); $this->tpl->setVariable('SEPERATOR', ':'); #$link_data = ilLinkResourceItems::lookupItem($this->getObjId(),$sub_item); #$link_data = ilParameterAppender::_append($link_data); #$this->getItemListGUI()->setChildId($sub_item); $this->tpl->setVariable('LINK', 'ilias.php?baseClass=ilExerciseHandlerGUI&cmd=showOverview&ref_id=' . $this->getRefId() . '&ass_id=' . $sub_item); $this->tpl->setVariable('TITLE', ilExAssignment::lookupTitle($sub_item)); if (count($this->getSubItemIds(true)) > 1) { $this->parseRelevance($sub_item); } $this->tpl->parseCurrentBlock(); } $this->showDetailsLink(); return $valid ? $this->tpl->get() : ''; }
/** * Send notifications * @return */ public function send() { global $ilUser; // parent::send(); include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; switch ($this->getType()) { case self::TYPE_FEEDBACK_FILE_ADDED: foreach ($this->getRecipients() as $rcp) { $this->initLanguage($rcp); $this->initMail(); $this->setSubject(sprintf($this->getLanguageText('exc_msg_new_feedback_file_uploaded'), $this->getObjectTitle(true))); $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage())); $this->appendBody("\n\n"); $this->appendBody($this->getLanguageText('exc_msg_new_feedback_file_uploaded2')); $this->appendBody("\n"); $this->appendBody($this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true)); $this->appendBody("\n"); $this->appendBody($this->getLanguageText('exc_assignment') . ": " . ilExAssignment::lookupTitle($this->getAssignmentId())); $this->appendBody("\n\n"); $this->appendBody($this->getLanguageText('exc_mail_permanent_link')); $this->appendBody("\n"); $this->appendBody($this->createPermanentLink(array(), '_' . $this->getAssignmentId()) . '#fb' . $this->getAssignmentId()); $this->getMail()->appendInstallationSignature(true); $this->sendMail(array($rcp), array('system')); } break; case self::TYPE_SUBMISSION_UPLOAD: foreach ($this->getRecipients() as $rcp) { $this->initLanguage($rcp); $this->initMail(); $this->setSubject(sprintf($this->getLanguageText('exc_submission_notification_subject'), $this->getObjectTitle(true))); $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage())); $this->appendBody("\n\n"); $this->appendBody(sprintf($this->getLanguageText('exc_submission_notification_body'), $this->getObjectTitle(true))); $this->appendBody("\n"); $this->appendBody($this->getLanguageText('exc_assignment') . ": " . ilExAssignment::lookupTitle($this->getAssignmentId())); $this->appendBody("\n"); $this->appendBody($this->getLanguageText('user') . ": " . $ilUser->getFullName()); $this->appendBody("\n\n"); $this->appendBody(sprintf($this->getLanguageText('exc_submission_notification_link'), $this->createPermanentLink())); $this->getMail()->appendInstallationSignature(true); $this->sendMail(array($rcp), array('system')); } break; } return true; }
/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd, $a_exc, $a_ass_id) { global $ilCtrl, $lng, $ilAccess, $lng; $this->exc = $a_exc; $this->exc_id = $this->exc->getId(); include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $this->ass_id = $a_ass_id; parent::__construct($a_parent_obj, $a_parent_cmd); $this->setData(ilExAssignment::getMemberListData($this->exc_id, $this->ass_id)); $this->setTitle($lng->txt("exc_assignment") . ": " . ilExAssignment::lookupTitle($a_ass_id)); $this->setTopCommands(true); //$this->setLimit(9999); $this->addColumn($this->lng->txt("name"), "name"); $this->addColumn($this->lng->txt("exc_submission"), ""); $this->setDefaultOrderField("name"); $this->setDefaultOrderDirection("asc"); $this->setEnableHeader(true); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.exc_public_submissions_row.html", "Modules/Exercise"); //$this->disable("footer"); $this->setEnableTitle(true); }
function initMultiFeedbackForm($a_ass_id) { global $lng; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->addCommandButton("uploadMultiFeedback", $lng->txt("upload")); $form->addCommandButton("members", $lng->txt("cancel")); // multi feedback file $fi = new ilFileInputGUI($lng->txt("exc_multi_feedback_file"), "mfzip"); $fi->setSuffixes(array("zip")); $fi->setRequired(true); $form->addItem($fi); $form->setTitle(ilExAssignment::lookupTitle($a_ass_id)); $form->setFormAction($this->ctrl->getFormAction($this, "uploadMultiFeedback")); return $form; }
/** * Download all submitted files of an assignment (all user) * * @param $members array of user names, key is user id */ function downloadAllDeliveredFiles($a_exc_id, $a_ass_id, $members) { global $lng, $ilObjDataCache, $ilias; include_once "./Services/Utilities/classes/class.ilUtil.php"; include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $storage = new ilFSStorageExercise($a_exc_id, $a_ass_id); $storage->create(); ksort($members); //$savepath = $this->getExercisePath() . "/" . $this->obj_id . "/"; $savepath = $storage->getAbsoluteSubmissionPath(); $cdir = getcwd(); // important check: if the directory does not exist // ILIAS stays in the current directory (echoing only a warning) // and the zip command below archives the whole ILIAS directory // (including the data directory) and sends a mega file to the user :-o if (!is_dir($savepath)) { return; } // Safe mode fix // chdir($this->getExercisePath()); chdir($storage->getTempPath()); $zip = PATH_TO_ZIP; // check first, if we have enough free disk space to copy all files to temporary directory $tmpdir = ilUtil::ilTempnam(); ilUtil::makeDir($tmpdir); chdir($tmpdir); $dirsize = 0; foreach ($members as $id => $object) { $directory = $savepath . DIRECTORY_SEPARATOR . $id; $dirsize += ilUtil::dirsize($directory); } if ($dirsize > disk_free_space($tmpdir)) { return -1; } $ass_type = self::lookupType($a_ass_id); // copy all member directories to the temporary folder // switch from id to member name and append the login if the member name is double // ensure that no illegal filenames will be created // remove timestamp from filename $cache = array(); foreach ($members as $id => $user) { $sourcedir = $savepath . DIRECTORY_SEPARATOR . $id; if (!is_dir($sourcedir)) { continue; } $userName = ilObjUser::_lookupName($id); //$directory = ilUtil::getASCIIFilename(trim($userName["lastname"])."_".trim($userName["firstname"])); $directory = ilUtil::getASCIIFilename(trim($userName["lastname"]) . "_" . trim($userName["firstname"]) . "_" . trim($userName["login"]) . "_" . $userName["user_id"]); /*if (array_key_exists($directory, $cache)) { // first try is to append the login; $directory = ilUtil::getASCIIFilename($directory."_".trim(ilObjUser::_lookupLogin($id))); if (array_key_exists($directory, $cache)) { // second and secure: append the user id as well. $directory .= "_".$id; } }*/ $cache[$directory] = $directory; ilUtil::makeDir($directory); $sourcefiles = scandir($sourcedir); foreach ($sourcefiles as $sourcefile) { if ($sourcefile == "." || $sourcefile == "..") { continue; } $targetfile = trim(basename($sourcefile)); $pos = strpos($targetfile, "_"); if ($pos !== false) { $targetfile = substr($targetfile, $pos + 1); } $targetfile = $directory . DIRECTORY_SEPARATOR . $targetfile; $sourcefile = $sourcedir . DIRECTORY_SEPARATOR . $sourcefile; if (!copy($sourcefile, $targetfile)) { //echo 'Could not copy '.$sourcefile.' to '.$targetfile; $ilias->raiseError('Could not copy ' . basename($sourcefile) . " to '" . $targetfile . "'.", $ilias->error_obj->MESSAGE); } else { // preserve time stamp touch($targetfile, filectime($sourcefile)); // blogs and portfolios are stored as zip and have to be unzipped if ($ass_type == ilExAssignment::TYPE_PORTFOLIO || $ass_type == ilExAssignment::TYPE_BLOG) { ilUtil::unzip($targetfile); unlink($targetfile); } } } } $tmpfile = ilUtil::ilTempnam(); $tmpzipfile = $tmpfile . ".zip"; // Safe mode fix $zipcmd = $zip . " -r " . ilUtil::escapeShellArg($tmpzipfile) . " ."; exec($zipcmd); ilUtil::delDir($tmpdir); $assTitle = ilExAssignment::lookupTitle($a_ass_id) . "_" . $a_ass_id; chdir($cdir); ilUtil::deliverFile($tmpzipfile, (strlen($assTitle) == 0 ? strtolower($lng->txt("exc_assignment")) : $assTitle) . ".zip", "", false, true); }
/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd, $a_exc, $a_ass_id) { global $ilCtrl, $lng, $ilAccess, $lng; $this->exc = $a_exc; $this->exc_id = $this->exc->getId(); $this->setId("exc_mem_" . $a_ass_id); include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $this->storage = new ilFSStorageExercise($this->exc_id, $a_ass_id); include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $this->ass_id = $a_ass_id; parent::__construct($a_parent_obj, $a_parent_cmd); $this->setTitle($lng->txt("exc_assignment") . ": " . ilExAssignment::lookupTitle($a_ass_id)); $this->setTopCommands(true); //$this->setLimit(9999); $this->type = ilExAssignment::lookupType($this->ass_id); $data = ilExAssignment::getMemberListData($this->exc_id, $this->ass_id); // team upload? (1 row == 1 team) if ($this->type == ilExAssignment::TYPE_UPLOAD_TEAM) { $ass_obj = new ilExAssignment($this->ass_id); $team_map = ilExAssignment::getAssignmentTeamMap($this->ass_id); $tmp = array(); foreach ($data as $item) { $team_id = $team_map[$item["usr_id"]]; // #11058 if (!$team_id) { $team_id = $ass_obj->getTeamId($item["usr_id"], true); } if (!isset($tmp[$team_id])) { $tmp[$team_id] = $item; } $tmp[$team_id]["team"][$item["usr_id"]] = $item["name"]; $tmp[$team_id]["team_id"] = $team_id; } $data = $tmp; unset($tmp); } $this->setData($data); $this->addColumn("", "", "1", true); if ($this->type != ilExAssignment::TYPE_UPLOAD_TEAM) { $this->addColumn($this->lng->txt("image"), "", "1"); $this->addColumn($this->lng->txt("name"), "name"); $this->addColumn($this->lng->txt("login"), "login"); } else { $this->addColumn($this->lng->txt("exc_team")); } $this->sent_col = ilExAssignment::lookupAnyExerciseSent($this->exc->getId(), $this->ass_id); if ($this->sent_col) { $this->addColumn($this->lng->txt("exc_exercise_sent"), "sent_time"); } $this->addColumn($this->lng->txt("exc_submission"), "submission"); $this->addColumn($this->lng->txt("exc_grading"), "solved_time"); $this->addColumn($this->lng->txt("feedback"), "feedback_time"); $this->setDefaultOrderField("name"); $this->setDefaultOrderDirection("asc"); $this->setEnableHeader(true); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.exc_members_row.html", "Modules/Exercise"); //$this->disable("footer"); $this->setEnableTitle(true); $this->setSelectAllCheckbox("member"); $this->addMultiCommand("saveStatus", $lng->txt("exc_save_changes")); $this->addMultiCommand("redirectFeedbackMail", $lng->txt("exc_send_mail")); $this->addMultiCommand("sendMembers", $lng->txt("exc_send_assignment")); $this->addMultiCommand("confirmDeassignMembers", $lng->txt("exc_deassign_members")); //if(count($this->exc->members_obj->getAllDeliveredFiles())) if (count(ilExAssignment::getAllDeliveredFiles($this->exc_id, $this->ass_id))) { $this->addCommandButton("downloadAll", $lng->txt("download_all_returned_files")); } }
/** * Set assignment header */ function setAssignmentHeader() { global $ilTabs, $lng, $ilCtrl, $tpl, $ilHelp; include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $tpl->setTitle(ilExAssignment::lookupTitle($_GET["ass_id"])); $tpl->setDescription(""); $ilTabs->clearTargets(); $ilHelp->setScreenIdComponent("exc"); $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, "listAssignments")); $ilTabs->addTab("ass_settings", $lng->txt("settings"), $ilCtrl->getLinkTarget($this, "editAssignment")); $ilTabs->addTab("ass_files", $lng->txt("files"), $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles")); }
/** * send exercise per mail to members */ function sendAssignment($a_exc_id, $a_ass_id, $a_members) { include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $ass_title = ilExAssignment::lookupTitle($a_ass_id); include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $storage = new ilFSStorageExercise($a_exc_id, $a_ass_id); $files = $storage->getFiles(); if (count($files)) { include_once "./Services/Mail/classes/class.ilFileDataMail.php"; $mfile_obj = new ilFileDataMail($_SESSION["AccountId"]); foreach ($files as $file) { $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]); $file_names[] = $file["name"]; } } include_once "Services/Mail/classes/class.ilMail.php"; $tmp_mail_obj = new ilMail($_SESSION["AccountId"]); $message = $tmp_mail_obj->sendMail($this->__formatRecipients($a_members), "", "", $this->__formatSubject($ass_title), $this->__formatBody($a_ass_id), count($file_names) ? $file_names : array(), array("normal")); unset($tmp_mail_obj); if (count($file_names)) { $mfile_obj->unlinkFiles($file_names); unset($mfile_obj); } // SET STATUS SENT FOR ALL RECIPIENTS foreach ($a_members as $member_id => $value) { ilExAssignment::updateStatusSentForUser($a_ass_id, $member_id, 1); } return true; }
/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd, $a_exc, $a_ass_id) { global $ilCtrl, $lng; $this->exc = $a_exc; $this->exc_id = $this->exc->getId(); $this->setId("exc_mem_" . $a_ass_id); include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $this->storage = new ilFSStorageExercise($this->exc_id, $a_ass_id); include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $this->ass_id = $a_ass_id; parent::__construct($a_parent_obj, $a_parent_cmd); $this->setTitle($lng->txt("exc_assignment") . ": " . ilExAssignment::lookupTitle($a_ass_id)); $this->setTopCommands(true); //$this->setLimit(9999); $this->type = ilExAssignment::lookupType($this->ass_id); $data = ilExAssignment::getMemberListData($this->exc_id, $this->ass_id); // team upload? (1 row == 1 team) if ($this->type == ilExAssignment::TYPE_UPLOAD_TEAM) { $ass_obj = new ilExAssignment($this->ass_id); $team_map = ilExAssignment::getAssignmentTeamMap($this->ass_id); $tmp = array(); foreach ($data as $item) { $team_id = $team_map[$item["usr_id"]]; if (!$team_id) { // #11058 // $team_id = $ass_obj->getTeamId($item["usr_id"], true); // #11957 $team_id = "nty" . $item["usr_id"]; } if (!isset($tmp[$team_id])) { $tmp[$team_id] = $item; } $tmp[$team_id]["team"][$item["usr_id"]] = $item["name"]; $tmp[$team_id]["team_id"] = $team_id; } $data = $tmp; unset($tmp); } else { // peer review / rating $ass_obj = new ilExAssignment($this->ass_id); $this->peer_review = $ass_obj->getPeerReview(); if ($this->peer_review) { include_once './Services/Rating/classes/class.ilRatingGUI.php'; } } $this->setData($data); $this->addColumn("", "", "1", true); if ($this->type != ilExAssignment::TYPE_UPLOAD_TEAM) { $this->selected = $this->getSelectedColumns(); if (in_array("image", $this->selected)) { $this->addColumn($this->lng->txt("image"), "", "1"); } $this->addColumn($this->lng->txt("name"), "name"); if (in_array("login", $this->selected)) { $this->addColumn($this->lng->txt("login"), "login"); } } else { $this->addColumn($this->lng->txt("exc_team")); } $this->sent_col = ilExAssignment::lookupAnyExerciseSent($this->exc->getId(), $this->ass_id); if ($this->sent_col) { $this->addColumn($this->lng->txt("exc_exercise_sent"), "sent_time"); } $this->addColumn($this->lng->txt("exc_submission"), "submission"); $this->addColumn($this->lng->txt("exc_grading"), "solved_time"); $this->addColumn($this->lng->txt("feedback"), "feedback_time"); $this->setDefaultOrderField("name"); $this->setDefaultOrderDirection("asc"); $this->setEnableHeader(true); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.exc_members_row.html", "Modules/Exercise"); //$this->disable("footer"); $this->setEnableTitle(true); $this->setSelectAllCheckbox("member"); $this->addMultiCommand("saveStatus", $lng->txt("exc_save_selected")); $this->addMultiCommand("redirectFeedbackMail", $lng->txt("exc_send_mail")); $this->addMultiCommand("sendMembers", $lng->txt("exc_send_assignment")); $this->addMultiCommand("confirmDeassignMembers", $lng->txt("exc_deassign_members")); $this->addCommandButton("saveStatusAll", $lng->txt("exc_save_all")); include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php"; $this->overlay_tpl = new ilTemplate("tpl.exc_learner_comment_overlay.html", true, true, "Modules/Exercise"); }