public function hasSCORMCertificate($sid, $ref_id, $usr_id)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!strlen($ref_id)) {
         return $this->__raiseError('No ref id given. Aborting!', 'Client');
     }
     global $rbacsystem, $tree, $ilLog;
     // get obj_id
     if (!($obj_id = ilObject::_lookupObjectId($ref_id))) {
         return $this->__raiseError('No exercise found for id: ' . $ref_id, 'Client');
     }
     if (ilObject::_isInTrash($ref_id)) {
         return $this->__raiseError("Parent with ID {$ref_id} has been deleted.", 'Client');
     }
     $result = false;
     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
     $result = ilObjSAHSLearningModuleAccess::_lookupUserCertificate($obj_id, $usr_id);
     return $result;
 }
 /**
  * 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", "");
 }
 /**
  * Get item properties
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 function getProperties()
 {
     global $lng, $rbacsystem;
     $props = array();
     include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
     $editable = ilObjSAHSLearningModuleAccess::_lookupEditable($this->obj_id);
     if (!$editable && ilObjSAHSLearningModuleAccess::_isOffline($this->obj_id)) {
         $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline"));
     } else {
         if ($editable) {
             $props[] = array("alert" => true, "value" => $lng->txt("authoring_mode"));
         }
     }
     if ($rbacsystem->checkAccess("write", $this->ref_id)) {
         $props[] = array("alert" => false, "property" => $lng->txt("type"), "value" => $lng->txt("sahs"));
     }
     // check for certificates
     if (ilObjSAHSLearningModuleAccess::_lookupUserCertificate($this->obj_id)) {
         include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
         $type = ilObjSAHSLearningModule::_lookupSubType($this->obj_id);
         switch ($type) {
             case "scorm":
                 $lng->loadLanguageModule('certificate');
                 $cmd_link = "ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=" . $this->ref_id . "&cmd=downloadCertificate";
                 $props[] = array("alert" => false, "property" => $lng->txt("condition_finished"), "value" => '<a href="' . $cmd_link . '">' . $lng->txt("download_certificate") . '</a>');
                 break;
             case "scorm2004":
                 $lng->loadLanguageModule('certificate');
                 $cmd_link = "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=" . $this->ref_id . "&amp;cmd=downloadCertificate";
                 $props[] = array("alert" => false, "property" => $lng->txt("condition_finished"), "value" => '<a href="' . $cmd_link . '">' . $lng->txt("download_certificate") . '</a>');
                 break;
         }
     }
     return $props;
 }