本文整理汇总了PHP中EfrontLesson::createLesson方法的典型用法代码示例。如果您正苦于以下问题:PHP EfrontLesson::createLesson方法的具体用法?PHP EfrontLesson::createLesson怎么用?PHP EfrontLesson::createLesson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EfrontLesson
的用法示例。
在下文中一共展示了EfrontLesson::createLesson方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importLessonsToCourse
/**
* Import exported lessons to course
*
* @param array $data The exported course data
* @param EfrontFile $courseFile The file of the exported course
* @since 3.6.1
* @access private
*/
private function importLessonsToCourse($data, $courseFile)
{
$data['lessons_to_courses'] = $this->setCorrectLessonOrder($data['lessons_to_courses']);
$lessonsSchedule = array();
foreach ($data['lessons_to_courses'] as $value) {
$lesson = EfrontLesson::createLesson(array('name' => 'imported_lesson', 'course_only' => true, 'directions_ID' => $this->course['directions_ID']));
$lessonFile = new EfrontFile($courseFile['directory'] . '/' . $value['lessons_ID'] . '_exported.zip');
$lessonFile = $lessonFile->copy($lesson->getDirectory());
$lesson->import($lessonFile, false, false, true);
$lessonsSchedule[$lesson->lesson['id']] = array('start_date' => $value['start_date'], 'end_date' => $value['end_date'], 'start_period' => $value['start_period'], 'end_period' => $value['end_period']);
$this->addLessons($lesson, $lessonsSchedule);
$this->replaceLessonInCourseRules($value['lessons_ID'], $lesson);
}
}
示例2: HTML_QuickForm
$form = new HTML_QuickForm("import_lesson_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=lessons", "", null, true);
//Build the form
$form->addElement('file', 'import_content', _UPLOADLESSONFILE, 'class = "inputText"');
$form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
//getUploadMaxSize returns size in KB
$form->addElement('submit', 'submit_lesson', _SUBMIT, 'class = "flatButton"');
try {
if ($form->isSubmitted() && $form->validate()) {
//If the form is submitted and validated
$directionsTree = new EfrontDirectionsTree();
if (sizeof($directionsTree->tree) == 0) {
eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_YOUMUSTFIRSTCREATEDIRECTION) . '&message_type=failure');
exit;
}
//changed because of #1462
$newLesson = EfrontLesson::createLesson();
$filesystem = new FileSystemTree($newLesson->getDirectory(), true);
$file = $filesystem->uploadFile('import_content', $newLesson->getDirectory());
$newLesson->import($file, false, true, true);
$message = _OPERATIONCOMPLETEDSUCCESSFULLY;
$message_type = 'success';
}
} catch (EfrontFileException $e) {
handleNormalFlowExceptions($e);
}
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
//Create a smarty renderer
$renderer->setRequiredTemplate('{$html}{if $required}
<span class = "formRequired">*</span>
{/if}');
$renderer->setErrorTemplate('{$html}{if $error}
示例3: createInstance
/**
* Create lesson instance
*
* This function is used to create a lesson instance.
* <br/>Example:
* <code>
* $instance = EfrontLesson :: createInstance(43);
* </code>
*
* @param mixed $instanceSource Either a lesson id or an EfrontLesson object.
* @return EfrontLesson The new lesson instance
* @since 3.6.1
* @access public
* @static
*/
public static function createInstance($instanceSource, $originateCourse)
{
if (!$instanceSource instanceof EfrontLesson) {
$instanceSource = new EfrontLesson($instanceSource);
}
if (!$originateCourse instanceof EfrontCourse) {
$originateCourse = new EfrontCourse($originateCourse);
}
$result = eF_getTableData("lessons", "*", "id=" . $instanceSource->lesson['id']);
unset($result[0]['id']);
//unset($result[0]['directions_ID']); //Instances don't belong to a category
if (!$result[0]['share_folder']) {
$result[0]['share_folder'] = $instanceSource->lesson['id'];
}
//$result[0]['name'] .= ' ('._INSTANCE.')';
$result[0]['originating_course'] = $originateCourse->course['id'];
$result[0]['instance_source'] = $instanceSource->lesson['id'];
$file = $instanceSource->export(false, true, false);
$instance = EfrontLesson::createLesson($result[0]);
$instance->import($file, true, true, true);
$instance->course['originating_course'] = $originateCourse->course['id'];
$instance->course['instance_source'] = $instanceSource->lesson['id'];
$instance->persist();
$modules = eF_loadAllModules();
foreach ($modules as $module) {
$module->onCreateInstance($instance->lesson['id'], $instanceSource->lesson['id']);
}
return $instance;
}
示例4: importData
//.........这里部分代码省略.........
$userFound = true;
}
if ($userFound) {
$lessons_name = trim($data['lesson_name']);
$lessons_ID = $this->getLessonByName($lessons_name);
unset($data['lesson_name']);
if ($lessons_ID) {
foreach ($lessons_ID as $lesson_ID) {
$data['lessons_ID'] = $lesson_ID;
$lesson = new EfrontLesson($lesson_ID);
if (is_null($this->lesson_users[$lesson_ID])) {
$result = eF_getTableDataFlat("users_to_lessons", "users_LOGIN", "lessons_ID={$lesson_ID} AND archive=0");
$this->lesson_users[$lesson_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']);
}
if (isset($this->lesson_users[$lesson_ID][$data['users_login']])) {
throw new Exception("User is already assigned to the lesson", self::USER_TO_LESSON_EXISTS);
}
if (!$lesson->lesson['course_only']) {
$lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
}
$data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0);
eF_updateTableData("users_to_lessons", $data, "users_login = '" . $data['users_login'] . "' AND lessons_ID = " . $data['lessons_ID']);
if (!$lesson->lesson['course_only']) {
if ($data['active']) {
$lesson->confirm($data['users_login']);
} else {
$lesson->unconfirm($data['users_login']);
}
}
$this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login'];
}
} else {
if ($lessons_name != "") {
$lesson = EfrontLesson::createLesson(array("name" => $lessons_name, 'course_only' => false));
$this->log["success"][] = _LINE . " {$line}: " . _NEWLESSON . " " . $lessons_name;
$lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
$lessons_ID = $lesson->lesson['id'];
$this->lessonNamesToIds[$lessons_name] = array($lessons_ID);
eF_updateTableData("users_to_lessons", $data, "users_login = '" . $data['users_login'] . "' AND lessons_ID = " . $lessons_ID);
if ($data['active']) {
$lesson->confirm($data['users_login']);
} else {
$lesson->unconfirm($data['users_login']);
}
$this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login'];
} else {
$this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDLESSON . " " . $lessons_name;
}
}
} else {
$this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login'];
}
break;
case "users_to_groups":
//debug();
$groups_ID = $this->getGroupByName($data['groups.name']);
$group_name = $data['groups.name'];
unset($data['groups.name']);
foreach ($groups_ID as $group_ID) {
$data['groups_ID'] = $group_ID;
$group = new EfrontGroup($group_ID);
$group->addUsers(array($data['users_login']));
$this->log["success"][] = _LINE . " {$line}: " . _NEWGROUPASSIGNMENT . " " . $group_name . " - " . $data['users_login'];
}
break;
//debug(false);
示例5: time
echo "<status>error</status>";
echo "<message>Invalid category</message>";
echo "</xml>";
exit;
}
$insert['name'] = $_GET['name'];
$insert['directions_ID'] = $_GET['category'];
$insert['course_only'] = $_GET['course_only'];
$insert['languages_NAME'] = $_GET['language'];
$insert['created'] = time();
if (isset($_GET['price']) && eF_checkParameter($_GET['price'], 'uint')) {
$insert['price'] = $_GET['price'];
}
$fields = array('name' => $insert['name'], 'directions_ID' => $insert['directions_ID'], 'languages_NAME' => $insert['languages_NAME'], 'course_only' => $insert['course_only'], 'created' => $insert['created'], 'price' => isset($insert['price']) && !$insert['course_only'] ? $insert['price'] : 0);
try {
$newLesson = EfrontLesson::createLesson($fields);
//$newLesson is now a new lesson object
echo "<xml>";
echo "<status>ok</status>";
echo "</xml>";
} catch (Exception $e) {
echo "<xml>";
echo "<status>error</status>";
echo "<message>Some problem occured</message>";
echo "</xml>";
}
} else {
echo "<xml>";
echo "<status>error</status>";
echo "<message>Incomplete arguments</message>";
echo "</xml>";