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)); }
/** * 日历课程接口 */ 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'); } }
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(); }
/** * 主界面 */ 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)); }
private function loadModel($id) { $model = Lesson::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
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)); }
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; }
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(); } }
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 name($module = null, $id = null) { Yii::app()->getModule('aud'); Yii::app()->getModule('group'); Yii::app()->getModule('lesson'); Yii::app()->getModule('sch'); Yii::app()->getModule('spec'); Yii::app()->getModule('teacher'); $item = ''; switch ($module) { case 'aud': if ($aud = Aud::model()->findByPk($id)) { $item = $aud->name . ' (' . Yii::app()->params['aud_types'][$aud->type] . ')'; } break; case 'group': if ($group = Group::model()->findByPk($id)) { $item = $group->group_spec->code . '-' . $group->year . '-0' . $group->number . ' (' . $group->group_spec->name . ', ' . Yii::app()->sch->course($group->year) . ' курс)'; } break; case 'lesson': if ($lesson = Lesson::model()->findByPk($id)) { $item = isset($lesson->fullname) ? $lesson->fullname : $lesson->name; } break; case 'sch': if ($sch = Sch::model()->findByPk($id)) { $item = $sch->group->groupName() . ' (' . $sch->group->group_spec->name . ', ' . Yii::app()->sch->course($sch->group->year) . ' курс)'; } break; case 'spec': if ($spec = Spec::model()->findByPk($id)) { $item = $spec->name; } break; case 'teacher': if ($teacher = Teacher::model()->findByPk($id)) { $item = $teacher->surname . ' ' . $teacher->initials; } break; default: $item = ''; break; } return $item; }
public function actionReview() { $message = false; $lesson = Lesson::model()->findByPk($_GET['id']); $model = StudentTeacher::model()->findByAttributes(array('student_id' => $this->_user['studentId'], 'teacher_id' => $lesson['teacher_id'])); if (!count($model)) { $model = new StudentTeacher(); } if (isset($_POST['StudentTeacher'])) { $model->attributes = $_POST['StudentTeacher']; $model->student_id = $this->_user['studentId']; $model->teacher_id = $lesson['teacher_id']; if ($model->save()) { $message = true; } } $this->render('review', array('lesson' => $lesson, 'message' => $message, 'model' => $model)); }
public function actionView($id) { $teacher = $this->loadModel($id); $this->_seoTitle = '名师 - ' . $teacher->name; $userId = $this->_cookiesGet('userId'); $userType = $this->_cookiesGet('userType'); $reviewModel = new Review(); if ($userType === 'student' and isset($_POST['Review'])) { $reviewModel->attributes = $_POST['Review']; $reviewModel->teacher_id = $id; $reviewModel->student_id = $userId; $reviewModel->ctime = time(); if ($reviewModel->validate() and $reviewModel->save()) { Yii::app()->user->setFlash('success', '保存成功'); } } $criteria = new CDbCriteria(); $books = Book::model()->findAllByAttributes(array('teacher_id' => $id)); $lessons = array(); $reviews = array(); $list = yii::app()->request->getParam('list'); if ($list === null or $list === 'lesson') { $model = Lesson::model(); $count = $model->count($criteria->addCondition("teacher_id = {$id}")); $pager = new CPagination($count); $pager->pageSize = 4; $pager->applyLimit($criteria); $lessons = $model->findAll($criteria); } else { $model = Review::model(); $count = $model->count($criteria->addCondition("teacher_id = {$id}")); $pager = new CPagination($count); $pager->pageSize = 4; $pager->applyLimit($criteria); $reviews = Yii::app()->db->createCommand()->select('s.*, r.contents, r.ctime')->from('seed_review r')->leftjoin('seed_student s', 's.id=r.student_id')->where('r.teacher_id=:teacher_id', array(':teacher_id' => $id))->order('ctime desc')->limit(4, $pager->currentPage * $pager->pageSize)->queryAll(); } //判断学员已关注老师 if ($userType === 'student') { $is_focus = StudentTeacher::model()->findByAttributes(array('student_id' => $userId, 'teacher_id' => $id)); } $this->render('view', array('is_focus' => $is_focus, 'teacher' => $teacher, 'lessons' => $lessons, 'reviews' => $reviews, 'books' => $books, 'userType' => $userType, 'reviewModel' => $reviewModel, 'count' => $count, 'pager' => $pager, 'list' => $_GET['list'])); }
/** * 主界面 */ public function actionHome() { //查询课程 $lessons = Lesson::model()->findAll(array('select' => array('catalog_id', 'arrivals', 'price'))); //学员活跃度 $studentAllCount = Student::model()->count(); $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) . '%'; //学员月活跃度 $time = date('Y-m', time()); for ($i = -1; $i < 8; $i++) { $m = date('m', time()); $m = $m - $i - 1; $ii = $i + 1; $startTime[$m] = date('Y-m-d H:i:s', strtotime("{$time} -{$ii} month")); $endTime[$m] = date('Y-m-d H:i:s', strtotime("{$time} -{$i} month")); $sMoAcCount[$m] = StudentLesson::model()->countBySql("SELECT COUNT(DISTINCT student_id) FROM `seed_student_lesson` WHERE is_pay=:is_pay AND pay_time>=:start_time AND pay_time<:end_time", array(':is_pay' => 1, ':start_time' => $startTime[$m], ':end_time' => $endTime[$m])); $sAllMoAcCount[$m] = Student::model()->countBySql('SELECT COUNT(id) FROM `seed_student` WHERE register_time>=:start_time AND register_time<:end_time', array(':start_time' => $startTime[$m], ':end_time' => $endTime[$m])); if ($sAllMoAcCount[$m] == 0) { $sMoPercentage[$m] = "0%"; } else { $sMoPercentage[$m] = round($sMoAcCount[$m] / $sAllMoAcCount[$m] * 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, 'sMoPercentage' => $sMoPercentage)); }
public function actionIndex() { $this->_seoTitle = '中国传统文化教育|东方美学|中式精致生活|我要去上课'; $placeCriteria = new CDbCriteria(); $teacherCriteria = new CDbCriteria(); $picCriteria = new CDbCriteria(); $placeCriteria->limit = '3'; $placeCriteria->order = 'id DESC'; $placeCriteria->addCondition('status = :status'); $placeCriteria->params[':status'] = 1; $teacherCriteria->limit = '8'; $teacherCriteria->order = 'id DESC'; $teacherCriteria->addCondition('status = :status'); $teacherCriteria->params[':status'] = 1; $picCriteria->limit = '4'; $picCriteria->order = 'id DESC'; $picCriteria->addCondition('check_status = :check_status'); $picCriteria->params[':check_status'] = 1; $lesson = Lesson::model()->findByAttributes(array('id' => '5')); $place = Place::model()->findAll($placeCriteria); $teacher = Teacher::model()->findAll($teacherCriteria); $pic = Lesson::model()->findAll($picCriteria); $this->render('index', array('place' => $place, 'teacher' => $teacher, 'lesson' => $lesson, 'pic' => $pic)); }
public function actionBuy() { $result = array(); $lessonId = (int) $_POST['lessonId']; if ($lessonId) { $lesson = Lesson::model()->findByPk($lessonId); $accountId = Yii::app()->user->getId(); $account = Account::model()->findByPk($accountId); if ($lesson && $account) { if ($lesson->price > $account->asset) { $result['status'] = 0; $result['reason'] = Yii::t('flexiblearn', 'You do not have enough money to buy this lesson. Please add some money to it !'); } else { $account->asset = $account->asset - $lesson->price; $idBoughtLessons = array(); foreach ($account->boughtLessons as $lesson) { array_push($idBoughtLessons, $lesson->getPrimaryKey()); } array_push($idBoughtLessons, $lessonId); $account->boughtLessons = $idBoughtLessons; if ($account->save()) { Yii::app()->user->setFlash('buy-message', Yii::app()->t('zii', 'You bought this lesson successfully !')); $this->redirect($this->createUrl('lesson/view', array('id' => $model->getPrimaryKey(), 'success' => 1))); } else { Yii::app()->user->setFlash('buy-message', Yii::app()->t('zii', 'You bought this lesson unsuccessfully !')); $this->redirect($this->createUrl('lesson/view', array('id' => $model->getPrimaryKey(), 'success' => 0, 'account' => $account))); } } } } else { $result['status'] = 0; } }
<?php if (!($_SERVER['REQUEST_URI'] === '/index.php?r=login' or $_SERVER['REQUEST_URI'] === '/index.php?r=register' or $_SERVER['REQUEST_URI'] === '/index.php?r=register&userType=master' or $_SERVER['REQUEST_URI'] === '/index.php?r=register&userType=student' or $_SERVER['REQUEST_URI'] === '/index.php?r=register&userType=host' or $_SERVER['REQUEST_URI'] === '/index.php?r=login&userType=student' or $_SERVER['REQUEST_URI'] === '/index.php?r=login&userType=host' or $_SERVER['REQUEST_URI'] === '/index.php?r=login&userType=master')) { ?> <footer class="cp-thumbnail cp-subject cp-picture-effect"> <!--热门课程--> <h4><i class="fa fa-fire"></i> 热门课程</h4> <div class="row"> <?php $lessonRecommendCriteria = new CDbCriteria(); //推荐课程 $lessonRecommendCriteria->limit = '3'; $lessonRecommendCriteria->order = 'id DESC'; $lessonRecommendCriteria->addCondition('recommendation = :recommendation'); $lessonRecommendCriteria->params[':recommendation'] = 1; $lessonRecommend = Lesson::model()->findAll($lessonRecommendCriteria); foreach ($lessonRecommend as $lRecommend) { ?> <div class="col-xs-4"> <div class="thumbnail"> <a href="<?php echo Yii::app()->createUrl('lesson/view', array('id' => $lRecommend->id)); ?> "> <img class="img-responsive" src="<?php echo $lRecommend->pic; ?> "> </a> <div class="caption"> <a href="<?php
public function actionChangelesson($idDis, $idLess = null) { if ($idLess == null) { $model = new Lesson(); $model->id_discipline = $idDis; $this->pageTitle = 'Создать урок'; } else { $discipline = $this->loadModel('DisciplineToTeacher', $idDis); if ($discipline->id_teacher != Yii::app()->user->id) { throw new CHttpException(403, 'У вас недостаточно прав для выполнения указанного действия.'); } $model = Lesson::model()->findByPk($idLess); $this->pageTitle = 'Изменить урок'; } if (isset($_POST['Lesson'])) { $model->attributes = $_POST['Lesson']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id_discipline)); } } $this->render('changeLesson', array('model' => $model)); }
public function actionUpdateLesson() { $this->_seoTitle = '名师 - 编辑课程'; $model = Lesson::model()->findByPk($_GET['id']); if (isset($_POST['Lesson'])) { $model->attributes = $_POST['Lesson']; $file = XUpload::upload($_FILES['attach']); if (is_array($file)) { $model->pic = $file['pathname']; @unlink($_POST['oAttach']); @unlink($_POST['oThumb']); } if ($model->validate() and $model->save()) { $this->redirect(array('mylesson')); } } $this->render('addlesson', array('model' => $model)); }
public function actionPublishAll($courseId) { $course = $this->loadCourse($courseId); $result = true; $lessons = Lesson::model()->findAll(array('condition' => 'published=0')); foreach ($lessons as $lesson) { if (!$lesson->saveAttributes(array('published' => 1))) { $result = false; } } if ($result) { Yii::app()->user->setFlash('success', Yii::t('app', '操作成功!')); } else { Yii::app()->user->setFlash('error', Yii::t('app', '操作失败!')); } $this->redirect(array('index', 'courseId' => $course->id)); }
public function nextLesson($courseId, $userId) { $criteria = new CDbCriteria(); $criteria->join = "inner join {{lesson}} l"; $criteria->condition = 'l.courseId=:courseId and finishTime=0 and t.userId=:userId'; $criteria->params = array(':courseId' => $courseId, ':userId' => $userId); $criteria->order = "weight asc"; $learn = self::model()->find($criteria); if ($learn && $learn->lesson) { return $learn->lesson; } $criteria = new CDbCriteria(); $criteria->select = "lessonId"; $criteria->join = "inner join {{lesson}} l"; $criteria->condition = 'l.courseId=:courseId and t.userId=:userId'; $criteria->params = array(':courseId' => $courseId, 'userId' => $userId); $learns = self::model()->findAll($criteria); $lessonIds = array(); foreach ($learns as $learn) { $lessonIds[] = $learn->lessonId; } $criteria = new CDbCriteria(); $criteria->addCondition('courseId=:courseId'); $criteria->params = array(':courseId' => $courseId); $criteria->addNotInCondition('id', $lessonIds); $criteria->order = "weight asc"; $lesson = Lesson::model()->find($criteria); return $lesson; }
</tr> <tr > <td > <?php echo $form->textField($model, 'end_date_time'); ?> </td> </tr> <tr> <td class="tb_title">所属导师:</td> </tr> <tr > <td > <?php $lesson = Lesson::model()->findByPk($model->id); $teachers = $lesson->teachers; echo $teachers->name; ?> </td> </tr> <tr> <td class="tb_title">性别限制:</td> </tr> <tr > <td > <?php echo $form->dropDownList($model, 'sex', array('0' => '男', '1' => '女', '2' => '不限', '3' => '儿童')); ?> </td>
public function actionProgress($id, $userId = 0) { $course = $this->loadModel($id); if (!$userId) { $userId = Yii::app()->user->id; } $user = UserInfo::model()->findByPk($userId); if (!$user) { throw new CHttpException(404, 'The requested page does not exist.'); } $criteria = new CDbCriteria(); $criteria->condition = "courseId=:courseId and status=:status and chapterId=0"; $criteria->params = array(':courseId' => $course->id, ':status' => Lesson::STATUS_PUBLIC); $criteria->order = "weight asc"; $lessons = Lesson::model()->findAll($criteria); $criteria->condition = "courseId=:courseId"; $criteria->params = array(':courseId' => $course->id); $chapters = Chapter::model()->findAll($criteria); $lessonsAndChapters = array_merge($lessons, $chapters); usort($lessonsAndChapters, array(new LessonSorter(), 'sortByWeight')); if ($userId) { $member = CourseMember::model()->findByAttributes(array('courseId' => $course->id, 'userId' => $userId)); } else { $member = new CourseMember(); } $lessonTotalCount = $course->lessonCount; $lessonLearnedCount = LessonLearn::model()->lessonCount($userId, $course->id); $nextLesson = LessonLearn::model()->nextLesson($course->id, $userId); $this->render('progress', array('lessonsAndChapters' => $lessonsAndChapters, 'course' => $course, 'member' => $member, 'lessonTotalCount' => $lessonTotalCount, 'lessonLearnedCount' => $lessonLearnedCount, 'user' => $user, 'percent' => $lessonTotalCount > 0 ? 100 * $lessonLearnedCount / $lessonTotalCount : 0, 'nextLesson' => $nextLesson)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($idLesson) { $this->layout = 'site'; $model = new Video(); $model->id_lesson = (int) $idLesson; $arrayModels = array(); if (isset($_POST['Video'])) { $model->attributes = $_POST['Video']; $lesson = Lesson::model()->findByPk($idLesson); if (Yii::app()->user->checkAccess('adminOwnLesson', array('lesson' => $lesson))) { $model->is_active = $lesson->is_active; } $model->id_lesson = $idLesson; $model->path_video_thumbnail = Yii::app()->params['defaultLessonThumbnail']; if ($model->save()) { if (!Yii::app()->user->checkAccess('adminLesson')) { $model->is_active = 0; $adminUserIds = Yii::app()->db->createCommand()->select('userid')->from('authassignment')->where('itemname=:itemname', array(':itemname' => 'admin'))->queryColumn(); foreach ($adminUserIds as $id) { $message = new Message(); $message->id_from = Yii::app()->user->getId(); $message->id_user = $id; $message->subject = 'A new video is created'; $message->message = "User " . CHtml::link($this->viewer->username, $this->viewer->href) . " have just created the lesson " . CHtml::link($model->name, $model->href); $message->save(); } } $this->redirect(array('view', 'id' => $model->id)); } // $model->file = $file = CUploadedFile::getInstance($model, 'file'); // if ($model->validate(array('file'))) { // $fileName = Yii::app()->params['video'] . '/' . $file->getName(); // if (file_exists($fileName)) { // $fileName = Yii::app()->params['lessonThumbnails'] . '/' . time() . '_' . $file->getName(); // } // if ($file->saveAs(strtolower($fileName))) { //// $videoHelper = new CVideo(); //// $videoThumbnailName = $videoHelper->create_thumbnail($fileName, //// Yii::app()->params['videoWidth'], //// Yii::app()->params['videoHeight'], //// Yii::app()->params['videoThumbnail'] //// ); //// $convertVideoFileName = $videoHelper->convertVideo($fileName); //// //// $model->path = $convertVideoFileName; //// $model->path_video_thumbnail = $videoThumbnailName; // // $model->path = $fileName; // $model->path_video_thumbnail = Yii::app()->params['defaultLessonThumbnail']; // // if ($model->save()) { // $this->redirect(array('view', 'id' => $model->getPrimaryKey())); // } // } // } } if (Yii::app()->user->checkAccess('adminVideo')) { $model->is_active = 1; } $this->render('create', array('model' => $model)); }
public function refreshAllChapterIds($courseId) { $lessons = Lesson::model()->findAllByAttributes(array('courseId' => intval($courseId)), array('order' => 'weight asc')); foreach ($lessons as $lesson) { $criteria = new CDbCriteria(); $criteria->select = "id"; $criteria->condition = "courseId=:courseId and weight<:weight"; $criteria->params = array(':courseId' => $courseId, ':weight' => $lesson->weight); $criteria->order = "weight desc"; $criteria->limit = 1; $chapter = Chapter::model()->find($criteria); if ($chapter) { $lesson->chapterId = $chapter->id; } else { $lesson->chapterId = 0; } $lesson->save(); } }
<?php /* @var $this LessonPrivateNoteController */ /* @var $data LessonPrivateNote */ ?> <div> <div style="margin-bottom:10px"> <?php $lesson = Lesson::model()->findByPk($data->lessonId); echo CHtml::link($lesson->title, array('lesson/view', 'id' => $data->lessonId)); ?> </div> <?php echo $data->content; echo CHtml::link(Yii::t('app', "修改"), array('lesson/view', 'id' => $lesson->id), array('class' => 'pull-right muted')); ?> <div class="clearfix"></div> </div>
/** * 课程总课时数据 */ public function getLessonNum() { $num = Lesson::model()->countByAttributes(array('courseId' => $this->id)); return $num ? (int) $num : 0; }
?> </td> <td><?php echo $row->price; ?> </td> <td><?php echo $row->start_date_time; ?> </td> <td><?php echo $row->end_date_time; ?> </td> <td><?php $lesson = Lesson::model()->findByPk($row->id); $teachers = $lesson->teachers; echo $teachers->name; ?> </td> <td> <?php $areas = Area::model()->findAllByAttributes(array('grade' => 2)); $area = CHtml::listData($areas, "area_id", "name"); print_r($area[$row->city]); ?> </td> <td><?php echo $row->max_students; ?> </td>
/** * 检查权限 */ public function allowOnlyAdmin() { if (Yii::app()->user->checkAccess('admin')) { return true; } if (isset($_GET['id'])) { $lessonDoc = $this->loadModel($_GET['id']); $lesson = $lessonDoc->lesson; } else { if (isset($_GET['lessonId'])) { $lesson = Lesson::model()->findByPk($_GET['lessonId']); } } if (isset($lesson) && $lesson->course) { $member = $lesson->course->findMember(array('userId' => Yii::app()->user->id)); if ($member && $member->inRoles(array('admin', 'superAdmin'))) { return true; } } return false; }
<?php return array("fields" => array("id" => array("label" => "ID"), "lesson_id" => array("label" => "Lesson Name", "type" => "_dropdown", "_list" => array("primary" => "lesson_id", "displayAttr" => "lesson_name", "src" => function () { $rows = Lesson::model()->findAll(); return $rows; })), "video_link" => array("label" => "Video Link (Youtube or Vimeo)")), "columns" => array("id", "lesson_id", "video_link"), "actions" => array("_view" => true, "_edit" => array("lesson_id", "video_link"), "_delete" => true, "_new" => array("type" => "popup", "attr" => array("lesson_id", "video_link")), "_search" => array("lesson_id", "video_link"), "_search_advanced" => array("lesson_id", "video_link"), "_customButtons" => array()), "default" => array("orderBy" => "id", "orderType" => "asc", "page" => 1, "per_page" => 10, "search" => "", "search_advanced" => ""), "tableAlias" => "lessonvideo", "title" => "Lesson - Video Manager", "condition" => false, "limit_values" => array(10, 20, 30, 40), "model" => "LessonVideo", "primary" => "id", "itemLabel" => "lessonvideo", "additionalFiles" => array());