Ejemplo n.º 1
0
 /**
  * Update assignment
  *
  */
 public function updateAssignmentObject()
 {
     global $tpl, $lng, $ilCtrl, $ilTabs;
     $this->checkPermission("write");
     $ilTabs->activateTab("content");
     $this->addContentSubTabs("list_assignments");
     $this->initAssignmentForm("edit");
     if ($this->form->checkInput()) {
         include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
         $ass = new ilExAssignment($_GET["ass_id"]);
         // #14450
         $protected_peer_review_groups = false;
         if ($ass->getPeerReview() && $ass->hasPeerReviewGroups()) {
             $protected_peer_review_groups = true;
         }
         // additional checks
         $valid = true;
         if (!$protected_peer_review_groups) {
             if ($_POST["start_time_cb"] && $_POST["deadline_cb"]) {
                 // check whether start date is before end date
                 $start_date = $this->form->getItemByPostVar("start_time")->getDate();
                 $end_date = $this->form->getItemByPostVar("deadline")->getDate();
                 if ($start_date->get(IL_CAL_UNIX) >= $end_date->get(IL_CAL_UNIX)) {
                     $this->form->getItemByPostVar("start_time")->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
                     $this->form->getItemByPostVar("deadline")->setAlert($lng->txt("exc_start_date_should_be_before_end_date"));
                     $valid = false;
                 }
             }
             if (!$_POST["deadline_cb"]) {
                 if ($_POST["peer"]) {
                     $this->form->getItemByPostVar("peer")->setAlert($lng->txt("exc_needs_deadline"));
                     $valid = false;
                 }
                 if ($_POST["fb"] && $_POST["fb_date"] == ilExAssignment::FEEDBACK_DATE_DEADLINE) {
                     $this->form->getItemByPostVar("fb")->setAlert($lng->txt("exc_needs_deadline"));
                     $valid = false;
                 }
             } else {
                 if ($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM && $_POST["peer"] && $_POST["peer_dl_tgl"]) {
                     $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
                     $peer_dl = $peer_dl->get(IL_CAL_UNIX);
                     $end_date = $this->form->getItemByPostVar("deadline")->getDate();
                     $end_date = $end_date->get(IL_CAL_UNIX);
                     // #13877
                     if ($peer_dl < $end_date) {
                         $this->form->getItemByPostVar("peer_dl")->setAlert($lng->txt("exc_peer_deadline_mismatch"));
                         $valid = false;
                     }
                 }
             }
         }
         if (!$valid) {
             ilUtil::sendFailure($lng->txt("form_input_not_valid"));
             $this->form->setValuesByPost();
             $tpl->setContent($this->form->getHtml());
             return;
         }
         $ass->setTitle($_POST["title"]);
         $ass->setInstruction($_POST["instruction"]);
         $ass->setExerciseId($this->object->getId());
         $ass->setMandatory($_POST["mandatory"]);
         $ass->setType($_POST["type"]);
         if ($_POST["start_time_cb"]) {
             $date = $this->form->getItemByPostVar("start_time")->getDate();
             $ass->setStartTime($date->get(IL_CAL_UNIX));
         } else {
             $ass->setStartTime(null);
         }
         if (!$protected_peer_review_groups) {
             // deadline
             if ($_POST["deadline_cb"]) {
                 $date = $this->form->getItemByPostVar("deadline")->getDate();
                 $ass->setDeadline($date->get(IL_CAL_UNIX));
             } else {
                 $ass->setDeadline(null);
             }
             if ($_POST["type"] != ilExAssignment::TYPE_UPLOAD_TEAM) {
                 $ass->setPeerReview($_POST["peer"]);
                 $ass->setPeerReviewMin($_POST["peer_min"]);
                 $ass->setPeerReviewFileUpload($_POST["peer_file"]);
                 if ($ass->getDeadline() && $ass->getDeadline() > time()) {
                     $ass->setPeerReviewPersonalized($_POST["peer_prsl"]);
                 }
                 if ($_POST["peer_dl_tgl"]) {
                     $peer_dl = $this->form->getItemByPostVar("peer_dl")->getDate();
                     $ass->setPeerReviewDeadline($peer_dl->get(IL_CAL_UNIX));
                 } else {
                     $ass->setPeerReviewDeadline(null);
                 }
             }
         }
         if (!$_POST["fb"] || $this->form->getItemByPostVar("fb_file")->getDeletionFlag()) {
             $ass->deleteFeedbackFile();
             $ass->setFeedbackFile(null);
         } else {
             if ($_FILES["fb_file"]["tmp_name"]) {
                 $ass->handleFeedbackFileUpload($_FILES["fb_file"]);
             }
         }
         $ass->setFeedbackCron($_POST["fb"]);
         // #13380
         $ass->setFeedbackDate($_POST["fb_date"]);
         $ass->update();
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
         $ilCtrl->redirect($this, "editAssignment");
     } else {
         $this->form->setValuesByPost();
         $tpl->setContent($this->form->getHtml());
     }
 }
Ejemplo n.º 2
0
 function getExerciseInfo($a_assignment_id)
 {
     global $lng, $ilCtrl, $ilUser;
     include_once "Modules/Exercise/classes/class.ilExAssignment.php";
     $ass = new ilExAssignment($a_assignment_id);
     $exercise_id = $ass->getExerciseId();
     if (!$exercise_id) {
         return;
     }
     // is the assignment still open?
     $times_up = false;
     if ($ass->getDeadline() && $ass->getDeadline() - time() <= 0) {
         $times_up = true;
     }
     // exercise goto
     include_once "./Services/Link/classes/class.ilLink.php";
     $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
     $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
     $info = sprintf($lng->txt("blog_exercise_info"), $ass->getTitle(), "<a href=\"" . $exc_link . "\">" . ilObject::_lookupTitle($exercise_id) . "</a>");
     // submit button
     if (!$times_up) {
         $ilCtrl->setParameter($this, "exc", $exercise_id);
         $ilCtrl->setParameter($this, "ass", $a_assignment_id);
         $submit_link = $ilCtrl->getLinkTarget($this, "finalize");
         $ilCtrl->setParameter($this, "ass", "");
         $ilCtrl->setParameter($this, "exc", "");
         $info .= " <a class=\"submit emphsubmit\" href=\"" . $submit_link . "\">" . $lng->txt("blog_finalize_blog") . "</a>";
     }
     // submitted files
     $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $ilUser->getId(), true);
     if ($submitted) {
         $submitted = array_pop($submitted);
         $ilCtrl->setParameter($this, "ass", $a_assignment_id);
         $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcSubFile");
         $ilCtrl->setParameter($this, "ass", "");
         $rel = ilDatePresentation::useRelativeDates();
         ilDatePresentation::setUseRelativeDates(false);
         $info .= "<br />" . sprintf($lng->txt("blog_exercise_submitted_info"), ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME)), "<a href=\"" . $dl_link . "\" class=\"submit\">" . $lng->txt("download") . "</a>");
         ilDatePresentation::setUseRelativeDates($rel);
     }
     // work instructions incl. files
     $tooltip = "";
     $ass = $ass->getInstruction();
     if ($ass) {
         $tooltip .= nl2br($ass);
     }
     $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id);
     if (count($ass_files) > 0) {
         $tooltip .= "<br /><br />";
         foreach ($ass_files as $file) {
             $ilCtrl->setParameter($this, "ass", $a_assignment_id);
             $ilCtrl->setParameter($this, "file", urlencode($file["name"]));
             $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcAssFile");
             $ilCtrl->setParameter($this, "file", "");
             $ilCtrl->setParameter($this, "ass", "");
             $tooltip .= $file["name"] . ": <a href=\"" . $dl_link . "\">" . $lng->txt("download") . "</a>";
         }
     }
     if ($tooltip) {
         $ol_id = "exc_ass_" . $a_assignment_id;
         include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $overlay = new ilOverlayGUI($ol_id);
         // overlay
         $overlay->setAnchor($ol_id . "_tr");
         $overlay->setTrigger($ol_id . "_tr", "click", $ol_id . "_tr");
         $overlay->add();
         $info .= "<div id=\"" . $ol_id . "_tr\"><a href=\"#\">" . $lng->txt("exc_instruction") . "</a></div>" . "<div id=\"" . $ol_id . "\" style=\"display:none; padding:10px;\" class=\"ilOverlay\">" . $tooltip . "</div>";
     }
     return "<div>" . $info . "</div>";
 }
 /**
  * Get current values for assignment from 
  *
  */
 public function getAssignmentValues()
 {
     $values = array();
     $ass = new ilExAssignment($_GET["ass_id"]);
     $values["title"] = $ass->getTitle();
     if ($ass->getStartTime() > 0) {
         $values["start_time_cb"] = true;
     }
     $values["mandatory"] = $ass->getMandatory();
     $values["instruction"] = $ass->getInstruction();
     $values["type"] = $ass->getType();
     if ($ass->getDeadline() > 0) {
         $values["deadline_cb"] = true;
     }
     $this->form->setValuesByArray($values);
     if ($ass->getDeadline() > 0) {
         $edit_date = new ilDateTime($ass->getDeadline(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("deadline");
         $ed_item->setDate($edit_date);
     }
     if ($ass->getStartTime() > 0) {
         $edit_date = new ilDateTime($ass->getStartTime(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("start_time");
         $ed_item->setDate($edit_date);
     }
     // if there are any submissions we cannot change type anymore
     if (sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $ass->getId()))) {
         $this->form->getItemByPostVar("type")->setDisabled(true);
     }
 }
 function __formatBody($a_ass_id)
 {
     global $lng;
     $lng->loadLanguageModule("exc");
     include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
     $ass = new ilExAssignment($a_ass_id);
     $body = $ass->getInstruction();
     $body .= "\n\n";
     if ($ass->getDeadline() == 0) {
         $body .= $lng->txt("exc_edit_until") . ": " . $lng->txt("exc_no_deadline_specified");
     } else {
         $body .= $lng->txt("exc_edit_until") . ": " . ilFormat::formatDate(date("Y-m-d H:i:s", $ass->getDeadline()), "datetime", true);
     }
     $body .= "\n\n";
     $body .= ILIAS_HTTP_PATH . "/goto.php?target=" . $this->getType() . "_" . $this->getRefId() . "&client_id=" . CLIENT_ID;
     return $body;
 }
Ejemplo n.º 5
0
 function getExerciseInfo($a_assignment_id, $a_add_submit = false)
 {
     include_once "Modules/Exercise/classes/class.ilExAssignment.php";
     $ass = new ilExAssignment($a_assignment_id);
     $exercise_id = $ass->getExerciseId();
     if (!$exercise_id) {
         return;
     }
     // is the assignment still open?
     $times_up = false;
     if ($ass->getDeadline() && $ass->getDeadline() - time() <= 0) {
         $times_up = true;
     }
     // exercise goto
     include_once "./Services/Link/classes/class.ilLink.php";
     $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
     $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
     $info = sprintf($this->lng->txt("prtf_exercise_info"), $ass->getTitle(), "<a href=\"" . $exc_link . "\">" . ilObject::_lookupTitle($exercise_id) . "</a>");
     // submit button
     if ($a_add_submit && !$times_up) {
         $this->ctrl->setParameter($this, "exc", $exercise_id);
         $this->ctrl->setParameter($this, "ass", $a_assignment_id);
         $submit_link = $this->ctrl->getLinkTarget($this, "finalize");
         $this->ctrl->setParameter($this, "ass", "");
         $this->ctrl->setParameter($this, "exc", "");
         include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
         $button = ilLinkButton::getInstance();
         $button->setCaption("prtf_finalize_portfolio");
         $button->setPrimary(true);
         $button->setUrl($submit_link);
         $info .= " " . $button->render();
     }
     // submitted files
     $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $this->user_id, true);
     if ($submitted) {
         $submitted = array_pop($submitted);
         $this->ctrl->setParameter($this, "ass", $a_assignment_id);
         $dl_link = $this->ctrl->getLinkTarget($this, "downloadExcSubFile");
         $this->ctrl->setParameter($this, "ass", "");
         $rel = ilDatePresentation::useRelativeDates();
         ilDatePresentation::setUseRelativeDates(false);
         include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
         $button = ilLinkButton::getInstance();
         $button->setCaption("download");
         $button->setUrl($dl_link);
         $info .= "<br />" . sprintf($this->lng->txt("prtf_exercise_submitted_info"), ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME)), $button->render());
         ilDatePresentation::setUseRelativeDates($rel);
     }
     // work instructions incl. files
     $tooltip = "";
     $ass = $ass->getInstruction();
     if ($ass) {
         $tooltip .= nl2br($ass);
     }
     $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id);
     if (count($ass_files) > 0) {
         $tooltip .= "<br /><br />";
         foreach ($ass_files as $file) {
             $this->ctrl->setParameter($this, "ass", $a_assignment_id);
             $this->ctrl->setParameter($this, "file", urlencode($file["name"]));
             $dl_link = $this->ctrl->getLinkTarget($this, "downloadExcAssFile");
             $this->ctrl->setParameter($this, "file", "");
             $this->ctrl->setParameter($this, "ass", "");
             $tooltip .= $file["name"] . ": <a href=\"" . $dl_link . "\">" . $this->lng->txt("download") . "</a>";
         }
     }
     if ($tooltip) {
         $ol_id = "exc_ass_" . $a_assignment_id;
         include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $overlay = new ilOverlayGUI($ol_id);
         // overlay
         $overlay->setAnchor($ol_id . "_tr");
         $overlay->setTrigger($ol_id . "_tr", "click", $ol_id . "_tr");
         $overlay->setAutoHide(false);
         // $overlay->setCloseElementId($cl_id);
         $overlay->add();
         // trigger
         $overlay->addTrigger($ol_id . "_tr", "click", $ol_id . "_tr");
         $info .= "<div id=\"" . $ol_id . "_tr\"><a href=\"#\">" . $this->lng->txt("exc_instruction") . "</a></div>" . "<div id=\"" . $ol_id . "\" style=\"display:none; background-color:white; border: 1px solid #bbb; padding: 10px;\">" . $tooltip . "</div>";
     }
     return $info;
 }
 /**
  * Get current values for assignment from 
  *
  */
 public function getAssignmentValues()
 {
     $values = array();
     $ass = new ilExAssignment($_GET["ass_id"]);
     $values["title"] = $ass->getTitle();
     if ($ass->getStartTime() > 0) {
         $values["start_time_cb"] = true;
     }
     $values["mandatory"] = $ass->getMandatory();
     $values["instruction"] = $ass->getInstruction();
     $values["type"] = $ass->getType();
     if ($ass->getDeadline() > 0) {
         $values["deadline_cb"] = true;
     }
     if ($this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
         $this->form->removeItemByPostVar("peer");
         $this->form->removeItemByPostVar("peer_min");
         $this->form->removeItemByPostVar("peer_dl");
     } else {
         $values["peer"] = $ass->getPeerReview();
         $values["peer_min"] = $ass->getPeerReviewMin();
         if ($ass->getPeerReviewDeadline() > 0) {
             $values["peer_dl_tgl"] = true;
             $peer_dl_date = new ilDateTime($ass->getPeerReviewDeadline(), IL_CAL_UNIX);
             $peer_dl = $this->form->getItemByPostVar("peer_dl");
             $peer_dl->setDate($peer_dl_date);
         }
     }
     $this->form->setValuesByArray($values);
     if ($ass->getDeadline() > 0) {
         $edit_date = new ilDateTime($ass->getDeadline(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("deadline");
         $ed_item->setDate($edit_date);
     }
     if ($ass->getStartTime() > 0) {
         $edit_date = new ilDateTime($ass->getStartTime(), IL_CAL_UNIX);
         $ed_item = $this->form->getItemByPostVar("start_time");
         $ed_item->setDate($edit_date);
     }
     if ($ass->getFeedbackFile()) {
         $this->form->getItemByPostVar("fb")->setChecked(true);
         $this->form->getItemByPostVar("fb_cron")->setChecked($ass->hasFeedbackCron());
         $this->form->getItemByPostVar("fb_file")->setValue(basename($ass->getFeedbackFilePath()));
     }
     // if there are any submissions we cannot change type anymore
     if (sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $ass->getId())) || $this->ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) {
         $this->form->getItemByPostVar("type")->setDisabled(true);
     }
 }