/**
  * Get all completed tests
  */
 protected function getItems()
 {
     global $ilUser, $tree;
     $data = array();
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (ilCertificate::isActive()) {
         $obj_ids = array();
         $root = $tree->getNodeData($tree->getRootId());
         foreach ($tree->getSubTree($root, true, "sahs") as $node) {
             $obj_ids[] = $node["obj_id"];
         }
         if ($obj_ids) {
             include_once "./Services/Tracking/classes/class.ilObjUserTracking.php";
             include_once "./Services/Tracking/classes/class.ilLPStatus.php";
             include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
             include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
             include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
             include_once "./Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php";
             $lp_active = ilObjUserTracking::_enabledLearningProgress();
             foreach (ilCertificate::areObjectsActive($obj_ids) as $obj_id => $active) {
                 if ($active) {
                     $type = ilObjSAHSLearningModule::_lookupSubType($obj_id);
                     if ($type == "scorm") {
                         $lm = new ilObjSCORMLearningModule($obj_id, false);
                     } else {
                         $lm = new ilObjSCORM2004LearningModule($obj_id, false);
                     }
                     $adapter = new ilSCORMCertificateAdapter($lm);
                     if (ilCertificate::_isComplete($adapter)) {
                         $lpdata = $completed = false;
                         if ($lp_active) {
                             $completed = ilLPStatus::_hasUserCompleted($obj_id, $ilUser->getId());
                             $lpdata = true;
                         }
                         if (!$lpdata) {
                             switch ($type) {
                                 case "scorm":
                                     $completed = ilObjSCORMLearningModule::_getCourseCompletionForUser($obj_id, $ilUser->getId());
                                     break;
                                 case "scorm2004":
                                     $completed = ilObjSCORM2004LearningModule::_getCourseCompletionForUser($obj_id, $ilUser->getId());
                                     break;
                             }
                         }
                         $data[] = array("id" => $obj_id, "title" => ilObject::_lookupTitle($obj_id), "passed" => (bool) $completed);
                     }
                 }
             }
         }
     }
     $this->setData($data);
 }
 /**
  * Get all completed tests
  */
 protected function getItems()
 {
     global $ilUser;
     include_once "Modules/Exercise/classes/class.ilObjExercise.php";
     $data = array();
     foreach (ilObjExercise::_lookupFinishedUserExercises($ilUser->getId()) as $exercise_id => $passed) {
         // #11210 - only available certificates!
         $exc = new ilObjExercise($exercise_id, false);
         if ($exc->hasUserCertificate($ilUser->getId())) {
             $adapter = new ilExerciseCertificateAdapter($exc);
             if (ilCertificate::_isComplete($adapter)) {
                 $data[] = array("id" => $exercise_id, "title" => ilObject::_lookupTitle($exercise_id), "passed" => $passed);
             }
         }
     }
     $this->setData($data);
 }
 /**
  * Get all completed tests
  */
 protected function getItems()
 {
     global $ilUser;
     $data = array();
     include_once "Modules/Course/classes/class.ilObjCourse.php";
     include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
     $obj_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), "crs");
     if ($obj_ids) {
         include_once "./Services/Certificate/classes/class.ilCertificate.php";
         include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
         ilCourseCertificateAdapter::_preloadListData($ilUser->getId(), $obj_ids);
         foreach ($obj_ids as $crs_id) {
             // #11210 - only available certificates!
             if (ilCourseCertificateAdapter::_hasUserCertificate($ilUser->getId(), $crs_id)) {
                 $crs = new ilObjCourse($crs_id, false);
                 $adapter = new ilCourseCertificateAdapter($crs);
                 if (ilCertificate::_isComplete($adapter)) {
                     $data[] = array("id" => $crs_id, "title" => ilObject::_lookupTitle($crs_id), "passed" => true);
                 }
             }
         }
     }
     $this->setData($data);
 }
Beispiel #4
0
 function getSettingsSubTabs($hiddenTabs = array())
 {
     /**
      * @var $ilTabs ilTabsGUI
      */
     global $ilTabs, $ilias;
     // general subtab
     $ilTabs->addSubTabTarget('general', $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'), '', array('ilobjtestsettingsgeneralgui'));
     if (!in_array('mark_schema', $hiddenTabs)) {
         $ilTabs->addSubTabTarget('mark_schema', $this->ctrl->getLinkTargetByClass('ilmarkschemagui', 'showMarkSchema'), '', array('ilmarkschemagui'));
     }
     // scoring subtab
     $ilTabs->addSubTabTarget('scoring', $this->ctrl->getLinkTargetByClass('ilObjTestSettingsScoringResultsGUI'), '', array('ilobjtestsettingsscoringresultsgui'));
     // certificate subtab
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (!in_array('certificate', $hiddenTabs) && ilCertificate::isActive()) {
         $ilTabs->addSubTabTarget("certificate", $this->ctrl->getLinkTarget($this, 'certificate'), array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"), array("", "ilobjtestgui", "ilcertificategui"));
     }
     if (!in_array('defaults', $hiddenTabs)) {
         // defaults subtab
         $ilTabs->addSubTabTarget("tst_default_settings", $this->ctrl->getLinkTarget($this, "defaults"), array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"), array("", "ilobjtestgui", "ilcertificategui"));
     }
 }
 /**
  * Check if given user has certificate to show/download
  * 
  * @param int $a_user_id
  * @return bool 
  */
 function hasUserCertificate($a_user_id)
 {
     // show certificate?
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (ilCertificate::isActive() && ilCertificate::isObjectActive($this->getId())) {
         $certificate_visible = $this->getCertificateVisibility();
         // if not never
         if ($certificate_visible != 2) {
             // if passed only
             include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
             $status = ilExerciseMembers::_lookupStatus($this->getId(), $a_user_id);
             if ($certificate_visible == 1 && $status == "passed") {
                 return true;
             } else {
                 if ($certificate_visible == 0 && $status != "notgraded") {
                     return true;
                 }
             }
         }
     }
     return false;
 }
 /**
  * Download the certificate for the active user
  */
 public function downloadCertificate()
 {
     global $ilUser, $tree, $ilCtrl;
     $allowed = false;
     $last_access = 0;
     $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
     if (ilObjSAHSLearningModuleAccess::_lookupUserCertificate($obj_id)) {
         include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
         $type = ilObjSAHSLearningModule::_lookupSubType($obj_id);
         switch ($type) {
             case "scorm":
                 include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
                 $allowed = true;
                 $last_access = ilObjSCORMLearningModule::_lookupLastAccess($obj_id, $ilUser->getId());
                 break;
             case "scorm2004":
                 include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
                 $allowed = true;
                 $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($obj_id, $ilUser->getId());
                 break;
             default:
                 break;
         }
     }
     if ($allowed) {
         include_once "./Services/Certificate/classes/class.ilCertificate.php";
         include_once "./Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php";
         $certificate = new ilCertificate(new ilSCORMCertificateAdapter($this->slm));
         $params = array("user_data" => ilObjUser::_lookupFields($ilUser->getId()), "last_access" => $last_access);
         $certificate->outCertificate($params, true);
         exit;
     }
     // redirect to parent category if certificate is not accessible
     $parent = $tree->getParentId($_GET["ref_id"]);
     $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent);
     $ilCtrl->redirectByClass("ilrepositorygui", "");
 }
 /**
  * Checks whether a certificate exists for the active user or not
  * @param int obj_id Object ID of the SCORM Learning Module
  * @param int usr_id Object ID of the user. If not given, the active user will be taken
  * @return true/false
  */
 public static function _lookupUserCertificate($obj_id, $usr_id = 0)
 {
     global $ilUser;
     $uid = $usr_id ? $usr_id : $ilUser->getId();
     $completed = false;
     // check for certificates
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     if (ilCertificate::isActive() && ilCertificate::isObjectActive($obj_id)) {
         $lpdata = false;
         include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
         $type = ilObjSAHSLearningModule::_lookupSubType($obj_id);
         include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
         if (ilObjUserTracking::_enabledLearningProgress()) {
             include_once "./Services/Tracking/classes/class.ilLPStatus.php";
             $completed = ilLPStatus::_hasUserCompleted($obj_id, $uid);
             $lpdata = true;
         }
         switch ($type) {
             case "scorm":
                 if (!$lpdata) {
                     include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
                     $completed = ilObjSCORMLearningModule::_getCourseCompletionForUser($obj_id, $uid);
                 }
                 break;
             case "scorm2004":
                 if (!$lpdata) {
                     include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
                     $completed = ilObjSCORM2004LearningModule::_getCourseCompletionForUser($obj_id, $uid);
                 }
                 break;
             default:
                 break;
         }
     }
     return $completed;
 }
 /**
  * Output of a test certificate
  */
 public function outCertificate()
 {
     global $ilUser;
     $active_id = $this->object->getTestSession()->getActiveId();
     $counted_pass = ilObjTest::_getResultPass($active_id);
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
     $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
     $certificate->outCertificate(array("active_id" => $active_id, "pass" => $counted_pass));
 }
 function outCertificateObject()
 {
     global $ilUser;
     if ($this->object->hasUserCertificate($ilUser->getId())) {
         ilUtil::sendFailure($this->lng->txt("msg_failed"));
         $this->showOverviewObject();
     }
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     include_once "./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
     $certificate = new ilCertificate(new ilExerciseCertificateAdapter($this->object));
     $certificate->outCertificate(array("user_id" => $ilUser->getId()));
 }
 /**
  * adds tabs to tab gui object
  *
  * @param	object		$tabs_gui		ilTabsGUI object
  */
 function getTabs(&$tabs_gui)
 {
     global $rbacsystem, $ilUser, $ilCtrl, $ilHelp;
     if ($this->ctrl->getCmd() == "delete") {
         return;
     }
     switch ($this->object->getSubType()) {
         case "scorm2004":
             $ilHelp->setScreenIdComponent("sahs13");
             break;
         case "scorm":
             $ilHelp->setScreenIdComponent("sahs12");
             break;
     }
     // file system gui tabs
     // properties
     $ilCtrl->setParameterByClass("ilfilesystemgui", "resetoffset", 1);
     $tabs_gui->addTarget("cont_list_files", $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"), "", "ilfilesystemgui");
     $ilCtrl->setParameterByClass("ilfilesystemgui", "resetoffset", "");
     // info screen
     $force_active = $this->ctrl->getNextClass() == "ilinfoscreengui" ? true : false;
     $tabs_gui->addTarget("info_short", $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "", "ilinfoscreengui", "", $force_active);
     // properties
     $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, "properties"), array("", "properties"), get_class($this));
     // learning progress
     include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
     if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
         $tabs_gui->addTarget('learning_progress', $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'), ''), '', array('illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui'));
     }
     include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     $privacy = ilPrivacySettings::_getInstance();
     if ($privacy->enabledSahsProtocolData()) {
         // tracking data
         $tabs_gui->addTarget("cont_tracking_data", $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems", get_class($this));
     }
     // certificate subtab
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (ilCertificate::isActive()) {
         // create and insert object in objecttree
         switch ($this->object->getSubType()) {
             case "scorm2004":
             case "scorm":
                 // certificate
                 $tabs_gui->addTarget("certificate", $this->ctrl->getLinkTarget($this, "certificate"), array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"));
                 break;
         }
     }
     include_once "Services/License/classes/class.ilLicenseAccess.php";
     if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId()) and ilLicenseAccess::_isEnabled()) {
         $tabs_gui->addTarget("license", $this->ctrl->getLinkTargetByClass('illicensegui', ''), "", "illicensegui");
     }
     // edit meta
     $tabs_gui->addTarget("meta_data", $this->ctrl->getLinkTargetByClass('ilmdeditorgui', ''), "", "ilmdeditorgui");
     // perm
     if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
         $tabs_gui->addTarget("perm_settings", $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), "perm"), array("perm", "info", "owner"), 'ilpermissiongui');
     }
 }
 /**
  * Output of a test certificate
  */
 public function outCertificate()
 {
     $testSession = $this->testSessionFactory->getSession();
     require_once './Services/Certificate/classes/class.ilCertificate.php';
     require_once './Modules/Test/classes/class.ilTestCertificateAdapter.php';
     $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
     $certificate->outCertificate(array("active_id" => $testSession->getActiveId(), "pass" => ilObjTest::_getResultPass($testSession->getActiveId())));
 }
Beispiel #12
0
 // please migrate to default branch implementation
 case 'icrs':
     require_once 'Modules/ILinc/classes/class.ilObjiLincCourseGUI.php';
     ilObjiLincCourseGUI::_goto($target_id);
     break;
     // please migrate to default branch implementation
 // please migrate to default branch implementation
 case 'root':
     require_once './Modules/RootFolder/classes/class.ilObjRootFolderGUI.php';
     ilObjRootFolderGUI::_goto($target_id);
     break;
     // please migrate to default branch implementation
 // please migrate to default branch implementation
 case 'cert':
     require_once './Services/Certificate/classes/class.ilCertificate.php';
     ilCertificate::_goto($target_id);
     break;
     //
     // default implementation (should be used by all new object types)
     //
 //
 // default implementation (should be used by all new object types)
 //
 default:
     if (!$objDefinition->isPlugin($target_type)) {
         $class_name = "ilObj" . $objDefinition->getClassName($target_type) . "GUI";
         $location = $objDefinition->getLocation($target_type);
         if (is_file($location . "/class." . $class_name . ".php")) {
             include_once $location . "/class." . $class_name . ".php";
             call_user_func(array($class_name, "_goto"), $rest);
         }
 function getSettingsSubTabs($hiddenTabs = array())
 {
     global $ilTabs, $ilias;
     // general subtab
     $force_active = $this->ctrl->getCmd() == "" ? true : false;
     $ilTabs->addSubTabTarget("general", $this->ctrl->getLinkTarget($this, 'properties'), array("properties", "saveProperties", "cancelProperties"), array("", "ilobjtestgui", "ilcertificategui"), "", $force_active);
     if (!in_array('mark_schema', $hiddenTabs)) {
         // mark schema subtab
         $ilTabs->addSubTabTarget("mark_schema", $this->ctrl->getLinkTarget($this, 'marks'), array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema", "saveMarks", "cancelMarks"), array("", "ilobjtestgui", "ilcertificategui"));
     }
     // scoring subtab
     $ilTabs->addSubTabTarget("scoring", $this->ctrl->getLinkTarget($this, 'scoring'), array("scoring"), array("", "ilobjtestgui", "ilcertificategui"));
     // certificate subtab
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (ilCertificate::isActive()) {
         $ilTabs->addSubTabTarget("certificate", $this->ctrl->getLinkTarget($this, 'certificate'), array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"), array("", "ilobjtestgui", "ilcertificategui"));
     }
     if (!in_array('defaults', $hiddenTabs)) {
         // defaults subtab
         $ilTabs->addSubTabTarget("tst_default_settings", $this->ctrl->getLinkTarget($this, "defaults"), array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"), array("", "ilobjtestgui", "ilcertificategui"));
     }
 }
 /**
  * Get certificate/passed status for all given objects and users
  * 
  * Used in ilObjCourseAccess for ilObjCourseListGUI 
  * 
  * @param array $a_usr_ids
  * @param array $a_obj_ids 
  */
 static function _preloadListData($a_usr_ids, $a_obj_ids)
 {
     global $ilDB;
     if (!is_array($a_usr_ids)) {
         $a_usr_ids = array($a_usr_ids);
     }
     if (!is_array($a_obj_ids)) {
         $a_obj_ids = array($a_obj_ids);
     }
     foreach ($a_usr_ids as $usr_id) {
         foreach ($a_obj_ids as $obj_id) {
             self::$has_certificate[$usr_id][$obj_id] = false;
         }
     }
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (ilCertificate::isActive()) {
         $obj_active = ilCertificate::areObjectsActive($a_obj_ids);
         include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
         $data = ilCourseParticipants::getPassedUsersForObjects($a_obj_ids, $a_usr_ids);
         foreach ($data as $rec) {
             if ($obj_active[$rec["obj_id"]]) {
                 self::$has_certificate[$rec["usr_id"]][$rec["obj_id"]] = true;
             }
         }
     }
 }
 /**
  * Constructor
  *
  * @access public
  * @param
  * @return
  */
 public function __construct($a_parent_obj, $a_type = 'admin', $show_content = true, $a_show_learning_progress = false, $a_show_timings = false, $a_show_edit_link = true, $a_role_id = 0, $a_show_lp_status_sync = false)
 {
     global $lng, $ilCtrl;
     $this->show_learning_progress = $a_show_learning_progress;
     $this->show_timings = $a_show_timings;
     $this->show_edit_link = $a_show_edit_link;
     $this->show_lp_status_sync = $a_show_lp_status_sync;
     // #13208
     include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
     if (!ilObjUserTracking::_enabledLearningProgress()) {
         $this->show_lp_status_sync = false;
     }
     $this->lng = $lng;
     $this->lng->loadLanguageModule('crs');
     $this->lng->loadLanguageModule('trac');
     $this->ctrl = $ilCtrl;
     $this->type = $a_type;
     $this->setRoleId($a_role_id);
     include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     $this->privacy = ilPrivacySettings::_getInstance();
     // required before constructor for columns
     $this->setId('crs_' . $a_type . '_' . $a_role_id . '_' . $a_parent_obj->object->getId());
     parent::__construct($a_parent_obj, 'members');
     $this->initSettings();
     $this->setFormName('participants');
     $this->addColumn('', 'f', "1");
     $this->addColumn($this->lng->txt('name'), 'lastname', '20%');
     $all_cols = $this->getSelectableColumns();
     foreach ($this->getSelectedColumns() as $col) {
         $this->addColumn($all_cols[$col]['txt'], $col);
     }
     if ($this->show_learning_progress) {
         $this->addColumn($this->lng->txt('learning_progress'), 'progress');
     }
     if ($this->privacy->enabledCourseAccessTimes()) {
         $this->addColumn($this->lng->txt('last_access'), 'access_ut', '16em');
     }
     $this->addColumn($this->lng->txt('crs_member_passed'), 'passed');
     if ($this->show_lp_status_sync) {
         $this->addColumn($this->lng->txt('crs_member_passed_status_changed'), 'passed_info');
     }
     if ($this->type == 'admin') {
         $this->setSelectAllCheckbox('admins');
         $this->addColumn($this->lng->txt('crs_notification_list_title'), 'notification');
         $this->addCommandButton('updateAdminStatus', $this->lng->txt('save'));
     } elseif ($this->type == 'tutor') {
         $this->setSelectAllCheckbox('tutors');
         $this->addColumn($this->lng->txt('crs_notification_list_title'), 'notification');
         $this->addCommandButton('updateTutorStatus', $this->lng->txt('save'));
     } elseif ($this->type == 'member') {
         $this->setSelectAllCheckbox('members');
         $this->addColumn($this->lng->txt('crs_blocked'), 'blocked');
         $this->addCommandButton('updateMemberStatus', $this->lng->txt('save'));
     } else {
         $this->setSelectAllCheckbox('roles');
         $this->addColumn($this->lng->txt('crs_blocked'), 'blocked');
         $this->addCommandButton('updateRoleStatus', $this->lng->txt('save'));
     }
     $this->addColumn($this->lng->txt(''), 'optional');
     $this->setRowTemplate("tpl.show_participants_row.html", "Modules/Course");
     if ($show_content) {
         $this->setDefaultOrderField('lastname');
         $this->enable('sort');
         $this->enable('header');
         $this->enable('numinfo');
         $this->enable('select_all');
     } else {
         $this->disable('content');
         $this->disable('header');
         $this->disable('footer');
         $this->disable('numinfo');
         $this->disable('select_all');
     }
     $this->setEnableNumInfo(true);
     $this->setExternalSegmentation(true);
     $this->getItems();
     $this->setTopCommands(true);
     $this->setEnableHeader(true);
     $this->setEnableTitle(true);
     $this->initFilter();
     $this->setShowRowsSelector(true);
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     $this->enable_certificates = ilCertificate::isActive();
     if ($this->enable_certificates) {
         $this->enable_certificates = ilCertificate::isObjectActive($a_parent_obj->object->getId());
     }
     if ($this->enable_certificates) {
         $lng->loadLanguageModule('certificate');
     }
 }
 /**
  * Shows the certificate editor for ILIAS tests
  */
 public function certificateEditor()
 {
     global $ilAccess;
     $form_fields = array();
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $form_fields = $this->getFormFieldsFromPOST();
     } else {
         $form_fields = $this->getFormFieldsFromFO();
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setPreventDoubleSubmission(false);
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt("certificate_edit"));
     $form->setMultipart(TRUE);
     $form->setTableWidth("100%");
     $form->setId("certificate");
     $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
     $active->setChecked($form_fields["active"]);
     $form->addItem($active);
     $import = new ilFileInputGUI($this->lng->txt("import"), "certificate_import");
     $import->setRequired(FALSE);
     $import->setSuffixes(array("zip"));
     // handle the certificate import
     if (strlen($_FILES["certificate_import"]["tmp_name"])) {
         if ($import->checkInput()) {
             $result = $this->object->importCertificate($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
             if ($result == FALSE) {
                 $import->setAlert($this->lng->txt("certificate_error_import"));
             } else {
                 $this->ctrl->redirect($this, "certificateEditor");
             }
         }
     }
     $form->addItem($import);
     $pageformat = new ilRadioGroupInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
     $pageformats = $this->object->getPageFormats();
     $pageformat->setValue($form_fields["pageformat"]);
     foreach ($pageformats as $format) {
         $option = new ilRadioOption($format["name"], $format["value"]);
         if (strcmp($format["value"], "custom") == 0) {
             $pageheight = new ilTextInputGUI($this->lng->txt("certificate_pageheight"), "pageheight");
             $pageheight->setValue($form_fields["pageheight"]);
             $pageheight->setSize(6);
             $pageheight->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
             $pageheight->setInfo($this->lng->txt("certificate_unit_description"));
             $pageheight->setRequired(true);
             $option->addSubitem($pageheight);
             $pagewidth = new ilTextInputGUI($this->lng->txt("certificate_pagewidth"), "pagewidth");
             $pagewidth->setValue($form_fields["pagewidth"]);
             $pagewidth->setSize(6);
             $pagewidth->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
             $pagewidth->setInfo($this->lng->txt("certificate_unit_description"));
             $pagewidth->setRequired(true);
             $option->addSubitem($pagewidth);
         }
         $pageformat->addOption($option);
     }
     $pageformat->setRequired(true);
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $pageformat->checkInput();
     }
     $form->addItem($pageformat);
     $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
     $bgimage->setRequired(FALSE);
     $bgimage->setUseCache(false);
     if (count($_POST)) {
         // handle the background upload
         if (strlen($_FILES["background"]["tmp_name"])) {
             if ($bgimage->checkInput()) {
                 $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
                 if ($result == FALSE) {
                     $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
                 }
             }
         }
     }
     if (!$this->object->hasBackgroundImage()) {
         include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
         if (ilObjCertificateSettingsAccess::hasBackgroundImage()) {
             $bgimage->setImage(ilObjCertificateSettingsAccess::getBackgroundImageThumbPathWeb());
         }
     } else {
         $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
     }
     $form->addItem($bgimage);
     $padding_top = new ilTextInputGUI($this->lng->txt("certificate_padding_top"), "padding_top");
     $padding_top->setRequired(TRUE);
     $padding_top->setValue($form_fields["padding_top"]);
     $padding_top->setSize(6);
     $padding_top->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
     $padding_top->setInfo($this->lng->txt("certificate_unit_description"));
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $padding_top->checkInput();
     }
     $form->addItem($padding_top);
     $rect = new ilCSSRectInputGUI($this->lng->txt("certificate_margin_body"), "margin_body");
     $rect->setRequired(TRUE);
     $rect->setUseUnits(TRUE);
     $rect->setTop($form_fields["margin_body_top"]);
     $rect->setBottom($form_fields["margin_body_bottom"]);
     $rect->setLeft($form_fields["margin_body_left"]);
     $rect->setRight($form_fields["margin_body_right"]);
     $rect->setInfo($this->lng->txt("certificate_unit_description"));
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $rect->checkInput();
     }
     $form->addItem($rect);
     $certificate = new ilTextAreaInputGUI($this->lng->txt("certificate_text"), "certificate_text");
     $certificate->removePlugin('ilimgupload');
     $certificate->setValue($form_fields["certificate_text"]);
     $certificate->setRequired(TRUE);
     $certificate->setRows(20);
     $certificate->setCols(80);
     // fraunhpatch start
     $common_desc_tpl = new ilTemplate("tpl.common_desc.html", true, true, "Services/Certificate");
     foreach (ilCertificate::getCustomCertificateFields() as $f) {
         $common_desc_tpl->setCurrentBlock("cert_field");
         $common_desc_tpl->setVariable("PH", $f["ph"]);
         $common_desc_tpl->setVariable("PH_TXT", $f["name"]);
         $common_desc_tpl->parseCurrentBlock();
     }
     $common_desc = $common_desc_tpl->get();
     // fraunhpatch start
     $certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription() . $common_desc);
     $certificate->setUseRte(TRUE, '3.4.7');
     $tags = array("br", "em", "font", "li", "ol", "p", "span", "strong", "u", "ul");
     $certificate->setRteTags($tags);
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $certificate->checkInput();
     }
     $form->addItem($certificate);
     $this->object->getAdapter()->addAdditionalFormElements($form, $form_fields);
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         if ($this->object->isComplete() || $this->object->hasBackgroundImage()) {
             $form->addCommandButton("certificatePreview", $this->lng->txt("certificate_preview"));
             $form->addCommandButton("certificateExportFO", $this->lng->txt("certificate_export"));
             $form->addCommandButton("certificateDelete", $this->lng->txt("delete"));
         }
         $form->addCommandButton("certificateSave", $this->lng->txt("save"));
     }
     $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         if ($_POST["background_delete"]) {
             $this->object->deleteBackgroundImage();
         }
         if ($form->checkInput()) {
             try {
                 $xslfo = $this->object->processXHTML2FO($form_fields);
                 $this->object->getAdapter()->saveFormFields($form_fields);
                 $this->object->saveCertificate($xslfo);
                 $this->object->writeActive($form_fields["active"]);
                 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), TRUE);
                 $this->ctrl->redirect($this, "certificateEditor");
             } catch (Exception $e) {
                 ilUtil::sendFailure($e->getMessage());
             }
         }
     }
 }
Beispiel #17
0
 function deliverCertificateObject()
 {
     global $ilUser, $ilAccess;
     $user_id = null;
     if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
         $user_id = $_REQUEST["member_id"];
     }
     if (!$user_id) {
         $user_id = $ilUser->getId();
     }
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (!ilCertificate::isActive() || !ilCertificate::isObjectActive($this->object->getId()) || !ilCourseParticipants::getDateTimeOfPassed($this->object->getId(), $user_id)) {
         ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
         $this->ctrl->redirect($this);
     }
     include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
     $certificate = new ilCertificate(new ilCourseCertificateAdapter($this->object));
     $certificate->outCertificate(array("user_id" => $user_id), true);
 }
Beispiel #18
0
 /**
  * Checks whether the certificate button could be shown on the info page or not
  *
  * @access public
  */
 function canShowCertificate($testSession, $user_id, $active_id)
 {
     if ($this->canShowTestResults($testSession)) {
         include_once "./Services/Certificate/classes/class.ilCertificate.php";
         include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
         $cert = new ilCertificate(new ilTestCertificateAdapter($this));
         if ($cert->isComplete()) {
             $vis = $this->getCertificateVisibility();
             $showcert = FALSE;
             switch ($vis) {
                 case 0:
                     $showcert = TRUE;
                     break;
                 case 1:
                     if ($this->getPassed($active_id)) {
                         $showcert = TRUE;
                     }
                     break;
                 case 2:
                     $showcert = FALSE;
                     break;
             }
             if ($showcert) {
                 return TRUE;
             } else {
                 return FALSE;
             }
         } else {
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }
 public static function isActive()
 {
     if (self::$is_active === null) {
         // basic admin setting active?
         $certificate_active = new ilSetting("certificate");
         $certificate_active = (bool) $certificate_active->get("active");
         // java/rtpc-server active?
         if ($certificate_active) {
             include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
             $certificate_active = ilRPCServerSettings::getInstance()->isEnabled();
         }
         self::$is_active = (bool) $certificate_active;
     }
     return self::$is_active;
 }
Beispiel #20
0
 /**
  * Clone course (no member data)
  *
  * @access public
  * @param int target ref_id
  * @param int copy id
  * 
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneAutoGeneratedRoles($new_obj);
     $this->cloneMetaData($new_obj);
     // Assign admin
     $new_obj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN);
     // #14596
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     if ($cwo->isRootNode($this->getRefId())) {
         $this->setOfflineStatus(true);
     }
     // Copy settings
     $this->cloneSettings($new_obj);
     // Course Defined Fields
     include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
     ilCourseDefinedFieldDefinition::_clone($this->getId(), $new_obj->getId());
     // Clone course files
     include_once 'Modules/Course/classes/class.ilCourseFile.php';
     ilCourseFile::_cloneFiles($this->getId(), $new_obj->getId());
     // Copy learning progress settings
     include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
     $obj_settings = new ilLPObjSettings($this->getId());
     $obj_settings->cloneSettings($new_obj->getId());
     unset($obj_settings);
     // clone icons
     global $ilLog;
     $ilLog->write(__METHOD__ . ': ' . $this->getBigIconPath() . ' ' . $this->getSmallIconPath());
     $new_obj->saveIcons($this->getBigIconPath(), $this->getSmallIconPath(), $this->getTinyIconPath());
     // clone certificate (#11085)
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
     $cert = new ilCertificate(new ilCourseCertificateAdapter($this));
     $newcert = new ilCertificate(new ilCourseCertificateAdapter($new_obj));
     $cert->cloneCertificate($newcert);
     return $new_obj;
 }
 /**
  * set Tabs for settings
  */
 function setSettingsSubTabs()
 {
     global $lng, $ilTabs, $ilCtrl;
     $ilTabs->addSubTabTarget("cont_settings", $this->ctrl->getLinkTarget($this, "properties"), array("edit", ""), get_class($this));
     $ilTabs->addSubTabTarget("cont_sc_new_version", $this->ctrl->getLinkTarget($this, "newModuleVersion"), array("edit", ""), get_class($this));
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     if (ilCertificate::isActive()) {
         // // create and insert object in objecttree
         // $ilTabs->addSubTabTarget("certificate",
         // $this->ctrl->getLinkTarget($this, "certificate"),
         // array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
         // "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport")
         // );
         $ilTabs->addSubTabTarget("certificate", $this->ctrl->getLinkTargetByClass("ilcertificategui", "certificateeditor"), "", "ilcertificategui");
     }
     $ilTabs->setTabActive('settings');
 }