コード例 #1
0
ファイル: CourseController.php プロジェクト: jne21/WBT
 function edit()
 {
     $registry = Registry::getInstance();
     $locales = LocaleManager::getLocales();
     $course = new Course(intval($_GET['id']));
     $owner = new Admin($course->ownerId);
     if ($_POST['action'] == 'save') {
         //d($_POST, 1);
         $course->ownerId = intval($_SESSION['admin']['id']);
         $course->state = intval($_POST['state'] == 'on');
         foreach (array_keys($locales) as $localeId) {
             $course->l10n->loadDataFromArray($localeId, ['name' => trim($_POST['name_' . $localeId]), 'meta' => trim($_POST['meta_' . $localeId]), 'description' => trim($_POST['description_' . $localeId]), 'brief' => trim($_POST['brief_' . $localeId]), 'url' => trim($_POST['url_' . $localeId]), 'title' => trim($_POST['title_' . $localeId]), 'state' => intval($_POST['state_' . $localeId])]);
         }
         $course->save();
         header('Location: /cms/course/list');
         exit;
     } else {
         $i18n = new I18n($registry->get('i18n_path') . 'course.xml');
         $data = ['course' => $course, 'lessons' => Lesson::getList($course->id), 'owner' => $owner];
         $renderer = new Renderer(Page::MODE_NORMAL);
         $pTitle = $i18n->get($course->id ? 'update_mode' : 'append_mode');
         $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', CourseEditView::get($data));
         $renderer->loadPage();
         $renderer->output();
     }
 }
コード例 #2
0
ファイル: StageTest.php プロジェクト: jne21/WBT
 function test_cleanUp()
 {
     $registry = Registry::getInstance();
     $setup = $registry->get(self::REG_KEY);
     Stage::delete($setup['stageId']);
     Lesson::delete($setup['lessonId']);
     Course::delete($setup['courseId']);
     Admin::delete($setup['ownerId']);
     $db = $registry->get(Stage::DB);
     $db->query("DELETE FROM `" . StageL10n::TABLE . "` WHERE `description` LIKE 'unitTest%'");
     $db->query("DELETE FROM `" . Stage::TABLE . "` WHERE `name` LIKE 'unitTest%'");
     $registry->set(self::REG_KEY, null);
 }
コード例 #3
0
ファイル: LessonController.php プロジェクト: jne21/WBT
 function renumber()
 {
     $application = Application::getInstance();
     $courseId = intval($application->segment[3]);
     if ($courseId) {
         Lesson::renumberAll($_POST['order']);
         //            Lesson::renumberAll($_POST['order'], NULL, NULL, '`course_id`='.$courseId);
         echo 'OK';
     } else {
         echo 'No CourseID';
     }
     exit;
 }
コード例 #4
0
ファイル: MaterialTest.php プロジェクト: jne21/WBT
 function test_cleanUp()
 {
     $registry = Registry::getInstance();
     $setup = $registry->get(self::REG_KEY);
     Material::delete($setup['id']);
     Stage::delete($setup['stageId']);
     Lesson::delete($setup['lessonId']);
     Course::delete($setup['courseId']);
     Admin::delete($setup['ownerId']);
     $db = $registry->get(Material::DB);
     $db->query("DELETE FROM `" . MaterialL10n::TABLE . "` WHERE `parent_id`={$setup['id']}") or die($db->lastError);
     #        $db->query("DELETE FROM `".MaterialL10n::TABLE."` WHERE `original_file_name`='gcode.gif'") or die($db->lastError);
     $db->query("DELETE FROM `" . Material::TABLE . "` WHERE `name` LIKE 'unitTest%'") or die($db->lastError);
     $db->query("DELETE FROM `" . Stage::TABLE . "` WHERE `name` LIKE 'unitTest%'") or die($db->lastError);
     $db->query("DELETE FROM `" . Exercise::TABLE . "` WHERE `name` LIKE 'unitTest%'") or die($db->lastError);
     $db->query("DELETE FROM `" . Lesson::TABLE . "` WHERE EXISTS(SELECT * FROM `" . LessonL10n::TABLE . "` `s` WHERE `parent_id`=`" . Lesson::TABLE . "`.`id` AND `s`.`name` LIKE 'unitTest%')") or die($db->lastError);
     $registry->set(self::REG_KEY, null);
 }
コード例 #5
0
ファイル: LessonTest.php プロジェクト: jne21/WBT
 static function createLesson($courseId)
 {
     $lesson = new Lesson();
     $lesson->courseId = $courseId;
     $lesson->l10n = self::createLocale();
     $lesson->save();
     return $lesson;
 }