/** * Import relevant properties from given exercise * * @param ilObjExercise $a_test * @return object */ public static function createFromExercise(ilObjExercise $a_exercise, $a_user_id) { global $lng; $lng->loadLanguageModule("exercise"); $newObj = new self(); $newObj->setTitle($a_exercise->getTitle()); $newObj->setDescription($a_exercise->getDescription()); include_once "Services/Tracking/classes/class.ilLPMarks.php"; $lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id); $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)); // create certificate include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php"; $certificate = new ilCertificate(new ilExerciseCertificateAdapter($a_exercise)); $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "exc_" . $a_exercise->getId() . "_" . $a_user_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } // remove if certificate works $newObj->create(); return $newObj; }
/** * Import relevant properties from given test * * @param ilObjTest $a_test * @return object */ public static function createFromTest(ilObjTest $a_test, $a_user_id) { global $lng; $lng->loadLanguageModule("wsp"); $newObj = new self(); $newObj->setTitle($lng->txt("wsp_type_tstv") . " \"" . $a_test->getTitle() . "\""); $newObj->setDescription($a_test->getDescription()); $active_id = $a_test->getActiveIdOfUser($a_user_id); $pass = ilObjTest::_getResultPass($active_id); $date = $a_test->getPassFinishDate($active_id, $pass); $newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX)); // create certificate include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php"; $certificate = new ilCertificate(new ilTestCertificateAdapter($a_test)); $certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } }
/** * Import relevant properties from given learning module * * @param ilObjSAHSLearningModule $a_lm * @return object */ public static function createFromSCORMLM(ilObjSAHSLearningModule $a_lm, $a_user_id) { global $lng; $lng->loadLanguageModule("sahs"); $newObj = new self(); $newObj->setTitle($a_lm->getTitle()); $newObj->setDescription($a_lm->getDescription()); include_once "Services/Tracking/classes/class.ilLPMarks.php"; $lp_marks = new ilLPMarks($a_lm->getId(), $a_user_id); $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)); // create certificate if (!stristr(get_class($a_lm), "2004")) { $last_access = ilObjSCORMLearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id); } else { $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id); } $params = array("user_data" => ilObjUser::_lookupFields($a_user_id), "last_access" => $last_access); include_once "Services/Certificate/classes/class.ilCertificate.php"; include_once "Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php"; $certificate = new ilCertificate(new ilSCORMCertificateAdapter($a_lm)); $certificate = $certificate->outCertificate($params, false); // save pdf file if ($certificate) { // we need the object id for storing the certificate file $newObj->create(); $path = self::initStorage($newObj->getId(), "certificate"); $file_name = "sahs_" . $a_lm->getId() . "_" . $a_user_id . ".pdf"; if (file_put_contents($path . $file_name, $certificate)) { $newObj->setProperty("file", $file_name); $newObj->update(); return $newObj; } // file creation failed, so remove to object, too $newObj->delete(); } }
public static function buildFromCurlResponse($curl_response) { $response = new self(); $t = new \SimpleXMLElement($curl_response); foreach ($t as $k => $v) { if ($k == 'Request') { foreach ($t->Request[0] as $k => $v) { $response->setHeader($k, $v); } } else { $obj = ResponseObj::fromXML($k, $v); $response->setProperty($k, $obj); // echo $k.'.'. print_r($v, 1) ."\n"; } } return $response; }
/** * @param array $defArray * @return \Lexsign\Deploy\Tasks\TaskDefinition * @throws InvalidArgumentException */ public static function createFromArray($name, array $defArray) { if (!isset($defArray['type']) || !isset($defArray['workingDir'])) { throw new InvalidArgumentException('Wrong definition array format, "type", "name" and "workingDir" MUST be set'); } $taskDef = new self($defArray['type'], $name, $defArray['workingDir']); unset($defArray['type']); unset($defArray['workingDir']); foreach ($defArray as $key => $value) { $taskDef->setProperty($key, $value); } return $taskDef; }
/** * get all selectionlist entries for a given selectionlist PK * * @param $FK_selectionList * @return SelectionListEntry[] */ public static function loadAllSelectionListEntries($FK_selectionList) { $table = DB::table('selectionListEntry'); $where = DB::where($table->getColumn('FK_selectionList'), DB::intTerm($FK_selectionList)); $select = new base_database_statement_Select(); $select->setTable($table); $select->setWhere($where); $result = $select->fetchDatabase(); $selectionListEntries = []; foreach ($result as $row) { $selectionListEntry = new self(); foreach ($row as $propName => $value) { $selectionListEntry->setProperty($propName, $value); } $selectionListEntries[] = $selectionListEntry; } return $selectionListEntries; }