public function run()
 {
     $params = array();
     $criteria = new CDbCriteria();
     $criteria->select = array('lecture_name,training_minute,id,lecture_type');
     if (isset($this->lecture_name) and $this->lecture_name != '') {
         $keyword = addcslashes($this->lecture_name, '%_');
         $criteria->addCondition('lecture_name LIKE :keyword');
         $params[':keyword'] = "%{$keyword}%";
     }
     if (isset($this->lecture_cat) and $this->lecture_cat != '') {
         $criteria->addCondition('lecture_cat_id=' . $this->lecture_cat);
     }
     if (isset($this->trainer) and $this->trainer != '') {
         $criteria->addCondition('created_by=' . $this->trainer);
     }
     if (!empty(Yii::app()->user->id) and Yii::app()->session['group_id'] == 1) {
         $criteria->addCondition('created_by=' . Yii::app()->user->id);
     }
     $criteria->params = $params;
     $criteria->order = 'created_date DESC';
     $total = Lecture::model()->count($criteria);
     $offset = $this->limit * ($this->page - 1);
     $criteria->limit = $this->limit;
     $criteria->offset = $offset;
     $data = Lecture::model()->findAll($criteria);
     if (!empty($data)) {
         $data = CJSON::decode(CJSON::encode($data));
     }
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $pages->applyLimit($criteria);
     $this->render($this->view, array('data' => $data, 'pages' => $pages));
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $this->layout = 'site';
     $criteria = new CDbCriteria();
     $criteria->order = 'created_date DESC';
     $criteria->addCondition('id_category = ' . $id);
     $criteria->addCondition('is_active = 1');
     $count = Lecture::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = Yii::app()->params['lecturesPerPage'];
     $pages->applyLimit($criteria);
     $lectures = Lecture::model()->findAll($criteria);
     $this->render('view', array('model' => $this->loadModel($id), 'pages' => $pages, 'lectures' => $lectures));
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     if (isset($_GET['idLanguage'])) {
         $idLanguage = $_GET['idLanguage'];
     }
     if (!isset($idLanguage)) {
         $defaultLanguage = Language::model()->findByAttributes(array('code' => Yii::app()->params['defaultLanguage']));
         $idLanguage = $defaultLanguage->getPrimaryKey();
     }
     $categories = Category::model()->findAllByAttributes(array('id_language' => $idLanguage, 'is_active' => 1));
     $arrLectures = array();
     foreach ($categories as $category) {
         $criteria = new CDbCriteria();
         $criteria->order = 'created_date DESC';
         $criteria->addCondition(array(sprintf('id_category = %d', $category->getPrimaryKey()), 'is_active= 1'));
         $criteria->limit = Yii::app()->params['numberOfLecturePerCategoryInIndexPage'];
         $arrLectures[$category->getPrimaryKey()] = Lecture::model()->findAll($criteria);
     }
     $this->render('index', array('categories' => $categories, 'arrLectures' => $arrLectures));
 }
    public function actionIndex($id){
        $this->initialize($id);
        $editMode = $this->checkEditMode($id, Yii::app()->user->getId());

        $lecture = Lecture::model()->findByPk($id);

        $criteria = new CDbCriteria();
        $criteria->addCondition('id_lecture='.$id);

        $dataProvider = new CActiveDataProvider('LectureElement');
        $dataProvider->criteria = $criteria;
        $criteria->order = 'block_order ASC';
        $dataProvider->setPagination(array(
                'pageSize' => '200',
            )
        );

        $owners = [];

        $criteria1 = new CDbCriteria();
        $criteria1->alias='teacher_module';
        $criteria1->select = 'idTeacher';
        $criteria1->addCondition('idModule='.$lecture->idModule);
        $criteria1->toArray();
        $temp = TeacherModule::model()->findAll($criteria1); //info about owners
        for($i = 0; $i < count($temp);$i++){
            array_push($owners, $temp[$i]->idTeacher);
        }
        $teachers = Teacher::model()->findAllByPk($owners);

        $countBlocks = LectureElement::model()->count('id_lecture = :id', array(':id' => $id));

        $this->render('index', array(
            'dataProvider' => $dataProvider,
            'lecture' => $lecture,
            'editMode' => $editMode,
            'countBlocks' => $countBlocks,
            'teachers' => $teachers,
        ));
    }
Beispiel #5
0
    public static function unableLecture($idLecture){

        Lecture::model()->updateByPk($idLecture, array('order' => 0));
    }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     if (empty(Yii::app()->user->id) || Yii::app()->session['group_id'] == 2) {
         $this->redirect(Yii::app()->createUrl(''));
     }
     $cs = Yii::app()->getClientScript();
     //$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/ckeditor/ckeditor.js');
     $cs->registerCssFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.fileupload.css');
     $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/bootstrap-datepicker/bootstrap-datetimepicker.js', CClientScript::POS_END);
     $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.ui.widget.js', CClientScript::POS_END);
     $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.fileupload.js', CClientScript::POS_END);
     $model = WCourse::model()->find('id=' . $id . ' AND created_by=' . Yii::app()->user->id);
     $nameSession = "";
     $nameSessionTrainee = "";
     if (!empty($model->id)) {
         $nameSession = "_" . $model->id;
         $nameSessionTrainee = $model->id;
     }
     if (empty($model)) {
         $this->redirect(Yii::app()->createUrl(''));
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->start_date = date('Y-m-d', strtotime($model->start_date));
     $model->end_date = date('Y-m-d', strtotime($model->end_date));
     if (isset($_POST['WCourse'])) {
         if (!empty($_POST['avatar'])) {
             $_POST['WCourse']['avatar'] = Common::createThumb('avatars/course', $_POST['avatar'], $_POST['WCourse']['course_name']);
             $name_avatar_old = $model->avatar;
             if (!empty($name_avatar_old) and file_exists(Yii::app()->params['upload_path'] . 'uploads/avatars/course/' . $name_avatar_old)) {
                 unlink(Yii::app()->params['upload_path'] . 'uploads/avatars/course/' . $name_avatar_old);
             }
         }
         $model->attributes = $_POST['WCourse'];
         $model->created_date = date('Y-m-d H:i:s');
         if (Yii::app()->session['group_id'] == 2) {
             $model->company_code = Yii::app()->session['company_code'];
         }
         $model->created_by = Yii::app()->user->id;
         $dataLecture = Yii::app()->session->get('dataLecture' . $nameSession) ? json_decode(Yii::app()->session->get('dataLecture' . $nameSession), true) : array();
         $listTrainee = Yii::app()->session->get('listTrainee_' . $nameSessionTrainee) ? json_decode(Yii::app()->session->get('listTrainee_' . $nameSessionTrainee), true) : array();
         $model->trainee_count = count($listTrainee);
         $model->lecture_count = count($dataLecture);
         if ($model->save()) {
             if (!empty($dataLecture)) {
                 foreach ($dataLecture as $item) {
                     $modelCourseLecture = CourseLecture::model()->find('course_id=' . $model->id . ' AND lecture_id=' . $item['id']);
                     if (empty($modelCourseLecture)) {
                         $modelCourseLecture = new CourseLecture();
                         $modelCourseLecture->course_id = $model->id;
                         $modelCourseLecture->lecture_id = $item['id'];
                         $modelCourseLecture->trainer_id = Yii::app()->user->id;
                     }
                     $modelCourseLecture->start_date = $item['start_date'];
                     $modelCourseLecture->end_date = $item['end_date'];
                     $modelCourseLecture->status = 1;
                     if ($modelCourseLecture->save()) {
                         unset($_SESSION['dataLecture' . $nameSession]);
                     }
                 }
             }
         }
         if (!empty($listTrainee)) {
             foreach ($listTrainee as $item) {
                 $modelCourseTrainee = WCourseTrainee::model()->find('course_id=' . $model->id . ' AND trainee_id=' . $item['id']);
                 if (empty($modelCourseTrainee)) {
                     $modelCourseTrainee = new WCourseTrainee();
                     $modelCourseTrainee->course_id = $model->id;
                     $modelCourseTrainee->trainee_id = $item['id'];
                     $modelCourseTrainee->status = 1;
                 }
                 if ($modelCourseTrainee->save()) {
                     unset($_SESSION['listTrainee_' . $nameSessionTrainee]);
                 }
             }
         }
         $this->redirect(array('update', 'id' => $model->id));
     }
     $dataCourseLecture = array();
     if (!empty($id)) {
         unset($_SESSION['dataLecture' . $nameSession]);
         unset($_SESSION['listTrainee_' . $nameSessionTrainee]);
         $data = CourseLecture::model()->findAll('course_id=' . $id . ' ORDER BY start_date ASC');
         $data = CJSON::decode(CJSON::encode($data));
         $dataCourseLecture = array();
         if (!empty($data)) {
             foreach ($data as $key => $item) {
                 if (!empty($item["lecture_id"])) {
                     $lectureDetails = Lecture::model()->find('id=' . $item['lecture_id']);
                     if (!empty($lectureDetails)) {
                         $lectureDetails = CJSON::decode(CJSON::encode($lectureDetails));
                         $dataCourseLecture[$item['lecture_id']]['id'] = $item['lecture_id'];
                         $dataCourseLecture[$item['lecture_id']]['start_date'] = date('Y-m-d H:i', strtotime($item['start_date']));
                         $dataCourseLecture[$item['lecture_id']]['end_date'] = date('Y-m-d H:i', strtotime($item['end_date']));
                         $dataCourseLecture[$item['lecture_id']]['lecture_name'] = $lectureDetails['lecture_name'];
                         $dataCourseLecture[$item['lecture_id']]['course_id'] = $item['course_id'];
                     }
                 }
             }
         }
         $dataTrainee = CourseTrainee::model()->findAll('course_id=' . $id . ' AND status=1');
         $dataTrainee = CJSON::decode(CJSON::encode($dataTrainee));
         $listTrainee = array();
         if (!empty($dataTrainee)) {
             foreach ($dataTrainee as $item) {
                 $traineeDetails = WUser::model()->find('id=' . $item['trainee_id']);
                 if (!empty($traineeDetails)) {
                     $traineeDetails = CJSON::decode(CJSON::encode($traineeDetails));
                     $listTrainee[$traineeDetails['id']]['id'] = $traineeDetails['id'];
                     $listTrainee[$traineeDetails['id']]['course_id'] = $id;
                     $listTrainee[$traineeDetails['id']]['fullname'] = $traineeDetails['fullname'];
                     $listTrainee[$traineeDetails['id']]['username'] = $traineeDetails['username'];
                 }
             }
         }
         Yii::app()->session->add('listTrainee_' . $nameSessionTrainee, json_encode($listTrainee));
         Yii::app()->session->add('dataLecture' . $nameSession, json_encode($dataCourseLecture));
     }
     $this->render('update', array('model' => $model, 'dataCourseLecture' => $dataCourseLecture));
 }
	/**
	 * Lists all models.
	 */
	public function actionIndex($lectureId)
	{
        $lecture = Lecture::model()->findByPk($lectureId);
        $teachersconsult = [];

        $criteria= new CDbCriteria;
        $criteria->alias = 'consultant_modules';
        $criteria->select = 'consultant';
        $criteria->addCondition('module='.$lecture->idModule);
        $temp = ConsultantModules::model()->findAll($criteria);
        for($i = 0; $i < count($temp);$i++){
            array_push($teachersconsult, $temp[$i]->consultant);
        }

        $criteriaData= new CDbCriteria;
        $criteriaData->alias = 'teacher';
        $criteriaData->addInCondition('teacher_id', $teachersconsult, 'OR');

        $dataProvider=new CActiveDataProvider('Teacher', array(
            'criteria' =>$criteriaData,
            'pagination'=>false,
    ));

		$this->render('index',array(
			'dataProvider'=>$dataProvider,
            'lecture'=>$lecture
		));
	}
Beispiel #8
0
 public static function accesModule($id){
     $lectures = Lecture::model()->findAll('idModule=:id', array(':id'=>$id));
     $permission = new Permissions();
     foreach($lectures as $lecture){
         if ($permission->checkPermission(Yii::app()->user->getId(),  $lecture->id, array('read'))) {
             return true;
         }
     }
     return false;
 }
Beispiel #9
0
<?php $order = Lecture::model()->count("idModule=$newmodel->module_ID and `order`>0"); ?>
<form id="addLessonForm" action="<?php echo Yii::app()->createUrl('module/saveLesson');?>" method="post">
    <br>
    <span id="formLabel"><?php echo Yii::t('module', '0382'); ?></span>
    <br>
    <span><?php echo Yii::t('module', '0226')." ".($newmodel->lesson_count + 1)."."; ?></span>
    <input name="idModule" value="<?php echo $newmodel->module_ID;?>" hidden="hidden">
    <input name="order" value="<?php echo $order+1;?>" hidden="hidden">
    <input name="lang" value="<?php echo $newmodel->language;?>" hidden="hidden">
    <input type="text" name="newLectureName" id="newLectureName" required pattern="^[=а-яА-ЯёЁa-zA-Z0-9ЄєІі.,;: ()/+-]+$">
    <br><br>
    <input type="submit"  value=<?php echo Yii::t('module', '0383'); ?> id="submitButton" onclick="trimLectureName()">
</form>
<button id="cancelButton" onclick="hideForm('lessonForm', 'newLectureName');"><?php echo Yii::t('module', '0384'); ?></button>
<div style="margin-top: 75px">
    <?php if(Yii::app()->user->hasFlash('newLecture')):
        echo Yii::app()->user->getFlash('newLecture');
    endif; ?>
</div>
Beispiel #10
0
            <?php 
echo $form->dropDownList($model, 'id_category', CHtml::listData(Category::model()->findAll("id_language = {$model->id_language}"), 'id', 'name'), array('ajax' => array('type' => 'POST', 'url' => $this->createUrl('lecture/listByCategory'), 'update' => '#Lesson_id_lecture')));
?>
            <?php 
echo $form->error($model, 'id_category');
?>
        </div>
    </div>       
    
    <div class="row">
        <?php 
echo $form->label($model, 'id_lecture');
?>
        <div>
            <?php 
echo $form->dropDownList($model, 'id_lecture', CHtml::listData(Lecture::model()->findAll("id_category = {$model->id_category}"), 'id', 'title'));
//                echo CHtml::link($model->lecture->title, $model->lecture->href);
?>
        </div>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($model, 'title_vi');
?>
        <div>
            <?php 
echo $form->textField($model, 'title_vi', array('size' => 50, 'maxlength' => 50));
?>
            <?php 
echo $form->error($model, 'title_vi');
Beispiel #11
0
echo CHtml::dropDownList('category_id', Yii::app()->request->getRequestUri(), $arrDataCategories);
$idCategory = Yii::app()->request->getQuery('category_id');
?>
</div>

<br />

<?php 
if ($idCategory) {
    $data = Lecture::model()->findAllByAttributes(array('id_category' => $idCategory));
} else {
    if ($idLanguage) {
        $criteria = new CDbCriteria();
        $criteria->join = 'JOIN category ON category.id = id_category';
        $criteria->condition = 'category.id_language = ' . $idLanguage;
        $data = Lecture::model()->findAll($criteria);
    } else {
        $data = Lecture::model()->findAll();
    }
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'lesson-grid', 'dataProvider' => $model->search($idCategory, $idLanguage), 'filter' => $model, 'columns' => array(array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1', 'htmlOptions' => array('class' => 'number-column')), 'title_vi', 'title_en', 'title_ko', array('name' => 'id_lecture', 'value' => '$data->lecture->title', 'filter' => CHtml::listData($data, 'id', 'title')), array('name' => 'is_active', 'filter' => array('0' => 'No', '1' => 'Yes'), 'value' => '($data->is_active)?"Yes":"No"'), array('name' => 'owner_by', 'header' => Yii::t('flexiblearn', 'Owner by'), 'value' => '$data->ownerBy->username', 'filter' => false), array('class' => 'CButtonColumn'))));
?>
<script language="javascript" type="text/javascript">
    $('#language_id').change(function() {
        window.location.href = $(this).val();
    });
    
    $('#category_id').change(function() {
        window.location.href = $(this).val();
    });
</script>
Beispiel #12
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return WLecture the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
 public static function getTheme($dp)
 {
     $result=Lecture::model()->findByPk($dp->lecture_id)->title;
     return $result;
 }
Beispiel #14
0
<?php
/**
 * Created by PhpStorm.
 * User: Ivanna
 * Date: 30.04.2015
 * Time: 17:12
 */
if (Lecture::model()->addNewLesson($_POST['idModule'], $_POST['newLectureName'], $_POST['order'], $_POST['lang']))
{
    Module::model()->updateByPk($_POST['idModule'], array('lesson_count'=>$_POST['order']));
        ?>
        <br>
        <br>
        Нова лекція <?php echo "№".$_POST['order']." ".$_POST['newLectureName'];?>
        додана до модуля <?php echo $_POST['idModule'];?>.
        <br><a href="<?php echo Yii::app()->createUrl('module'); ?>">
        Повернутися на сторінку модуля.
        </a>
<?php
}
?>
Beispiel #15
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Lecture the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Lecture::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
    public function actionDownLesson($idLecture){
        $idModule =Lecture::model()->findByPk($idLecture)->idModule;
        $count = Module::model()->findByPk($idModule)->lesson_count;
        $order = Lecture::model()->findByPk($idLecture)->order;

        if($order < $count) {
            $idNext = Lecture::model()->findByAttributes(array('idModule'=>$idModule, 'order' => $order + 1))->id;

            Lecture::model()->updateByPk($idLecture, array('order' => $order + 1));
            Lecture::model()->updateByPk($idNext, array('order' => $order));
        }
        // if AJAX request, we should not redirect the browser
        if(!isset($_GET['ajax']))
            $this->redirect(Yii::app()->request->urlReferrer);
    }
 public function actionShowLectures(){
     $first = '<select size="1" name="lecture">';
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title';
     $criteria->order = 'id ASC';
     $criteria->addCondition('idModule='.$_POST['module']);
     $rows = Lecture::model()->findAll($criteria);
     $result = $first.'<option value="">Всі лекції</option>
                <optgroup label="Виберіть лекцію">';
     if(!empty($rows)) {
         foreach ($rows as $numRow => $row) {
             $result = $result . '<option value="' . $row['id'] . '">' . $row['title'] . '</option>';
         };
     }
     $last = '</select>';
     echo $result.$last;
 }
<?php
$teacher=Teacher::model()->findByPk($data['teacher_id']);
$lecture=Lecture::model()->findByPk($data['lecture_id']);
?>
<tr>
    <td>
        <div><?php echo Yii::t('profile', '0132'); ?></div>
    </td>
    <td>
        <div><?php echo $data['date_cons'] ?></div>
    </td>
    <td>
        <div><?php echo $data['start_cons']."-".$data['end_cons'] ?></div>
    </td>
    <td>
        <div><?php echo $teacher->first_name.' '.$teacher->last_name ?></div>
    </td>
    <td>
        <div><?php echo $lecture->title ?></div>
    </td>
</tr>
Beispiel #19
0
<?php
/**
 * Created by PhpStorm.
 * User: Ivanna
 * Date: 02.05.2015
 * Time: 17:28
 */
$model = Lecture::model();
$editMode = ($canEdit)?'true':'';

?>

<div class="lessonModule" id="lectures">
    <?php
    if ($canEdit){
        ?>
        <div onclick="enableEdit();">
            <a href="#">
                <img src="<?php echo StaticFilesHelper::createPath('image', 'editor', 'edt_30px.png'); ?>"
                     id="editIco" title="<?php echo Yii::t('module', '0373'); ?>"/>
            </a>
        </div>
    <?php
    }?>
    <a name="list">
    </a>

    <div onclick="showForm();">
        <?php $form=$this->beginWidget('CActiveForm', array(
            'id'=>'ajaxaddlecture-form',
        )); ?>
 public function actionListByCategory()
 {
     $params = $_POST;
     foreach ($params as $param) {
         if (isset($params) && is_array($param) && array_key_exists('id_category', $param)) {
             $idCategory = (int) $param['id_category'];
         }
     }
     if (isset($idCategory)) {
         $data = Lecture::model()->findAllByAttributes(array('id_category' => $idCategory));
         $data = CHtml::listData($data, 'id', 'title');
         foreach ($data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     }
 }