예제 #1
0
 function edit()
 {
     $registry = Registry::getInstance();
     $locales = LocaleManager::getLocales();
     $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
     if (!$id) {
         $lesson = new Lesson(filter_input(INPUT_GET, 'lesson_id', FILTER_VALIDATE_INT));
         $lessonId = $lesson->id;
         if (!$lessonId) {
             header('Location: /cms/course/list');
             exit;
         }
     }
     $stage = new Stage($id);
     if ($_POST['action'] == 'save') {
         //d($_POST, 1);
         if (!$stage->id) {
             $exercise = new Exercise(filter_input(INPUT_POST, 'exercise_id', FILTER_VALIDATE_INT));
             $exerciseId = $exercise->id;
             //die(print_r($_POST));
             if (!$exerciseId) {
                 header('Location: /cms/course/list');
                 exit;
             }
             $stage->lessonId = $lessonId;
             $stage->exerciseId = $exerciseId;
             $stage->settings = $exercise->configTemplate;
         }
         foreach (array_keys($locales) as $localeId) {
             $stage->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])]);
         }
         $stage->name = filter_input(INPUT_POST, 'name');
         $stage->save();
         header('Location: /cms/lesson/edit?id=' . $stage->lessonId);
         exit;
     } else {
         $i18n = new I18n($registry->get('i18n_path') . 'stage.xml');
         $data['stage'] = $stage;
         $data['materials'] = Material::getList($this->id);
         if ($stage->id) {
             $exercise = new Exercise($stage->exerciseId);
             $data['exerciseName'] = $exercise->name;
         } else {
             $data['exercises'] = Exercise::getList();
         }
         $renderer = new Renderer(Page::MODE_NORMAL);
         $pTitle = $i18n->get($lesson->id ? 'update_mode' : 'append_mode');
         $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', StageEditView::get($data));
         $renderer->loadPage();
         $renderer->output();
     }
 }
예제 #2
0
파일: StageTest.php 프로젝트: jne21/WBT
 static function createStage($lessonId, $execiseId)
 {
     $stage = new Stage();
     $stage->lessonId = $lessonId;
     $stage->exerciseId = $execiseId;
     $stage->name = 'unitTest-' . microtime();
     $stage->l10n = self::createLocale();
     $stage->save();
     return $stage;
 }