本文整理汇总了PHP中Lesson类的典型用法代码示例。如果您正苦于以下问题:PHP Lesson类的具体用法?PHP Lesson怎么用?PHP Lesson使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Lesson类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
function register(Lesson $lesson)
{
// do something with this Lesson
// now tell someone
$notifier = Notifier::getNotifier();
$notifier->inform("new lesson: cost ({$lesson->cost()})");
}
示例2: slide_presentation_lesson
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>";
}
示例3: register
public function register(Lesson $lesson)
{
// marking registration
// ...
// notify
$notifier = Notifier::getNotifier();
$notifier->inform("new lesson. cost = {$lesson->cost()}");
}
示例4: addLesson
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();
}
示例5: actionCreate
/**
* 录入
*
*/
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));
}
示例6: makeLesson
/**
* @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);
}
}
示例7: beforeSave
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();
}
示例8: actionIndex
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));
}
示例9: actionHome
/**
* 主界面
*/
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));
}
示例10: actionGetSubjectSchedule
/**
* 日历课程接口
*/
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');
}
}
示例11: i
public static function i($id)
{
if (self::$i == NULL) {
self::$i = new Lesson($id);
}
return self::$i;
}
示例12: run
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()]);
}
}
示例13: getAll
public function getAll()
{
$lessons = Lesson::all();
$episodes = Episode::all();
$lessons = $lessons->toBase()->merge($episodes);
return $lessons;
}
示例14: Lesson
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);
}
}
示例15: loadModel
private function loadModel($id)
{
$model = Lesson::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}