Ejemplo n.º 1
0
                }
            }
            $i++;
        }
    }
    ?>
                        </div>
                        <hr />
                        <div class="footer_test">
                            <?php 
    echo $model['footer'];
    ?>
                        </div>
                        <div class="buttons" style="margin:50px 0 100px 0px;">
                            <?php 
    if (!WUserTest::checkUserTested($model['id'])) {
        ?>
                            <a href="<?php 
        echo Yii::app()->createUrl('wTest/Update', array('id' => $model['id']));
        ?>
"><button class="btn btn-success">Edit Test</button></a>
                            <?php 
    }
    ?>
                        </div>
                    </div>
                    <div class="clear"></div>
                <?php 
} else {
    ?>
                        <?php 
Ejemplo n.º 2
0
 public function actionMytrainee()
 {
     $this->layout = '//layouts/main_trainer';
     $data = WUserTest::getMyTest();
     $this->render('mytest', array('data' => $data));
 }
Ejemplo n.º 3
0
        <div class="clear"></div>
    </div>
</div>

<div class="primary_container_test">
    <div class="container_test">
        <div class="primary_container" style="margin-top: 0;">
            <div class="primary_container_body">
                <div id="container_course" style="padding: 0;">
                <?php 
if (!empty($data)) {
    ?>
                    <?php 
    foreach ($data as $key => $item) {
        if (isset($item->test)) {
            $status_test = WUserTest::checkStatus($item['course_id'], $item->test->id);
            ?>
                        <div class="dataList_item_test">
                            <a href="<?php 
            if ($status_test['success'] == 0 || $status_test['success'] == 1) {
                echo Yii::app()->createUrl('wCourseLecture/Introduce', array('course_id' => $item['course_id'], 'lecture_id' => $item['lecture_id'], 'test_id' => $item->test->id));
            } else {
                echo '#';
            }
            ?>
" class="item_direct">
                                <?php 
            if (!empty($item->test->avatar)) {
                ?>
                                <img class="img-thumbnail" src="<?php 
                echo Yii::app()->params['url_base'] . '/uploads/avatars/test/' . $item->test->avatar;
Ejemplo n.º 4
0
        $id = CHtml::encode($item->course->id);
        $id = intval($id);
        $count_test = new WUserTest();
        // var_dump($count_test);
        $results = $count_test->count_filter($id, 'user');
        echo $results;
        ?>
                                </span>
                            </p>
                            <p>
                                <span class="col1">Total Test: </span>
                                <span class="col2">
                                    <?php 
        $id = CHtml::encode($item->course->id);
        $id = intval($id);
        $count_test = new WUserTest();
        // var_dump($count_test);
        $results = $count_test->count_filter($id, 'test');
        echo $results;
        ?>
                                </span>
                            </p>
                        </div>
                        <?php 
        if (!empty($item->course->hot_course) and $item->course->hot_course == 1) {
            ?>
                        <img src="<?php 
            echo Yii::app()->theme->baseUrl;
            ?>
/img/icon-hot.png" class="iconhot" />
                        <?php 
Ejemplo n.º 5
0
                        <tr>
                            <th style="width: 50px; padding-left: 10px;">No</th>
                            <th style="width: 150px;">User name</th>
                            <th style="width: 200px;">Full name</th>
                            <th style="width: 350px;">Company</th>
                            <th style="width: 100px;">Mark</th>
                            <th>Rate</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
if (count($listtrainee) > 0) {
    $i = 1;
    foreach ($listtrainee as $list) {
        if (isset($list)) {
            $arrUT = WUserTest::model()->find('course_id=:course_id and user_id=:user_id and test_id=:test_id', array(':course_id' => $course_id, ':user_id' => $list['trainee_id'], 'test_id' => $test['id']));
            ?>
                            <tr class="<?php 
            if ($i % 2 == 0) {
                echo 'even';
            } else {
                echo 'old';
            }
            ?>
 <?php 
            if (isset($arrUT)) {
                echo 'showresult';
            }
            ?>
" index="<?php 
            echo $arrUT['id'] . '|' . $arrUT['user_id'];
 public function actionMarkTest()
 {
     $arrQuestion = isset($_REQUEST["arrQuestion"]) ? $_REQUEST["arrQuestion"] : array();
     $user_test_id = isset($_REQUEST["user_test_id"]) ? $_REQUEST["user_test_id"] : NULL;
     $json = array("result" => "true");
     if (!empty($arrQuestion)) {
         $checkSave = TRUE;
         foreach ($arrQuestion as $itemquestion) {
             $model = WUserAnswers::model()->find("question_id=" . $itemquestion["idquestion"] . ' AND user_test_id=' . $itemquestion["user_test_id"]);
             if (!empty($model)) {
                 $model->point_answer_text = $itemquestion["point_answer_text"];
                 $model->comment_trainer = $itemquestion["comment_question"];
                 if (!$model->save()) {
                     $checkSave = FALSE;
                 }
             }
         }
         if ($checkSave == TRUE) {
             $arrPointQuestion = array();
             // Lay Point cua cau hoi
             $db = Yii::app()->db;
             $comm = $db->createCommand()->select('t.*,t2.test_name')->from('pls_user_test t')->LeftJoin('pls_test_parent t2', 't2.id=t.test_id')->LeftJoin('pls_course t3', 't3.id=t.course_id')->where('t.id=' . $user_test_id . ' AND t3.created_by=' . Yii::app()->user->id);
             $dataUserTest = $comm->queryRow();
             $comm->reset();
             $comm = $db->createCommand()->select('t.*')->from('pls_test_user t')->where('t.id_test_parent=' . $dataUserTest["test_id"] . ' AND user_id=' . $dataUserTest["user_id"] . ' AND kind=' . $dataUserTest["test_kind"] . ' AND t.course_id=' . $dataUserTest["course_id"] . ' AND t.lecture_id=' . $dataUserTest["lecture_id"]);
             $dataTestUser = $comm->queryRow();
             if (!empty($dataTestUser)) {
                 if (!empty($dataTestUser["dataquestion"])) {
                     $dataquestion = json_decode($dataTestUser["dataquestion"], true);
                     if (!empty($dataquestion)) {
                         foreach ($dataquestion as $itemdataquestion) {
                             $arrPointQuestion[$itemdataquestion["idquestion"]]["point"] = $itemdataquestion["point"];
                             $arrPointQuestion[$itemdataquestion["idquestion"]]["answertrue"] = WQuestionAnswerLib::getAnswerTrueQuestion($itemdataquestion["idquestion"]);
                         }
                     }
                 }
             }
             // Select Nhung cau tra loi cua hoc vien
             $comm->reset();
             $comm = $db->createCommand()->select('t.*')->from('pls_user_answers t')->where('t.user_test_id=' . $user_test_id);
             $dataUserAnswer = $comm->queryAll();
             if (!empty($dataUserAnswer)) {
                 foreach ($dataUserAnswer as $itemdataUserAnswer) {
                     $arrPointQuestion[$itemdataUserAnswer["question_id"]]["question_type"] = $itemdataUserAnswer["question_type"];
                     $arrPointQuestion[$itemdataUserAnswer["question_id"]]["question_id"] = $itemdataUserAnswer["question_id"];
                     $arrPointQuestion[$itemdataUserAnswer["question_id"]]["doing"] = $itemdataUserAnswer["doing"];
                     if ($itemdataUserAnswer["question_type"] == 1 or $itemdataUserAnswer["question_type"] == 4) {
                         $arrPointQuestion[$itemdataUserAnswer["question_id"]]["useranswer"] = $itemdataUserAnswer["user_answer_id"];
                     } elseif ($itemdataUserAnswer["question_type"] == 2) {
                         $arrPointQuestion[$itemdataUserAnswer["question_id"]]["useranswer"] = $itemdataUserAnswer["user_answer_text"];
                     }
                     $arrPointQuestion[$itemdataUserAnswer["question_id"]]["point_answer_text"] = $itemdataUserAnswer["point_answer_text"];
                     $arrPointQuestion[$itemdataUserAnswer["question_id"]]["comment_trainer"] = $itemdataUserAnswer["comment_trainer"];
                 }
             }
             // Kiem tra nhung cau tra loi dung
             $dataNew = array();
             $total_point = 0;
             if (!empty($arrPointQuestion)) {
                 foreach ($arrPointQuestion as $key => $itemPointQuestion) {
                     $dataNew[$key] = $itemPointQuestion;
                     if (!empty($itemPointQuestion["answertrue"])) {
                         if ($itemPointQuestion["question_type"] == 4 or $itemPointQuestion["question_type"] == 1) {
                             // Truong hop nhieu dap an
                             $dataAnswer = explode(',', $itemPointQuestion["useranswer"]);
                             $dataAnswerNew = array();
                             foreach ($dataAnswer as $item) {
                                 if (!empty($item)) {
                                     $dataAnswerNew[] = $item;
                                 }
                             }
                             $check = TRUE;
                             if (count($dataAnswerNew) == count($itemPointQuestion["answertrue"])) {
                                 foreach ($dataAnswerNew as $itemdataAnswerNew) {
                                     if (!in_array($itemdataAnswerNew, $itemPointQuestion["answertrue"])) {
                                         $check = FALSE;
                                     }
                                 }
                             } else {
                                 $check = FALSE;
                             }
                             if ($check == TRUE) {
                                 $dataNew[$key]["check"] = "OK";
                                 $total_point += $itemPointQuestion["point"];
                             } else {
                                 $dataNew[$key]["check"] = "NOK";
                             }
                         }
                     }
                     if ($itemPointQuestion["question_type"] == 2) {
                         if (isset($itemPointQuestion["point_answer_text"])) {
                             $total_point += $itemPointQuestion["point_answer_text"];
                         }
                     }
                 }
             }
             // Luu ket qua vao database
             $model = WTestUser::model()->find('user_id=' . $dataUserTest["user_id"] . ' AND id_test_parent=' . $dataUserTest["test_id"] . ' AND kind=' . $dataUserTest["test_kind"] . ' AND course_id=' . $dataUserTest["course_id"] . ' AND lecture_id=' . $dataUserTest["lecture_id"]);
             $model->datafinish = json_encode($dataNew);
             $model->save();
             $modelUserTest = WUserTest::model()->find('id=' . $user_test_id);
             $modelUserTest->pass_score_point = $total_point;
             $modelUserTest->success = 2;
             if ($modelUserTest->save()) {
                 //$testDetails = WTest::model()->find("id=".$test_id);
                 $username = WUser::getFullNameUser($dataUserTest["user_id"]);
                 $trainer = WUser::getFullNameUser(Yii::app()->user->id);
                 $title = "Giáo viên " . $trainer . " đã chấm bài test: " . $dataUserTest["test_name"] . " của bạn";
                 if (!empty($dataUserTest["success"]) and $dataUserTest["success"] == 2) {
                     $title = "Giáo viên " . $trainer . " đã chấm bài lại test: " . $dataUserTest["test_name"] . " của bạn";
                 }
                 $content = "Dear <strong>" . $username . "</strong>";
                 //$content .="<br/>Bài làm Test :".$testDetails->test_name." của bạn đã được Giáo viên: <strong>".$trainer.'</strong> chấm xong';
                 $content .= "<br/>Giáo viên <strong>" . $trainer . '</strong> đã chấm bài: <strong>"' . $dataUserTest["test_name"] . '"</strong> của bạn';
                 $url = Yii::app()->createUrl("wCourseLecture/Viewresult", array("user_test_id" => $dataUserTest["id"]));
                 $content .= "<br/><a href='" . $url . "'>Click Để xem kết quả bài test</a>";
                 WMessage::SendMessage($title, $content, "notifi", Yii::app()->user->id, $dataUserTest["user_id"]);
                 $json = array("result" => "true");
             }
         } else {
             $json = array("result" => "false", "message" => "");
         }
     }
     echo json_encode($json);
 }
 /**
  * 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 WUserTest the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = WUserTest::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 8
0
<?php

/* @var $this WTestController */
/* @var $model WTest */
$this->breadcrumbs = array('Test' => array('index'), 'Update Test');
$idtest = isset($_REQUEST["id"]) ? $_REQUEST["id"] : NULL;
$testUse = FALSE;
if (empty($idtest)) {
    $this->redirect(Yii::app()->createUrl(""));
} else {
    $dataUserTest = WUserTest::model()->find("test_id=" . $idtest);
    if (!empty($dataUserTest)) {
        $testUse = TRUE;
    }
}
?>
<div class="primary_boxtop">
    <div class="primary_boxtop_content">
        <h1 class="fl"><img src="<?php 
echo Yii::app()->theme->baseUrl;
?>
/img/btn_add.png" align="middle" alt="Test" />Update Test</h1>
        <a style="float: right; margin-right: 10px; margin-top: 20px;" class="btn btn-warning" href="javascript:history.go(-1);">Trở về</a>
        <div class="clear"></div>
    </div>
</div>
<div class="primary_container">
    <div class="primary_container_test" style="box-shadow: 0px 0px 0px; border: 0px; ">
        <div class="container_test">
            <div class="box_test">
            <div class="primary_page_edit">
Ejemplo n.º 9
0
 // khong co pre test
 if (time() > strtotime($item['end_date'])) {
     echo "<span class='label label-default'>" . Yii::t('web/home', 'Not Finish') . "</span>";
 } 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"])) {
             //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>';
                 }
             }
         } else {
             //Khong co bai Pos Test
Ejemplo n.º 10
0
            if (!empty($value_lecture["pre_test_id"])) {
                $dataPreTest = WUserTest::getPointTest($data_user["id"], 1, $value_lecture["pre_test_id"], $value_lecture["course_id"], $value_lecture["lecture_id"]);
                if (!empty($dataPreTest) and !empty($dataPreTest["pass_score_point"])) {
                    $resultPretest = $dataPreTest["pass_score_point"];
                } else {
                    $resultPretest = "0";
                }
                if ($resultPretest / $value_lecture["pre_total_point"] * 100 > 50) {
                    $style = "color:green";
                } else {
                    $style = "color:red";
                }
                $pre_test = '<span style="' . $style . '">' . $resultPretest . "/" . $value_lecture["pre_total_point"] . '</span>';
            }
            if (!empty($value_lecture["post_test_id"])) {
                $dataPostTest = WUserTest::getPointTest($data_user["id"], 0, $value_lecture["post_test_id"], $value_lecture["course_id"], $value_lecture["lecture_id"]);
                if (!empty($dataPostTest) and !empty($dataPostTest["pass_score_point"])) {
                    $resultPosttest = $dataPostTest["pass_score_point"];
                    $post_test_check = TRUE;
                } else {
                    $resultPosttest = "0";
                }
                if ($resultPosttest / $value_lecture["post_total_point"] * 100 > 50) {
                    $style = "color:green";
                } else {
                    $style = "color:red";
                }
                $post_test = '<span style="' . $style . '">' . $resultPosttest . "/" . $value_lecture["post_total_point"] . '</span>';
            }
            ?>
 /**
  * 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'));
     }
 }
Ejemplo n.º 12
0
$arrQues = WQuestion::model()->findAll('test_id=:test_id', array(':test_id' => $data->test->id));
$i = 1;
foreach ($arrQues as $ques) {
    if ($ques['question_type'] == 2) {
        $arrUA = WUserAnswers::model()->find('question_id=:question_id and user_test_id=:user_test_id', array(':question_id' => $ques['id'], ':user_test_id' => $user_test_id));
        $strWrite .= '<div class="quesw"><span style="font-weight: bold;">' . Yii::t('web/home', 'Question') . ' ' . $i . '</span> (' . $ques['point'] . ' ' . Yii::t('web/home', 'points') . ')</div>
                                <div class="name_ques">' . $ques['question_text'] . '</div>
                                <input type="hidden" id="pointstr" value="' . $ques['point'] . '" />
                                <div class="ans" style="font-style: italic;">' . Yii::t('web/home', 'Answer') . ':</div>
                                <div class="answer">
                                    <p>' . $arrUA['user_answer_text'] . '</p>
                                </div>';
        if ($arrUA['user_answer_text'] != '') {
            $name_ques = $ques['question_text'];
            //$q_id      = $ques['id'];
            $point = WUserTest::model()->find('id=:id', array(':id' => $user_test_id));
            $strChoice .= '<tr><td style="text-align:left;padding-left: 48px;">' . Yii::t('web/home', 'Question') . ' ' . $i . ': ' . $name_ques . '</td><td>Writing</td><td>' . $point['point_text'] . '</td></tr>';
        }
    } elseif ($ques['question_type'] == 1 || $ques['question_type'] == 4) {
        $name_ques = $ques['question_text'];
        //$q_id      = $ques['id'];
        if (WUserAnswers::checkAnswer($ques['id'], $ques['question_type'], $user_test_id)) {
            $img = '<img src="' . Yii::app()->theme->baseUrl . '/img/true.png" />';
            $point = $ques['point'];
        } else {
            $img = '<img src="' . Yii::app()->theme->baseUrl . '/img/fail.png" />';
            $point = 0;
        }
        $strChoice .= '<tr><td style="text-align:left;padding-left: 48px;">' . Yii::t('web/home', 'Question') . ' ' . $i . ': ' . $name_ques . '</td><td>' . $img . '</td><td>' . $point . '</td></tr>';
    }
    $i++;
Ejemplo n.º 13
0
                if (isset($item->course)) {
                    echo CHtml::encode($item->course->course_name);
                }
                ?>
</span></p>
                        <p><span class="col1"><?php 
                echo Yii::t('web/home', 'Lecture');
                ?>
: </span><span class="col2"><?php 
                if (isset($item->lecture)) {
                    echo CHtml::encode($item->lecture->lecture_name);
                }
                ?>
</span></p>
                        <?php 
                if (WUserTest::checkTestText($item['test_id'])) {
                    ?>
                        <h3 style="font-size: 12px; color:#3ab54a; margin-top: 0;">This test is contain question type of writing.</h3>
                        <?php 
                }
                ?>
                        <!--<p><span class="col1">Status: </span><span class="col2"><?php 
                if ($item['status'] == 0 && $item['success'] == 2) {
                    echo '<span style="color:red;">Waiting Evalute<span>';
                } elseif ($item['status'] == 1 && $item['success'] == 2) {
                    echo '<span style="color:green;">Evaluted</span>';
                }
                ?>
</span></p>-->

                        <p style="padding-top: 10px; padding-left: 110px;"><span class="col1"><a href="<?php 
 /**
  * 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 actionDeletetest()
 {
     $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
     $arrJson = array();
     WUserTest::deleteUserTestByTest($id);
     if ($this->loadModel($id)->delete() && WCourseLecture::updateTestPreTest($id) && WQuestion::deleteQues($id)) {
         $arrJson = array('status' => true, 'msg' => 'Success');
     } else {
         $arrJson = array('status' => false, 'msg' => 'UnSuccess');
     }
     echo CJSON::encode($arrJson);
     exit;
 }
Ejemplo n.º 15
0
                                }
                            }
                        } else {
                            $check = FALSE;
                        }
                        if ($check == TRUE) {
                            $dataNew[$itemquestion["idquestion"]]["check"] = "OK";
                            $totalpointuser += $dataNew[$itemquestion["idquestion"]]["point"];
                        } else {
                            $dataNew[$itemquestion["idquestion"]]["check"] = "NOK";
                        }
                    }
                }
            }
            if ($item["success"] == 2) {
                $dataUpdateUserTest = WUserTest::model()->find("id=" . $item["user_test_id"]);
                $dataUpdateUserTest->pass_score_point = $totalpointuser;
                $dataUpdateUserTest->save();
                $datafinish = $dataNew;
                $modelTestUser = WTestUser::model()->find("user_id=" . $data_user_id . " AND course_id=" . $data_course_id . ' AND lecture_id=' . $data_lecture_id . ' AND kind=' . $data_test_kind . ' AND id_test_parent=' . $data_test_id);
                $modelTestUser->datafinish = json_encode($datafinish);
                $modelTestUser->save();
            }
        }
        $datafinish = WTestUser::GetDataAnswer($datafinish);
        if (isset($datafinish["total_check"])) {
            ?>
<!--                            <p style="margin-bottom: 2px;">Trả lời đúng <strong style="color: #D30C0C">--><?php 
            //echo $datafinish["total_true"]
            ?>
<!--/--><?php 
Ejemplo n.º 16
0
            //2 truong hop Lecture Ok va Lecture NOK
            if (empty($dataTrainingLog) or $dataTrainingLog['result'] == 'NOK') {
                //truong hop Null va NOK
                ?>
                                <a id="btnContinueTest" disabled="disabled" href="<?php 
                echo Yii::app()->createUrl('wCourseLecture/Introduce', array('course_id' => $model->course_id, 'lecture_id' => $model->lecture_id, 'test_id' => $model->test_id, 'kind' => 0));
                ?>
" class="btn btn-default">Do Post Test</a>
                                <?php 
            } elseif (!empty($dataTrainingLog) and $dataTrainingLog['result'] == 'OK') {
                //truong hop OK
                //co 2 truong hop
                //Da lam bai test va chua lam bai test
                if (WUserTest::checkTestSuccess($model->course_id, $model->lecture_id, $model->test_id, Yii::app()->user->id, 0) == TRUE) {
                    //Da lam bai test
                    $dataUsetTest = WUserTest::model()->find("course_id=" . $model->course_id . ' AND lecture_id=' . $model->lecture_id . ' AND test_id=' . $model->test_id . ' AND user_id=' . Yii::app()->user->id . ' AND test_kind=0');
                    if (!empty($dataUsetTest)) {
                        ?>
                                        <a id="btnContinueTest" href="<?php 
                        echo Yii::app()->createUrl('wCourseLecture/Viewresult', array('user_test_id' => $dataUsetTest->id));
                        ?>
" class="btn btn-default" ><?php 
                        echo Yii::t('web/home', 'You did the test. View Test Result');
                        ?>
</a>
                                        <?php 
                    } else {
                        ?>
                                    ?>
                                    <a id="btnContinueTest" href="<?php 
                        echo Yii::app()->createUrl('wCourseLecture/posttest', array('course_id' => $model->course_id, 'lecture_id' => $model->lecture_id, 'test_id' => $model->test_id, 'kind' => 0));
Ejemplo n.º 17
0
 public static function getTotalPoint($user_test_id)
 {
     $criteria = new CDbCriteria();
     $criteria->distinct = true;
     $criteria->select = 'question_id';
     $rs = self::model()->findAll($criteria);
     $total = 0;
     $oneUT = WUserTest::model()->find('id=:id', array(':id' => $user_test_id));
     if ($rs) {
         foreach ($rs as $r) {
             if (self::checkAnswer($r['question_id'], $r->questions->question_type, $user_test_id)) {
                 $total = $total + $r->questions->point;
             }
         }
         return $total + $oneUT['point_text'];
     }
 }
Ejemplo n.º 18
0
</th>
                            <th style="width: 100px;"><?php 
echo Yii::t('web/home', 'Mark');
?>
</th>
                            <th>Rate</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
if (count($listtrainee) > 0) {
    $i = 1;
    foreach ($listtrainee as $list) {
        if (isset($list->pls_user)) {
            $arrUT = WUserTest::model()->find('course_id=:course_id and user_id=:user_id and test_id=:test_id and test_kind=:test_kind', array(':course_id' => $course_id, ':user_id' => $list['trainee_id'], 'test_id' => $test['id'], ':test_kind' => $_REQUEST['kind']));
            $flag_text = WUserTest::checkDoTestText($arrUT['id']);
            ?>
                            <tr class="<?php 
            if ($i % 2 == 0) {
                echo 'even';
            } else {
                echo 'old';
            }
            ?>
 <?php 
            if (isset($arrUT)) {
                echo 'showresult';
            }
            ?>
" index="<?php 
            echo $arrUT['id'] . '|' . $arrUT['user_id'];
Ejemplo n.º 19
0
 public static function listMyTest($test_id = NULL, $course_id = NULL, $lecture_id = NULL, $test_kind = NULL)
 {
     $criteria = new CDbCriteria();
     $where = '';
     if (!empty($test_id)) {
         $where .= ' and test_id=' . $test_id;
     }
     if (!empty($course_id)) {
         $where .= ' and course_id=' . $course_id;
     }
     if (!empty($lecture_id)) {
         $where .= ' and lecture_id=' . $lecture_id;
     }
     if ($test_kind != NULL) {
         $where .= ' and test_kind=' . $test_kind;
     }
     $criteria->condition = 'user_id=:user_id and success=:success' . $where;
     $criteria->params = array(':user_id' => Yii::app()->user->id, ':success' => 2);
     $criteria->order = 'finish_date DESC';
     $rs = WUserTest::model()->findAll($criteria);
     if ($rs) {
         return $rs;
     } else {
         return null;
     }
 }
 /**
  * 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()));
 }