public static function generate_file_name($type = 'file') { $file_info = array(); $curr_info = date("Y,m,d,H,i,s"); list($year, $month, $day, $hour, $minute, $second) = @split(",", $curr_info); $filename = $year . $month . $day . $hour . $minute . $second . WFunction::random_generator(5); $file_info['name'] = $filename; $file_info['host_path'] = "/uploads/" . $type . "/{$year}/{$month}/"; $file_info['physical_path'] = $type . "/{$year}/{$month}/"; return $file_info; }
if ($item['kind_of_test'] == 0) { ?> <span class="icon_test">Post-test</span> <?php } elseif ($item['kind_of_test'] == 1) { ?> <span class="icon_test_pre">Pre-test</span> <?php } else { ?> <span class="icon_test_both">Both</span> <?php } ?> <?php echo WFunction::truncate(CHtml::encode($item['test_name']), 30); ?> </a></h2> <p><span class="col1">Category: </span><span class="col2"><a href="" style="color: #3AB54A;"><?php echo $item->testcat->test_cat; ?> </span></a></p> <p><span class="col1">Questions: </span><span class="col2"><?php echo count($item->question); ?> </span></p> <p><span class="col1">Duration: </span><span class="col2"><?php echo $item['time_test']; ?> </span></p>
public function actionListComment() { $this->layout = '//layouts/column2'; $idshop = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0; $vote_type = isset($_REQUEST['vote_type']) ? $_REQUEST['vote_type'] : ''; $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : ''; $page = isset($_POST['p']) ? $_POST['p'] : 1; $num_per_page = Yii::app()->params->listshop_num_per_page; $total = WUserItem::getCountComment($vote_type, $idshop); //echo $total;exit(); $pageInfo = WFunction::getPagerInfo($total, $page, $num_per_page); //var_dump($pageInfo); exit(); $imagePath = Yii::app()->theme->baseUrl . "/images/"; $page_wap = WFunction::web_pager($total, $pageInfo['cpage'], $num_per_page, Yii::app()->createUrl('wUserItem/listcomment', array('id' => $idshop, 'vote_type' => $vote_type)), $imagePath); $arrListComment = WUserItem::getListComment($vote_type, $idshop, $pageInfo['start'], $num_per_page); $arrShop = WUserItem::getDetailShop($idshop); $this->render('listcomment', array('arrComment' => $arrListComment, 'pageInfo' => $pageInfo, 'model' => $arrShop, 'type' => $type, 'vote_type' => $vote_type)); }
<div class="user-status busy pull-left"> <?php if (!empty($item["content_avatar"])) { $img = Yii::app()->BaseUrl . "/uploads/avatars/user/" . $item["content_avatar"]; } else { $img = Yii::app()->theme->baseUrl . "/img/profile_mask2.png"; } ?> <img class="media-object img-circle pull-left" src="<?php echo $img; ?> " alt="user#1" width="40"> </div> <div class="media-body"> <h5 class="media-heading"><?php echo WFunction::limit_chars(strip_tags($item["content"]), 50); ?> </h5> <small class="text-muted" style="font-size: 11px;"><?php echo date('H:i d/m/Y', strtotime($item["content_created_date"])); ?> </small><br/> <small class="text-muted" style="font-size: 11px;">Chủ đề: <?php echo ucfirst($item["title"]); ?> </small> </div> </div> </a> <?php }
/** * 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)); }
echo Yii::app()->createUrl('wNews/detailnews', array('id' => $news_item['id'])); ?> " title="<?php echo $news_item['news_title']; ?> "><?php echo $news_item['news_title']; ?> </a><br /> <span class="date1"><?php echo $news_item['created_time']; ?> </span><br /> <div class="desc"> <?php echo WFunction::truncate($news_item['news_short_description'], 200); ?> </div> </div> </div> <div class="new_item_bottom"></div> </div> <div class="list"> <div class="news_list_top"></div> <div style="height: 128px; background: #666; padding-left: 3px;"> <?php } else { ?>
?> <?php echo $model->lecture_type == 1 ? Yii::t('web/home', 'pages') : ""; echo $model->lecture_type == 4 ? Yii::t('web/home', 'Slide') : ""; ?> </label> </td> </tr> <tr> <td width="130"><label><?php echo Yii::t('web/home', 'Training Minute'); ?> </label></td> <td> <label><?php echo WFunction::GetMinutes(WLectureText::GetTimeTotalLectureText($model->lecture_id)); ?> <?php echo Yii::t('web/home', 'minutes'); ?> </label> </td> </tr> <?php } elseif ($model->lecture_type != 2) { ?> <tr> <td width="130"><label><?php echo Yii::t('web/home', 'Duration'); ?> </label></td>
</a> </div> <div class="ServiceInfo"> <a href="<?php echo Yii::app()->createUrl('wUserItem/detailshop', array('id' => $value['id'], 'title' => WFunction::convertToAlias($value['title']))); ?> "><b><?php echo $value['title']; ?> </b></a><br /> <p><?php echo WFunction::truncate($value['description'], 140); ?> </p> <a href="<?php echo Yii::app()->createUrl('wUserItem/detailshop', array('id' => $value['id'], 'title' => WFunction::convertToAlias($value['title']))); ?> " style="float: right;">Hiển thị shop...</a> </div> </div> <?php } } else { echo 'Không có shop hoặc sản phẩm nào'; } ?> <div class="jb_pagination"> <?php echo $pageInfo['strPager']; ?> </div>
/** * Trainee thuc hien 1 bai test * @param: $test_id : Test * @param: $course_id: Course **/ public function actionStarttest($test_id, $course_id, $lecture_id) { $this->layout = '//layouts/main_trainer'; $cs = Yii::app()->getClientScript(); $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'); $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 = 1; $model->added_date = date('Y-m-d H:i:s'); //unset(Yii::app()->session['user_test']); //echo $a;exit(); //var_dump($model->isNewRecord);exit(); $oneut = WUserTest::model()->find('test_id=:test_id and course_id=:course_id and lecture_id=:lecture_id and user_id=:user_id', array(':test_id' => $test_id, ':course_id' => $course_id, ':lecture_id' => $lecture_id, ':user_id' => Yii::app()->user->id)); ///var_dump($oneut);exit(); if (is_null($oneut)) { //echo '1';exit(); $model->save(); } else { //echo '2';exit(); //$model->updateByPk($oneut['id'], array('added_date' => date('Y-m-d H:i:s'))); } $per_page = 1; $page_number = isset($_POST['page']) ? $_POST['page'] : 0; $position = $page_number * $per_page; $total = WQuestion::totalQuestion($test_id); //echo $total;exit(); $pagination = WFunction::paging_question($total, $per_page); $test = WTest::model()->find('id=:id', array(':id' => $test_id)); $this->render('/wTest/trainee/starttest', array('course_id' => $course_id, 'lecture_id' => $lecture_id, 'test' => $test, 'pagination' => $pagination, 'total' => $total)); }