public function actionIntroduce()
 {
     if (empty(Yii::app()->user->id) or WCourseTrainee::checkRegister(intval($_REQUEST['course_id'])) != 1) {
         $this->redirect(Yii::app()->createUrl(''));
     }
     $test_id = isset($_GET['test_id']) ? $_GET['test_id'] : '';
     $course_id = isset($_GET['course_id']) ? $_GET['course_id'] : '';
     $lecture_id = isset($_GET['lecture_id']) ? $_GET['lecture_id'] : '';
     $kind = isset($_GET['kind']) ? $_GET['kind'] : '';
     $data = WTestParent::model()->find('id=:id', array(':id' => $test_id));
     $this->render('introduce', array('data' => $data, 'course_id' => $course_id, 'lecture_id' => $lecture_id, 'kind' => $kind));
 }
예제 #2
0
 public function run()
 {
     $params = array();
     $active = 0;
     $criteria = new CDbCriteria();
     //        $criteria->select = array('id,username,fullname,phone,address,status');
     $criteria->select = '*';
     if (isset($this->test_name) and $this->test_name != '') {
         $keyword = addcslashes($this->test_name, '%_');
         $criteria->addCondition('test_name LIKE :keyword');
         $params[':keyword'] = "%{$keyword}%";
     }
     $criteria->order = 'id DESC';
     if (isset($this->test_cat) and $this->test_cat != '') {
         $criteria->addCondition('test_cat_id=' . $this->test_cat);
     }
     $criteria->addCondition('kind_of_test=' . $this->kind_of_test . ' OR kind_of_test=2');
     $criteria->addCondition('created_by=' . Yii::app()->user->id);
     $criteria->params = $params;
     $total = WTestParent::model()->count($criteria);
     $offset = $this->limit * ($this->page - 1);
     $criteria->limit = $this->limit;
     $criteria->offset = $offset;
     $data = WTestParent::model()->findAll($criteria);
     if (!empty($data)) {
         $data = CJSON::decode(CJSON::encode($data));
         foreach ($data as $item) {
             $dataNew[$item['id']] = $item;
             if ($this->test_id == $item['id']) {
                 $active = 1;
             }
         }
     }
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $pages->applyLimit($criteria);
     $this->render($this->view, array('data' => $data, 'pages' => $pages, 'active' => $active));
 }
 public function actionEditTestParent()
 {
     self::CheckLogin();
     $id = isset($_REQUEST["id"]) ? $_REQUEST["id"] : NULL;
     if (empty($id)) {
         $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/jqueryUpload/jquery.ui.widget.js', CClientScript::POS_END);
     $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.fileupload.js', CClientScript::POS_END);
     $model = WTestParent::model()->find("id=" . $id);
     if (isset($_POST['WTestParent'])) {
         $model->attributes = $_POST['WTestParent'];
         $model->test_name = $_POST['WTestParent']['test_name'];
         //$model->code_test = 'ADH'.rand(5,10);
         $model->test_cat_id = $_POST['WTestParent']['test_cat_id'];
         $model->kind_of_test = $_POST['WTestParent']['kind_of_test'];
         $model->time_test = $_POST['WTestParent']['time_test'];
         $model->introduce = $_POST['WTestParent']['introduce'];
         if (isset($_POST['WTestParent']['footer'])) {
             $model->footer = $_POST['WTestParent']['footer'];
         }
         //$model->created_by = Yii::app()->user->id;
         //$model->created_date = date('Y-m-d H:i:s');
         if (isset($_POST['WTestParent']['total_point'])) {
             $model->total_point = $_POST['WTestParent']['total_point'];
         }
         if (isset($_POST['WTestParent']['if_random'])) {
             $model->if_random = $_POST['WTestParent']['if_random'];
         }
         $dataConfig = array();
         if (isset($_POST["datafix"])) {
             $dataConfig["datafix"] = $_POST["datafix"];
         }
         if (isset($_POST["datarandom"])) {
             $dataConfig["datarandom"] = $_POST["datarandom"];
         }
         if (Yii::app()->session['group_id'] == 2) {
             $model->company_code = Yii::app()->session['company_code'];
         }
         if (!empty($dataConfig)) {
             $model->dataconfig = json_encode($dataConfig);
         }
         //---------------------------------
         if (!empty($_POST['avatar'])) {
             $model->avatar = Common::createThumb('avatars/test', $_POST['avatar'], $_POST['WTestParent']['test_name']);
         }
         if ($model->save()) {
             $this->redirect(array('index'));
         } else {
             print_r(CHtml::errorSummary($model));
         }
     }
     $this->render("edittestparent", array('model' => $model));
 }
예제 #4
0
                 }
             }
         }
     }
 } else {
     if (WTrainingLog::getStatusLearnLecture('r=wlecture/LectureView&course_lecture_id=' . $item['id']) == FALSE) {
         if (time() > strtotime($item['end_date'])) {
             echo "<span class='label label-default'>" . Yii::t('web/home', 'Not Finish') . "</span>";
         } else {
             echo '<a href="' . $url . '"><span class="label label-info">' . Yii::t('web/home', 'Studying') . '...</span></a>';
         }
     } else {
         //Hoan thanh bai giang
         //Co bai Pos test
         if (!empty($item["test_id"])) {
             $checkEmptyPost = WTestParent::model()->find("id=" . $item["test_id"]);
             if (!empty($checkEmptyPost)) {
                 //Kiem tra lam bai pos test hay chua
                 if (WUserTest::checkTestStatus($item["course_id"], $item["lecture_id"], $item["test_id"], Yii::app()->user->id, 0) == FALSE) {
                     if (time() > strtotime($item['end_date'])) {
                         echo "<span class='label label-default'>" . Yii::t('web/home', 'Not Finish') . "</span>";
                     } else {
                         echo "<span style=\"color: #ff6714\">" . Yii::t('web/home', 'Waiting for Post-test') . "</span> - <a href='" . $url . "'>" . Yii::t('web/home', 'Do Post-Testing now') . "</a>";
                     }
                 } else {
                     // Ket qua
                     if (time() > strtotime($item['end_date'])) {
                         echo Yii::t('web/home', 'Finish') . " - " . '<a href="' . $url . '"><img src="' . Yii::app()->theme->baseUrl . '/img/complete.png" style="margin-right: 5px; border: 0px" /><span style="color: #3ab54a">' . Yii::t('web/home', 'Completed') . '</span></a>';
                     } else {
                         echo '<a href="' . $url . '"><img src="' . Yii::app()->theme->baseUrl . '/img/complete.png" style="margin-right: 5px; border: 0px" /><span style="color: #3ab54a">' . Yii::t('web/home', 'Completed') . '</span></a>';
                     }
예제 #5
0
 public static function DeletePages($id)
 {
     $model = WTestParent::model()->find("id=" . $id);
     if ($model->delete()) {
         return TRUE;
     }
     return FALSE;
 }
}
if (!empty($test_cat_id)) {
    $where .= " AND t.test_cat_id=" . $test_cat_id;
}
if (!empty($nametestparent)) {
    $where .= " AND t.test_name LIKE '%" . $nametestparent . "%'";
}
if ($kind_of_test != "") {
    $where .= " AND t.kind_of_test=" . $kind_of_test;
}
if (!empty(Yii::app()->user->id) and Yii::app()->session["group_id"] == 1) {
    $where .= " AND t.created_by=" . Yii::app()->user->id;
} elseif (!empty(Yii::app()->user->id) and Yii::app()->session["group_id"] == 2) {
    $where .= " AND t.created_by=NULL";
}
$total = WTestParent::getTotalPages($where);
$page = ceil($total / 10);
?>
<div id="content_data">
<?php 
if (isset($data) && !empty($data)) {
    foreach ($data as $key => $item) {
        ?>
    <div class="dataList_item_test_trainer">
        <a href="<?php 
        echo Yii::app()->createUrl('wTest/EditTestParent', array('id' => $item['id']));
        ?>
" class="item_direct">
            <?php 
        if (!empty($item['avatar'])) {
            ?>
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionLectureView($course_lecture_id)
 {
     if (empty(Yii::app()->user->id)) {
         $this->redirect(Yii::app()->createUrl(''));
     }
     $dataLectText = array();
     if (!empty($course_lecture_id)) {
         unset($_SESSION['listLectureText']);
         $db = Yii::app()->db;
         $today = date('Y-m-d H:i');
         $comm = $db->createCommand()->select('t.*,(SELECT COUNT(id) FROM pls_course_trainee WHERE course_id=t.course_id AND trainee_id=' . Yii::app()->user->id . ') as trainee,t.id as course_lecture_id,t2.id as course_id,t2.course_name,t4.fullname,t4.id,t4.username,t3.id as lecture_id,t3.lecture_type,t3.avatar,t3.lecture_name,t3.intro,t3.training_minute,t3.files,t3.seconds_question_vod')->from('pls_course_lecture t')->leftJoin('pls_course t2', 't.course_id= t2.id')->leftJoin('pls_lecture t3', 't.lecture_id= t3.id')->leftJoin('pls_user t4', 't2.trainer_id= t4.id')->where('t.id=' . $course_lecture_id);
         $data = $comm->queryRow();
         if (isset($data['trainee']) and $data['trainee'] == 0) {
             $this->redirect(Yii::app()->createUrl(''));
         }
         if (!empty($data['pre_test_id'])) {
             $checkEmptyTest = WTestParent::model()->find("id=" . $data["pre_test_id"]);
             if (!empty($checkEmptyTest)) {
                 $Pretest = WUserTest::model()->find('course_id=' . $data['course_id'] . ' AND test_kind=1 AND status=1 AND lecture_id=' . $data['lecture_id'] . ' AND test_id=' . $data['pre_test_id'] . ' AND user_id=' . Yii::app()->user->id);
                 if (empty($Pretest)) {
                     $this->redirect(Yii::app()->createUrl('wCourseLecture/introduce', array('course_id' => $data['course_id'], 'lecture_id' => $data['lecture_id'], 'test_id' => $data['pre_test_id'], 'kind' => 1)));
                 }
             }
         }
         if ($data['lecture_type'] == 3) {
             Yii::app()->session->add('idCourseLecture', $data['course_lecture_id']);
             $this->redirect(Yii::app()->createUrl('wLecture/WebinarDetails#primary'));
         }
         $data = json_decode(json_encode($data), FALSE);
         if ($data->lecture_type == 1) {
             $dataLectureText = WLectureText::model()->findAll('lecture_id=' . $data->lecture_id . ' ORDER BY id ASC');
         } elseif ($data->lecture_type == 4) {
             $dataLectureText = WLectureText::model()->findAll('lecture_id=' . $data->lecture_id . ' ORDER BY sorder ASC');
         } else {
             $dataLectureText = WLectureText::model()->findAll('lecture_id=' . $data->lecture_id . ' ORDER BY id ASC');
         }
         $dataLectureText = CJSON::decode(CJSON::encode($dataLectureText));
         if (!empty($dataLectureText)) {
             foreach ($dataLectureText as $key => $item) {
                 $dataLectText[$item['id']] = array('lecture_text_title' => $item['title'], 'lecture_text_time' => $item['times'], 'lecture_text_content' => $item['content'], 'images' => $item['images'], 'times' => '', 'data' => 'data', 'lecture_id' => $item['lecture_id'], 'id' => $item['id']);
             }
         }
         Yii::app()->session->add('listLectureText', json_encode($dataLectText));
         $url = Yii::app()->getRequest()->getQueryString();
         $user_id = Yii::app()->user->id;
         $dataTrainingLog = WTrainingLog::model()->find('action_url="' . $url . '" AND user_id=' . $user_id);
         $dataTrainingLog = CJSON::decode(CJSON::encode($dataTrainingLog));
         if (!empty($dataTrainingLog)) {
             $itemRead = $dataTrainingLog['data'];
             if (!empty($itemRead)) {
                 $itemRead = explode(',', $itemRead);
                 foreach ($itemRead as $value) {
                     if (!empty($value)) {
                         $dataTrainingLog['itemActive'][] = $value;
                     }
                 }
             } else {
                 $dataTrainingLog['itemActive'] = array();
             }
         }
     }
     $this->render('trainee/view', array('model' => $data, 'text' => $dataLectText, 'dataTrainingLog' => (isset($dataTrainingLog) and !empty($dataTrainingLog)) ? $dataTrainingLog : array()));
 }