Esempio n. 1
0
 function register(Lesson $lesson)
 {
     // do something with this Lesson
     // now tell someone
     $notifier = Notifier::getNotifier();
     $notifier->inform("new lesson: cost ({$lesson->cost()})");
 }
function slide_presentation_lesson(Lesson $lesson, $name)
{
    global $tr;
    $manageCourse = new CourseManager();
    $c = $manageCourse->getById($lesson->getCourseId());
    return "<div class='sp-presentation-content'>\r\n            <div>\r\n                <h4><strong>" . $tr->__("Author") . "</strong>: " . $name . "</h4>\r\n                <h4><strong>" . $tr->__("Course") . "</strong>: " . $c->getName() . "</h4>\r\n                <h4><strong>" . $tr->__("Duration") . "</strong>: " . $lesson->getDuration() . " min</h4>\r\n            </div>\r\n            <h2>" . $lesson->getName() . "</h2>\r\n\r\n        </div>";
}
Esempio n. 3
0
 public function register(Lesson $lesson)
 {
     // marking registration
     // ...
     // notify
     $notifier = Notifier::getNotifier();
     $notifier->inform("new lesson. cost = {$lesson->cost()}");
 }
Esempio n. 4
0
function addLesson($lesson_title, $lesson_parent_id = 0)
{
    $lesson_object = new Lesson();
    $lesson_object->setTitle($lesson_title)->setIsRoot(!$lesson_parent_id)->save();
    if ($lesson_parent_id) {
        $lesson_parent_object = new LessonParent();
        $lesson_parent_object->setLessonId($lesson_object->getId())->setParentId($lesson_parent_id)->save();
    }
    return $lesson_object->getId();
}
Esempio n. 5
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new Lesson();
     if (isset($_POST['Lesson'])) {
         $acl = $this->_gets->getPost('acl');
         $model->attributes = $_POST['Lesson'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('lesson_create', array('model' => $model));
 }
 /**
  * @param array $lessonFields
  */
 protected function makeLesson($lessonFields = [])
 {
     $lesson = array_merge(['title' => $this->fake->sentence, 'body' => $this->fake->paragraph, 'some_bool' => $this->fake->boolean], $lessonFields);
     while ($this->times--) {
         Lesson::create($lesson);
     }
 }
Esempio n. 7
0
 public function beforeSave()
 {
     if (!$this->weight || !$this->number) {
         $criteria = new CDbCriteria();
         $criteria->condition = "courseId=" . intval($this->courseId);
         $criteria->select = "max(weight) as maxWeight,max(number) as maxNumber";
         $chapter = self::model()->find($criteria);
         $lesson = Lesson::model()->find($criteria);
     }
     if (!$this->weight) {
         if (!$chapter && !$lesson) {
             $this->weight = 1;
         } else {
             if (!$lesson) {
                 $this->weight = $chapter->maxWeight + 1;
             } elseif (!$chapter) {
                 $this->weight = $lesson->maxWeight + 1;
             } else {
                 $this->weight = max(array($chapter->maxWeight, $lesson->maxWeight)) + 1;
             }
         }
     }
     if (!$this->number) {
         if ($chapter) {
             $this->number = $chapter->maxNumber + 1;
         } else {
             $this->number = 1;
         }
     }
     return parent::beforeSave();
 }
Esempio n. 8
0
 public function actionIndex()
 {
     Yii::app()->getModule('aud');
     Yii::app()->getModule('group');
     Yii::app()->getModule('lesson');
     Yii::app()->getModule('sch');
     Yii::app()->getModule('spec');
     Yii::app()->getModule('teacher');
     $schs = Sch::model()->findAll(array('order' => 'modified_time DESC', 'limit' => 100));
     $auds = Aud::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $specs = Spec::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $groups = Group::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $lessons = Lesson::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $teachers = Teacher::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
     $entries = $this->addEntries(array($auds, $specs, $groups, $lessons, $teachers));
     foreach ($schs as $value) {
         $entries[] = array('id' => $value->group_id, 'module' => strtolower(get_class($value)), 'time' => $value->modified_time . rand(100000, 999999), 'time' => $value->modified_time, 'user' => $value->modified_by, 'action' => 'update');
     }
     $entriesNew = array();
     foreach ($entries as $value) {
         $entriesNew[$value['time'] . rand(10000, 99999)] = $value;
     }
     krsort($entriesNew);
     $this->render('index', array('entries' => $entriesNew));
 }
Esempio n. 9
0
 /**
  * 主界面
  */
 public function actionHome()
 {
     //查询课程
     $lessons = Lesson::model()->findAll(array('select' => array('catalog_id', 'arrivals', 'price')));
     //学员活跃度
     $studentAllCount = Student::model()->count();
     $criteria = new CDbCriteria();
     $criteria->distinct = true;
     $criteria->addCondition('is_pays=:is_pay');
     $criteria->params[':is_pay'] = 1;
     $studentActiveCount = StudentLesson::model()->countBySql("SELECT COUNT(DISTINCT student_id) FROM `seed_student_lesson` WHERE is_pay=:is_pay", array(':is_pay' => 1));
     $studentPercentage = round($studentActiveCount / $studentAllCount * 100) . '%';
     //获取课程分类数组
     $catalogs = Catalog::model()->findAllByAttributes(array('parent_id' => 6));
     $allCountLesson = Lesson::model()->count();
     foreach ($catalogs as $catalog) {
         //初始化
         $lessonMoney[$catalog[id]] = 0;
         $allLesson[$catalog[id]] = 0;
         $catalogName[$catalog[catalog_name]] = $catalog[id];
         //各分类中已报名课程和发布课程总量
         $allLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id", array(":catalog_id" => $catalog[id]));
         $applyLesson[$catalog[id]] = Lesson::model()->count("catalog_id=:catalog_id AND actual_students<>:actual_students", array(":catalog_id" => $catalog[id], ":actual_students" => 0));
     }
     //成交总金额
     foreach ($lessons as $lesson) {
         $lessonMoney[$lesson[catalog_id]] = (int) $lesson[arrivals] * (int) $lesson[price];
     }
     $this->render('home', array('catalogName' => json_encode($catalogName), 'lessonMoney' => json_encode($lessonMoney), 'allLesson' => json_encode($allLesson), 'applyLesson' => json_encode($applyLesson), 'studentPercentage' => $studentPercentage));
 }
 /**
  * 日历课程接口
  */
 public function actionGetSubjectSchedule()
 {
     if (!isset($_REQUEST['teacherId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['date'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('teacherId', null));
     $token = trim(Yii::app()->request->getParam('token', null));
     $date = trim(Yii::app()->request->getParam('date', null));
     if (!ctype_digit($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     // 用户名不存在,返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     // 验证日期格式合法
     if (!$this->isDate($date)) {
         $this->_return('MSG_ERR_FAIL_DATE_FORMAT');
     }
     $year = mb_substr($date, 0, 4, 'utf8');
     $month = mb_substr($date, 5, 2, 'utf8');
     $day = mb_substr($date, 8, 2, 'utf8');
     if (empty($year) || empty($month) || empty($day)) {
         $this->_return('MSG_ERR_FAIL_DATE_LESS');
     }
     // 验证token
     if (Token::model()->verifyToken($user_id, $token)) {
         // 获取日历课程
         $data = Lesson::model()->getSubjectSchedule($user_id, $year, $month, $day, $date);
         $this->_return('MSG_SUCCESS', $data);
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
Esempio n. 11
0
 public static function i($id)
 {
     if (self::$i == NULL) {
         self::$i = new Lesson($id);
     }
     return self::$i;
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         Lesson::create(['title' => $faker->sentence(5), 'body' => $faker->paragraph(4), 'some_bool' => $faker->boolean()]);
     }
 }
Esempio n. 13
0
 public function getAll()
 {
     $lessons = Lesson::all();
     $episodes = Episode::all();
     $lessons = $lessons->toBase()->merge($episodes);
     return $lessons;
 }
 public static function Lesson($type, $data)
 {
     require_once 'lesson.class.php';
     $class = new Lesson();
     $status = false;
     $device = ManagementFunction::getPostVariable('device');
     $number_device = ManagementFunction::getPostVariable('number_dv');
     $class->setData($data);
     $class->device = $device;
     $class->number_device = $number_device;
     switch ($type) {
         case 'add':
             $status = $class->add();
             break;
         case 'update':
             $status = $class->update();
             break;
         case 'delete':
             $status = $class->delete();
             break;
         case 'getsingle':
             $status = $class->getsingle();
             break;
         case 'getpage':
             $status = $class->getpage();
             break;
         case 'search':
             $status = $class->search();
             break;
         case 'getlessondetail':
             $status = $class->getLessonDetail();
             break;
         case 'dellessondetail':
             $status = $class->delLessonDetail();
             break;
         case 'updatelessondetail':
             $status = $class->updatelessondetail();
             break;
         case 'add-lesson-detail':
             $status = $class->addlessondetail();
             break;
         case 'getroom':
             $status = $class->getroom();
             break;
         case 'print':
             $status = $class->print_data();
             break;
         default:
             break;
     }
     if ($status) {
         wp_send_json_success($status);
     } else {
         wp_send_json_error($class->error);
     }
 }
Esempio n. 15
0
 private function loadModel($id)
 {
     $model = Lesson::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $lesson = Lesson::find($id);
     if (!$lesson) {
         return $this->respondNotFound('Lesson does not exist.');
     }
     return $this->respond(['data' => $this->lessonTransformer->transform($lesson)]);
 }
 public function actionSubject()
 {
     $subject_id = "";
     if (isset($_GET["subject_id"])) {
         $subject_id = StringHelper::filterString($_GET["subject_id"]);
     } else {
         if (isset($_GET["subject_code"])) {
             $subject_code = StringHelper::filterString($_GET["subject_code"]);
             $subject_by_code = Subject::model()->findByAttributes(array('subject_code' => $subject_code));
             $subject_id = $subject_by_code->subject_id;
         }
     }
     $subjectCriteria = new CDbCriteria();
     $subjectCriteria->select = "*";
     $subjectCriteria->condition = "subject_id = :subject_id";
     $subjectCriteria->params = array(":subject_id" => $subject_id);
     $subject = Subject::model()->findAll($subjectCriteria);
     $teachers = Teacher::model()->with(array("subject_teacher" => array("select" => false, "condition" => "subject_id = :subject_id", "params" => array(":subject_id" => $subject_id))))->findAll();
     //            $doc = Doc::model()->with(array("docs" => array(
     //                            "select" => "*",
     //                            "condition" => "subject_id = :subject_id and active = 1",
     //                            "params" => array(":subject_id" => $subject_id)
     //                )))->findAll(array("limit" => "3", "order" => "RAND()"));
     //
     //            $reference = Doc::model()->with(array("docs" => array(
     //                            "select" => "*",
     //                            "condition" => "subject_id = :subject_id and active = 0",
     //                            "params" => array(":subject_id" => $subject_id)
     //                )))->findAll(array("limit" => "3", "order" => "RAND()"));
     $lesson = Lesson::model()->findAll(array("select" => "*", "condition" => "lesson_subject = :lesson_subject", "params" => array(":lesson_subject" => $subject_id), "order" => "lesson_weeks ASC"));
     //            $doc_related = Doc::model()->with(array("docs" => array(
     //                            "condition" => "subject_id = :subject_id",
     //                            "params" => array(":subject_id" => $subject_id)
     //                )))->findAll();
     //   $sql = "SELECT * FROM tbl_doc JOIN tbl_subject_doc ON tbl_doc.doc_id = tbl_subject_doc.doc_id WHERE tbl_subject_doc.subject_id = " . $subject_id;
     // $doc_related = Yii::app()->db->createCommand($sql)->query();
     $criteria = new CDbCriteria();
     $criteria->select = 't.*';
     $criteria->join = 'JOIN tbl_subject_doc ON t.doc_id = tbl_subject_doc.doc_id';
     $criteria->condition = 'tbl_subject_doc.subject_id = :value';
     $criteria->params = array(":value" => $subject_id);
     $doc_related = Doc::model()->findAll($criteria);
     //            $doc_related = SubjectDoc::model()->findAll(array(
     //                'select' => '*',
     //                'condition' => 'subject_id = :subject_id',
     //                'params' => array(':subject_id' => $subject_id)));
     foreach ($subject as $subject_detail) {
         $title = $subject_detail->subject_name . " | Bluebee - UET";
         $des = $subject_detail->subject_target;
     }
     $this->pageTitle = $title;
     Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
     Yii::app()->clientScript->registerMetaTag(Yii::app()->createAbsoluteUrl('listOfSubject/subject?subject_id=') . $subject_id, null, null, array('property' => 'og:url'));
     Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
     $category_father = Faculty::model()->findAll();
     $subject_type = SubjectType::model()->findAll();
     $this->render('subject', array('subject' => $subject, 'category_father' => $category_father, 'subject_type' => $subject_type, 'teacher' => $teachers, 'lesson' => $lesson, 'doc_related' => $doc_related));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $lesson = Lesson::create(Input::all());
     // Alternatively, fire and listen for an event
     // Then, call this from the listener.
     Notify::lessonSubscribers($lesson);
     return 'Success';
     // or redirect or whatever
 }
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new Lesson();
     if (isset($_POST['Lesson'])) {
         $acl = $this->_gets->getPost('acl');
         $model->attributes = $_POST['Lesson'];
         $model->teacher_id = 88888888;
         $model->check_status = 1;
         $model->actual_students = 0;
         $model->arrivals = 0;
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('lessonRecommend_create', array('model' => $model));
 }
 public function run()
 {
     $faker = Faker::create();
     $lessonIds = Lesson::lists('id');
     $tagIds = Tag::lists('id');
     foreach (range(1, 30) as $index) {
         DB::table('lesson_tag')->insert(['lesson_id' => $faker->randomElement($lessonIds), 'tag_id' => $faker->randomElement($tagIds)]);
     }
 }
Esempio n. 21
0
 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl();
     $model = new Lesson();
     $criteria = new CDbCriteria();
     $criteria->condition = $condition;
     $criteria->order = 't.id ASC';
     //$criteria->with = array ( 'catalog' );
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     //$pageParams = XUtils::buildCondition( $_GET, array ( 'title' , 'catalogId','titleAlias' ) );
     //$pages->params = is_array( $pageParams ) ? $pageParams : array ();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('lesson_index', array('datalist' => $result, 'pagebar' => $pages));
 }
 public function __construct()
 {
     if (!isset($_GET['id']) || empty($_GET['id'])) {
         die("Please first select a lesson!");
     }
     $lessonId = $this->secureString($_GET['id']);
     $this->lesson = Lesson::getLesson($lessonId);
     $this->course = Course::getCourseById($this->lesson->getCourseId());
     $this->view = new TutorialAdminView($this->lesson, $this->course);
 }
Esempio n. 23
0
 public function schData()
 {
     Yii::app()->getModule('aud');
     Yii::app()->getModule('spec');
     Yii::app()->getModule('lesson');
     Yii::app()->getModule('teacher');
     $data = array();
     $data['auds'] = Aud::model()->getAll();
     $data['lessons'] = Lesson::model()->getAll();
     $data['teachers'] = Teacher::model()->getAll();
     return $data;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $lesson = Lesson::find($id);
     if (!$lesson) {
         return $this->respondNotFound('Lesson Not Exist');
         /*return Response::json([
         			'error' => [
         				'message' => 'Lesson not found'
         			]
         		],404);*/
     }
     return $this->respond(['data' => $this->lessonTransformer->transform($lesson)]);
 }
 public function __construct()
 {
     if (!isset($_GET['id']) || empty($_GET['id'])) {
         die("Please first select a lesson!");
     }
     $lessonId = $this->secureString($_GET['id']);
     $this->lesson = Lesson::getLesson($lessonId);
     if (!isset($this->lesson)) {
         die("This lesson was not found!");
     }
     $this->course = Course::getCourseById($this->lesson->getCourseId());
     $this->view = new ExerciseView($this->lesson, $this->course);
 }
Esempio n. 26
0
 public function actionIndex()
 {
     $this->_seoTitle = '我要去上课 - 亲子成长';
     $criteria = new CDbCriteria();
     $criteria->addCondition("catalog_id = 24");
     //分页
     $count = Lesson::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 5;
     $pager->applyLimit($criteria);
     $lessons = Lesson::model()->findAll($criteria->addCondition("status = 1"));
     $this->render('index', array('lessons' => $lessons, 'count' => $count, 'pager' => $pager));
 }
 public function actionLesson($courseId, $lessonid)
 {
     $course = Course::model()->findByPk($courseId);
     $course->viewNum = $course->viewNum + 1;
     $lesson = Lesson::model()->findByPk($lessonid);
     $lesson->viewNum = $lesson->viewNum + 1;
     if ($course->save() && $lesson->save()) {
         $lessonView = new LessonView();
         $lessonView->userId = Yii::app()->user->isGuest ? 0 : Yii::app()->user->id;
         $lessonView->ip = Yii::app()->request->getUserHostAddress();
         $lessonView->lessonid = $lessonid;
         $lessonView->save();
     }
 }
Esempio n. 28
0
 public function refreshStat()
 {
     $criteria = new CDbCriteria();
     $criteria->select = "mediaId";
     $criteria->condition = "mediaType='quiz' and courseId=" . intval($this->courseId);
     $lessons = Lesson::model()->findAll($criteria);
     $this->arrQuizIds = array();
     foreach ($lessons as $lesson) {
         $this->arrQuizIds[] = $lesson->mediaId;
     }
     $this->totalScore = $this->totalScoreCount;
     $this->quizNum = $this->quizCount;
     $this->avgScore = $this->quizNum == 0 ? 0 : $this->totalScore / $this->quizNum;
     $this->save();
 }
 public function deleteLesson()
 {
     if (isset($_POST['confirmed']) && $_POST['confirmed'] === 'true') {
         $id = $this->secureString($_POST['lessonId']);
         if (Lesson::deleteLesson($id)) {
             $this->getView()->addSuccessMessage('Lesson was successfully deleted.');
         } else {
             $this->getView()->addErrorMessage('Lesson could not be deleted!');
         }
     } else {
         $this->getView()->addWarnMessage('Are you sure you want to delete this lesson?');
         $this->getView()->addDeleteConfirmation();
     }
     $this->defaultAction();
 }
 public function addNewLessonInput()
 {
     $newLessonNr = Lesson::getNewLessonNr($this->course->getId());
     $this->addContentAfter('<form method="post">
   <input type="hidden" name="action" value="saveNewLesson" />
   <table class="table">
     <tr>
       <td>' . $newLessonNr . '</td>
       <td><input type="text" name="nameEN" placeholder="Name EN" /></td>
       <td><input type="text" name="nameDE" placeholder="Name DE" /></td>
       <td><input type="text" name="points" placeholder="' . I18n::t('admin.lessonadmin.points') . '" /></td>
       <td><input type="submit" class="btn btn-default" value="' . I18n::t('button.save') . '" /></td>
     </tr>
   </table>
 </form>');
 }