/**
  * 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');
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Пример #4
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);
 }