public static function checkTestPreTest($test_id) { $criteria = new CDbCriteria(); $criteria->condition = 'test_id =:test_id OR pre_test_id =:pre_test_id'; $criteria->params = array(':test_id' => $test_id, ':pre_test_id' => $test_id); $rs = WCourseLecture::model()->findAll($criteria); if ($rs && count($rs) > 0) { return true; } else { return false; } }
. Results will be announced later.</div> </div> <div> <?php if ($model->kind_of_test == 1 or $model->kind_of_test == 2) { $cl = WCourseLecture::model()->find('course_id=' . $_REQUEST['course_id'] . ' AND lecture_id=' . $_REQUEST['lecture_id'] . ' AND pre_test_id=' . $_REQUEST['test_id']); ?> <a class="btn btn-danger" style="margin-top: 10px" href="<?php echo Yii::app()->createUrl('wLecture/LectureView', array('course_lecture_id' => $cl->id)); ?> ">Continue Lecture</a> <?php } elseif ($model->kind_of_test == 0) { ?> <?php $cl = WCourseLecture::model()->find('course_id=' . $_REQUEST['course_id'] . ' AND lecture_id=' . $_REQUEST['lecture_id'] . ' AND test_id=' . $_REQUEST['test_id']); ?> <p><a class="btn btn-danger" style="margin-top: 10px" href="<?php echo Yii::app()->createUrl('wCourse/TraineeViewCourse', array('id' => $cl->course_id)); ?> ">Continue Course</a></p> <p><span style="color: green; margin-top: 10px;">Congratulations, you have completed the lesson.</span></p> <?php } ?> </div> </div> </div> </div>
/** * 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 WCourseLecture the loaded model * @throws CHttpException */ public function loadModel($id) { $model = WCourseLecture::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function getTestByLectureLog() { $criteria = new CDbCriteria(); $criteria->condition = 'user_id=:user_id and result=:result'; $criteria->params = array(':user_id' => Yii::app()->user->id, ':result' => 'OK'); $criteria->order = 'id DESC'; $rs = WTrainingLog::model()->findAll($criteria); if ($rs) { $arrCL = array(); foreach ($rs as $r) { $action = $r['action_url']; $arrAction = explode('&', $action); $stra = $arrAction[1]; $course_lecture_id = explode('=', $stra); $arrCL[] = WCourseLecture::model()->find('id=:id ORDER BY id DESC', array(':id' => $course_lecture_id[1])); } return $arrCL; } else { return null; } }
public function actionCopyCourse() { $idcourse = $_REQUEST["idcourse"]; $dataCourse = WCourse::model()->find("id=" . $idcourse); $check = 0; if (!empty($dataCourse)) { $modelCourse = new WCourse(); $modelCourse->approve = $dataCourse->approve; $modelCourse->avatar = $dataCourse->avatar; $modelCourse->course_cat_id = $dataCourse->course_cat_id; $space = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $newCode = ""; $index = 0; for ($i = 0; $i < strlen($space); $i++) { $checkData = WCourse::model()->findAll("course_code='" . $dataCourse->course_code . $space[$i] . "'"); if (empty($checkData)) { $newCode = $dataCourse->course_code . $space[$i]; break; } else { $index++; } } $name = "Copy "; if ($index != 0) { $name .= $index . ' '; } $modelCourse->course_code = $newCode; $modelCourse->course_name = $name . $dataCourse->course_name; $modelCourse->created_by = $dataCourse->created_by; $modelCourse->created_date = date('Y-m-d H:i:s'); $modelCourse->description = $dataCourse->description; $modelCourse->start_date = NULL; $modelCourse->end_date = NULL; $modelCourse->hot_course = 0; $modelCourse->intruduce = $dataCourse->intruduce; $modelCourse->lecture_count = $dataCourse->lecture_count; $modelCourse->status = $dataCourse->status; $modelCourse->trainee_count = 0; $modelCourse->trainer_id = $dataCourse->trainer_id; if ($modelCourse->save()) { $idcoursenew = $modelCourse->id; $dataCourseLecture = WCourseLecture::model()->findAll('course_id=' . $idcourse . ' ORDER BY start_date ASC'); if (!empty($dataCourseLecture)) { foreach ($dataCourseLecture as $courselecture) { $modelCourseLecture = new WCourseLecture(); $modelCourseLecture->course_id = $idcoursenew; $modelCourseLecture->end_date = NULL; $modelCourseLecture->start_date = NULL; $modelCourseLecture->status = $courselecture->status; $modelCourseLecture->trainer_id = $courselecture->trainer_id; $modelCourseLecture->lecture_id = $courselecture->lecture_id; if ($modelCourseLecture->save()) { } else { $check = 2; } } } } else { $check = 1; } } $mess = ""; $status = "true"; if ($check == 0) { $mess = "Copy thành công"; $status = "true"; } elseif ($check == 1) { $status = "false"; $mess = "Không thêm mới được Course. Lỗi thao tác, mời bạn thử lại."; } else { $status = "false"; $mess = "Lỗi thao tác, mời bạn thử lại."; } echo json_encode(array("result" => $status, 'message' => $mess)); }
/** * Trainee thuc hien 1 bai test * @param: $test_id : Test * @param: $course_id: Course **/ public function actionStarttest($test_id, $course_id, $lecture_id) { self::CheckLogin(); $this->layout = '//layouts/main_trainer'; $cs = Yii::app()->getClientScript(); unset($_SESSION['dataQuestionLis']); $cs->registerCssFile(Yii::app()->theme->baseUrl . '/css/jquery-ui.css?ver=' . time()); $cs->registerCssFile(Yii::app()->theme->baseUrl . '/css/dialog.css?ver=' . time()); //$cs->registerCssFile(Yii::app()->theme->baseUrl.'/css/jquery.countdown.css?ver='.time()); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.simplemodal-1.4.4.js', CClientScript::POS_END); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui.js'); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.slimscroll.min.js'); //Check trainee co trong khoa hoc hay khong if (WCourseTrainee::CheckTraineeInCourse($course_id) == FALSE) { $this->redirect(Yii::app()->CreateUrl("/")); } $kind = isset($_REQUEST['kind']) ? $_REQUEST['kind'] : ''; $db = Yii::app()->db; $comm = $db->createCommand()->select('t.*,t2.test_cat')->from('pls_test_parent t')->leftJoin('pls_test_cat t2', 't.test_cat_id = t2.id')->where('t.id=' . $test_id); $result = $comm->queryRow(); $dataQuestion = array(); $dataQuestionLib = array(); // Luu Data Question vao 1 mang $dataTestUser = WTestUser::model()->find("id_test_parent=" . $test_id . ' AND course_id=' . $course_id . ' AND lecture_id=' . $lecture_id . ' AND user_id=' . Yii::app()->user->id); if (empty($dataTestUser)) { if (!empty($result["dataconfig"])) { $dataconfig = json_decode($result["dataconfig"], true); $dataQuestionFix = array(); $totalquestion = 0; // Ket noi database $db = Yii::app()->db; $comm = $db->createCommand(); if (isset($dataconfig["datafix"]) and !empty($dataconfig["datafix"])) { $totalquestion += count($dataconfig["datafix"]); if (!empty($result["if_random"])) { $dataNew = array(); $i = 0; $count = count($dataconfig["datafix"]); while ($i < $count) { $indexrandom = array_rand($dataconfig["datafix"]); $dataNew[$i] = $dataconfig["datafix"][$indexrandom]; unset($dataconfig["datafix"][$indexrandom]); $i++; } $dataconfig["datafix"] = $dataNew; } foreach ($dataconfig["datafix"] as $key => $ItemdataquestionFix) { $dataQuestionFix[] = $ItemdataquestionFix["idquestion"]; $dataQuestionLib[$key] = $ItemdataquestionFix; } } ///////////// if (isset($dataconfig["datarandom"]) and !empty($dataconfig["datarandom"])) { foreach ($dataconfig["datarandom"] as $itemdatarandom) { $totalquestion += $itemdatarandom["number_question"]; $point = $itemdatarandom["point_question"] / $itemdatarandom["number_question"]; $comm->reset(); $comm = $comm->select('*')->from('pls_question_lib t'); if (!empty($dataQuestionFix)) { $comm = $comm->where('t.question_cat_id=' . $itemdatarandom["idcate"] . ' AND t.id NOT IN(' . implode(',', $dataQuestionFix) . ')'); } else { $comm = $comm->where('t.question_cat_id=' . $itemdatarandom["idcate"]); } $comm = $comm->order('RAND()')->limit($itemdatarandom["number_question"]); $data = $comm->queryAll(); $dataNew = array(); if (!empty($data)) { foreach ($data as $key => $dataItem) { $dataNew[$key]["idquestion"] = $dataItem["id"]; $dataNew[$key]["point"] = $point; } $dataQuestionLib = array_merge($dataQuestionLib, $dataNew); } } } $dataTestUser = new WTestUser(); $dataTestUser->id_test_parent = $test_id; $dataTestUser->user_id = Yii::app()->user->id; $dataTestUser->dataquestion = json_encode($dataQuestionLib); $dataTestUser->course_id = $course_id; $dataTestUser->lecture_id = $lecture_id; $dataTestUser->kind = $kind; $dataTestUser->save(); } } else { if (!empty($dataTestUser->dataquestion)) { $dataQuestionLib = json_decode($dataTestUser->dataquestion, true); } } $total = count($dataQuestionLib); $kind = isset($_REQUEST['kind']) ? $_REQUEST['kind'] : ''; $model = new WUserTest(); $model->test_id = $test_id; $model->course_id = $course_id; $model->lecture_id = $lecture_id; $model->user_id = Yii::app()->user->id; $model->status = 0; $model->added_date = date('Y-m-d H:i:s'); if ($kind == '' or $kind == 1) { $model->test_kind = 1; } else { $model->test_kind = 0; } //echo $model->test_kind; exit(); $oneut = WUserTest::model()->find('test_id=:test_id and course_id=:course_id and lecture_id=:lecture_id and user_id=:user_id and test_kind=:test_kind', array(':test_id' => $test_id, ':course_id' => $course_id, ':lecture_id' => $lecture_id, ':user_id' => Yii::app()->user->id, ':test_kind' => $model->test_kind)); if (is_null($oneut)) { $model->save(); $user_test_id = $model->id; } else { if ($oneut->status >= 1) { $cl = WCourseLecture::model()->find('course_id=' . $course_id . ' AND lecture_id=' . $lecture_id); if ($kind == 1) { $this->redirect(Yii::app()->createUrl("wLecture/LectureView", array("course_lecture_id" => $cl->id))); } elseif ($kind == 0) { $this->redirect(Yii::app()->createUrl("wCourse/TraineeViewCourse", array("id" => $cl->course_id))); } } $user_test_id = $oneut->id; } $per_page = 1; $page_number = isset($_POST['page']) ? $_POST['page'] : 0; $position = $page_number * $per_page; if (!empty($total)) { $pagination = WFunction::gettab($dataQuestionLib); } else { $pagination = ''; } $this->render('/wTest/trainee/starttest', array('course_id' => $course_id, 'lecture_id' => $lecture_id, 'test' => $result, 'pagination' => $pagination, 'total' => $total, 'kind' => $model->test_kind, "question" => $dataQuestionLib, "user_test_id" => $user_test_id)); }
public static function getInfoCourseLectureComment($idcomment, $dataId, $dataType) { $db = Yii::app()->db; $dataNew = array(); $group_id = Yii::app()->session["group_id"]; if ($dataType == "course") { $comm = $db->createCommand()->select('t.*')->from('pls_course t')->where("t.id IS NOT NULL AND t.id=" . $dataId); $data = $comm->queryRow(); if (!empty($data)) { $dataNew[$idcomment]["name"] = 'Course: ' . $data["course_name"]; $url = Yii::app()->createUrl("wCourse/view", array("id" => $data["id"])); switch ($group_id) { case 1: $url = Yii::app()->createUrl("wCourse/view", array("id" => $data["id"], "row" => "comment_row_" . $idcomment)); break; case 2: $url = Yii::app()->createUrl("wCourse/TraineeViewCourse", array("id" => $data["id"], "row" => "comment_row_" . $idcomment)); break; case 3: $url = Yii::app()->createUrl("wCourse/view", array("id" => $data["id"], "row" => "comment_row_" . $idcomment)); break; } $dataNew[$idcomment]["url"] = $url; } } elseif ($dataType == "courselecture") { $comm = $db->createCommand()->select('t.*')->from('pls_lecture t')->where("t.id IS NOT NULL AND t.id=" . $dataId); $data = $comm->queryRow(); if (!empty($data)) { $url = NULL; switch ($group_id) { case 1: case 3: $url = Yii::app()->createUrl("wLecture/View", array("id" => $data["id"], "row" => "comment_row_" . $idcomment)); break; case 2: $datacourselecture = WCourseLecture::model()->findAll("lecture_id=" . $dataId); $course_lecture_id = NULL; if (!empty($datacourselecture)) { foreach ($datacourselecture as $itemcourelecture) { $modelCourseTrainee = WCourseTrainee::model()->find("course_id=" . $itemcourelecture->course_id . ' AND trainee_id=' . Yii::app()->user->id); if (!empty($modelCourseTrainee)) { $course_lecture_id = $itemcourelecture->id; } } } if (!empty($course_lecture_id)) { $url = Yii::app()->createUrl("wLecture/LectureView", array("course_lecture_id" => $course_lecture_id, "row" => "comment_row_" . $idcomment)); } else { $url = "javascript:;"; } break; /*case 3: $url = Yii::app()->createUrl("wSuperLecture/LectureView",array("course_lecture_id" => $data["id"]));; break;*/ } $dataNew[$idcomment]["name"] = 'Lecture: ' . $data["lecture_name"]; $dataNew[$idcomment]["url"] = $url; } } return $dataNew; }
<?php /* @var $this LectureController */ /* @var $model WLecture */ /* @var $form CActiveForm */ $checkEmpty = array(); if (!$model->isNewRecord) { $checkEmpty = WCourseLecture::model()->findAll("lecture_id=" . $model->id); } ?> <div class="primary_page_edit"> <div class="form_avatar"> <a href="javascript:void(0);" style="min-height: 50px;"> <center> <?php if (!empty($model->avatar)) { ?> <img id="img_avatar_course" style="width:100%;" src="<?php echo Yii::app()->params['url_base'] . '/uploads/avatars/lecture/' . $model->avatar; ?> " alt=""/> <?php } else { ?> <img id="img_avatar_course" style="width:100%;" src="<?php echo Yii::app()->theme->baseUrl; ?> /img/add-avatar-lecture.jpg" alt=""/> <?php } ?>
<?php if ($dataTestUser["kind"] == 1) { ?> <?php $cl = WCourseLecture::model()->find('course_id=' . $dataTestUser['course_id'] . ' AND lecture_id=' . $dataTestUser['lecture_id'] . ' AND pre_test_id=' . $dataTestUser['id_test_parent'] . ''); ?> <a class="btn btn-danger" style="margin-top: 10px" href="<?php echo Yii::app()->createUrl('wLecture/LectureView', array('course_lecture_id' => $cl->id)); ?> ">Continue Lecture</a></p> <?php } elseif ($dataTestUser["kind"] == 0) { ?> <?php $cl = WCourseLecture::model()->find('course_id=' . $dataTestUser['course_id'] . ' AND lecture_id=' . $dataTestUser['lecture_id'] . ' AND test_id=' . $dataTestUser['id_test_parent'] . ''); ?> <a class="btn btn-danger" style="margin-top: 10px" href="<?php echo Yii::app()->createUrl('wCourse/TraineeViewCourse', array('id' => $cl->course_id)); ?> ">Continue</a></p> <?php } ?> <?php } ?> </div> </div> </div> </div>
public function actionLectureList() { if (empty(Yii::app()->user->id)) { $this->redirect(Yii::app()->createUrl('')); } $db = Yii::app()->db; $comm = $db->createCommand()->select('t.*')->from('pls_lecture_cat t'); $data_lecture = $comm->queryAll(); $comm = $db->createCommand()->select('t.*')->from('pls_course t')->leftJoin('pls_course_lecture t1', 't1.course_id = t.id')->group('t.id'); $data_course = $comm->queryAll(); $string_where = 't.status = 1'; $data = array(); if (isset($_REQUEST["page"])) { $page_number = filter_var($_REQUEST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH); } else { $page_number = 0; } if (isset($_REQUEST["cate"]) && !empty($_REQUEST["cate"])) { $string_where .= ' AND t2.id=' . $_REQUEST["cate"]; } else { // $value=''; } if (isset($_REQUEST["course"]) && !empty($_REQUEST["course"])) { $string_where .= ' AND t.course_id=' . $_REQUEST["course"]; } else { // $value=''; } $position = 0; $itempage = 6; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course_lecture t')->leftJoin('pls_lecture t1', 't1.id = t.lecture_id')->leftJoin('pls_lecture_cat t2', 't2.id = t1.lecture_cat_id')->leftJoin('pls_course t4', 't4.id = t.course_id')->where($string_where)->order('t.start_date ASC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.id, t1.lecture_type, t1.lecture_name, t1.training_minute, t1.intro, t1.avatar, t1.pages, t4.course_code, t2.cat_name, t5.fullname ')->from('pls_course_lecture t')->leftJoin('pls_lecture t1', 't1.id = t.lecture_id')->leftJoin('pls_lecture_cat t2', 't2.id = t1.lecture_cat_id')->leftJoin('pls_course t4', 't4.id = t.course_id')->leftJoin('pls_user t5', 't.trainer_id = t5.id')->where($string_where)->order('t.start_date ASC'); // var_dump($string_where); /*$limit = 10; $page = (isset($_GET['page']) AND !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page-1); $pages = new CPagination($total); $pages->pageSize = $limit; */ $comm->limit = $itempage; $comm->offset = $page_number * 6; $results = $comm->queryAll(); $countLecture = WCourseLecture::model()->findAll(); $total_pages = ceil(count($countLecture) / 6); // số trang = tất cả bản ghi/số bản ghi hiển thị 1 trang $this->render('supervisor/lecturelist', array('total_pages' => $total_pages, 'data_lecture' => $data_lecture, 'data_course' => $data_course, 'results' => $results)); }
public function actionUpdateTest() { $course_id = $_POST['course_id']; $lecture_id = $_POST['lecture_id']; $status = $_POST['status']; $idTest = $_POST['idTest']; $kind_of_test = $_POST['kind_of_test']; $model = WCourseLecture::model()->find('course_id=' . $course_id . ' AND lecture_id=' . $lecture_id); if ($status == 0) { if ($kind_of_test == 0) { $model->pre_test_id = $idTest; } elseif ($kind_of_test == 1) { $model->test_id = $idTest; } } else { if ($kind_of_test == 0) { $model->pre_test_id = ''; } elseif ($kind_of_test == 1) { $model->test_id = ''; } } if ($model->save()) { if ($kind_of_test == 0) { $idTest = $model->pre_test_id; } elseif ($kind_of_test == 1) { $idTest = $model->test_id; } echo json_encode(array('status' => 'true', 'idTest' => $idTest)); } else { echo json_encode(array('status' => 'false', 'idTest' => 0)); } }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { WCourseTrainee::model()->deleteAll(array('trainee_id' => $id)); WCourseLecture::model()->deleteAll(array('trainee_id' => $id)); WUserTest::model()->deleteAll(array('user_id' => $id)); $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $view = 'index'; if (Yii::app()->user->isGuest) { $this->redirect(array('login')); } else { if (Yii::app()->session['group_id'] == 2) { $this->layout = '//layouts/main'; $view = 'trainee/index'; $this->render($view); } elseif (Yii::app()->session['group_id'] == 1) { $this->layout = '//layouts/main'; $view = 'trainer/index'; $this->render($view); } elseif (Yii::app()->session['group_id'] == 4) { $this->layout = '//layouts/main'; $view = 'teamleader/index'; $this->render($view); } elseif (Yii::app()->session['group_id'] == 3) { $view = 'supervisor/index'; // $view = 'index'; $this->layout = '//layouts/main'; $data = array(); // biểu đồ liên quan $infoCourse = array(); $criteria = new CDbCriteria(); $criteria->condition = 'status = 1'; $criteria->order = 'id desc'; $criteria->limit = 6; $count = WUser::model()->count($criteria); $pages = new CPagination($count); // results per page $pages->pageSize = Params::$rowsPerPage; $pages->applyLimit($criteria); $infosupper = WUser::model()->findAll($criteria); // course_lecture /* $courseLecture = array(); $db = Yii::app()->db; $comm = $db->createCommand() ->select('COUNT(*)') ->from('pls_course_lecture t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_lecture t2','t2.id = t.lecture_id') ->leftJoin('pls_test t3','t3.id = t.pre_test_id') ->leftJoin('pls_test t4','t4.id = t.test_id') ->leftJoin('pls_user t5','t5.id = t.trainer_id') ->order('t.id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand() ->select(' t.*, t1.course_name, t2.lecture_name, t3.test_name, t4.test_name, t5.fullname ') ->from('pls_course_lecture t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_lecture t2','t2.id = t.lecture_id') ->leftJoin('pls_test t3','t3.id = t.pre_test_id') ->leftJoin('pls_test t4','t4.id = t.test_id') ->leftJoin('pls_user t5','t5.id = t.trainer_id') ->order('t.id ASC'); $limit = 6; $page = (isset($_GET['page']) AND !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page-1); $comm->limit = $limit; $comm->offset = $offset; $courseLecture = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; */ $courseLecture = array(); $courseLecture = WCourseLecture::model()->findAll(); $Lectures = array(); $Lectures = WLecture::model()->findAll(); // course trainne /* $courseTrainee = array(); $db = Yii::app()->db; $comm = $db->createCommand() ->select('COUNT(*)') ->from('pls_course_trainee t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_user t2','t2.id = t.trainee_id') ->order('t.id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand() ->select(' t.*, t1.course_name, t2.fullname ') ->from('pls_course_trainee t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_user t2','t2.id = t.trainee_id') ->order('t.id ASC'); $limit = 10; $page = (isset($_GET['page']) AND !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page-1); $comm->limit = $limit; $comm->offset = $offset; $courseTrainee = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit;*/ // course_trainee $db = Yii::app()->db; $comm = $db->createCommand()->select('count(*)')->from('pls_user t')->where('t.user_group_id=2'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select('*')->from('pls_user t')->where('t.user_group_id=2'); $limit = 5; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $data = $comm->queryAll(); $result = array(); if (!empty($data)) { foreach ($data as $item) { $result[$item['id']] = $item; $comm->reset(); $comm = $db->createCommand()->select('t2.course_name')->from('pls_course_trainee t')->leftJoin('pls_course t2', 't.course_id= t2.id')->where('t.trainee_id=' . $item['id'] . ' AND t.status = 1'); $Trainee = $comm->queryAll(); $result[$item['id']]['course_list'] = $Trainee; } } $pages = new CPagination($total); $pages->pageSize = $limit; $TraineeUser = array(); $TraineeUser = WUser::model()->findAll('status=1 and user_group_id=2'); // var_dump(count($TraineeUser)); $TrainerUser = array(); $TrainerUser = WUser::model()->findAll('status =1 and user_group_id=1'); // var_dump(count($TrainerUser)); $sum = array(); $sum = array_merge($TraineeUser, $TrainerUser); // var_dump(count($sum));die; // var_dump(count($sumUser));die; // course_trainer $db = Yii::app()->db; $comm = $db->createCommand()->select('count(*)')->from('pls_user t')->where('t.user_group_id=1'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select('*')->from('pls_user t')->where('t.user_group_id=1'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $data = $comm->queryAll(); $resultTrainer = array(); if (!empty($data)) { foreach ($data as $item) { $result[$item['id']] = $item; $comm->reset(); $comm = $db->createCommand()->select('t2.course_name')->from('pls_course_trainee t')->leftJoin('pls_course t2', 't.course_id= t2.id')->where('t.trainee_id=' . $item['id'] . ' AND t.status = 1'); $courseTrainee = $comm->queryAll(); $resultTrainer[$item['id']]['course_list'] = $courseTrainee; } } $pages = new CPagination($total); $pages->pageSize = $limit; // var_dump(count($resultTrainer));die; // course_result_test $courseTest = array(); $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_user_test t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_user t2', 't2.id = t.user_id')->leftJoin('pls_test t3', 't3.id = t.test_id')->order('t.course_id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t1.course_name, t2.fullname, t3.total_point ')->from('pls_user_test t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_user t2', 't2.id = t.user_id')->leftJoin('pls_test t3', 't3.id = t.test_id')->order('t.course_id ASC'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $courseTest = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; // lecture_schedule $lectureSchedule = array(); $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course_lecture t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_lecture t2', 't2.id = t.lecture_id')->leftJoin('pls_user t5', 't5.id = t.trainer_id')->order('t.trainer_id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t1.course_name, t2.lecture_name, t5.fullname ')->from('pls_course_lecture t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_lecture t2', 't2.id = t.lecture_id')->leftJoin('pls_user t5', 't5.id = t.trainer_id')->order('t.trainer_id DESC'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $lectureSchedule = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; // running course $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course t')->leftJoin('pls_course_cat t1', 't1.id = t.course_cat_id')->where('t.status = 2 and t.end_date > NOW()')->order('t.start_date ASC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t1.course_cat, t1.avatar ')->from('pls_course t')->leftJoin('pls_course_cat t1', 't1.id = t.course_cat_id')->where('t.status = 2 and t.end_date > NOW()')->order('t.start_date ASC'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $runningCourse = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; $totalCourse = array(); $coursependding = array(); $courseactive = array(); $coursestart = array(); $coursecomplete = array(); $totalCourse = WCourse::model()->findAll(); $coursependding = WCourse::model()->findAll('status=0'); $courseactive = WCourse::model()->findAll('status=1'); $coursestart = WCourse::model()->findAll('status=2'); $coursecomplete = WCourse::model()->findAll('status=5'); $imgoverview = '<img width="680px" height="360px" src="' . Yii::app()->theme->baseUrl . '/img/overview.png" />'; // training proccessing $dashCourse = array(); $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course t')->leftJoin('pls_user t2', 't2.id = t.trainer_id')->order('t.status ASC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t2.fullname ')->from('pls_course t')->leftJoin('pls_user t2', 't2.id = t.trainer_id')->order('t.status ASC'); $dashCourse = $comm->queryAll(); $total_pages = ceil(count($dashCourse) / Params::$coursePerPage); $test = $db->createCommand(' SELECT course_id, user_id, AVG(point_percent), YEAR(end_date) ,Y.course_name FROM( SELECT A.course_id, A.lecture_id, A.test_id, A.pass_score_point, A.user_id, C.total_point, ROUND(IFNULL(A.pass_score_point, 0)*100 / C.total_point, 0) point_percent FROM pls_user_test A INNER JOIN pls_test C ON A.test_id = C.id WHERE A. status = 1 AND A.success = 2 GROUP BY A.course_id, A.test_id, A.user_id, A.lecture_id ) X INNER JOIN pls_course Y ON X.course_id = Y.id WHERE Y.end_date < NOW() GROUP BY course_id, end_date ,course_name , YEAR(end_date) ORDER BY YEAR(end_date) ASC '); $test = $test->queryAll(); // MyHelper::dump($test);die; $this->render($view, array('total_pages' => $total_pages, 'test' => $test, 'totalCourse' => $totalCourse, 'coursependding' => $coursependding, 'courseactive' => $courseactive, 'coursestart' => $coursestart, 'coursecomplete' => $coursecomplete, 'Lectures' => $Lectures, 'TraineeUser' => $TraineeUser, 'TrainerUser' => $TrainerUser, 'sum' => $sum, 'imgoverview' => $imgoverview, 'runningCourse' => $runningCourse, 'courseTrainer' => $resultTrainer, 'courseTrainee' => $result, 'courseLecture' => $courseLecture, 'courseTest' => $courseTest, 'lectureSchedule' => $lectureSchedule)); // $this->render($view,array('courseTrainee'=>$courseTrainee, 'courseLecture'=>$courseLecture, 'courseTest'=>$courseTest,'lectureSchedule'=>$lectureSchedule)); } } }
public function actionUpdateTest() { $idcourselecture = $_REQUEST['idcourselecture']; $kind_of_test = $_REQUEST['kind_of_test']; $model = WCourseLecture::model()->find("id=" . $idcourselecture); if ($kind_of_test == 0) { $model->test_id = NULL; } elseif ($kind_of_test == 1) { $model->pre_test_id = NULL; } if ($model->save()) { echo json_encode(array('result' => 'true')); } else { echo json_encode(array('result' => 'false')); } }