コード例 #1
0
 public function actionViewSoalQuiz($id)
 {
     $hasil = Quizsoal::model()->findAllByAttributes(array('id_quiz' => $id));
     $soalkuis = new Quizsoal('search');
     $soalkuis->id_quiz = $id;
     $kosong = 0;
     if ($_POST['Submit_jawaban']) {
         if (count($_POST['jawaban']) < 1) {
             echo "Anda belum menjawab soal satupun ";
         } else {
             $Jawaban = "";
             $nomor = 1;
             //var_dump($_POST['NomorSoal']);
             //                echo "*";
             for ($i = 1; $i <= $_POST['NomorSoal']; $i++) {
                 if ($_POST['jawaban']["{$i}"] == NULL) {
                     $Jawaban .= "#";
                     $kosong += 1;
                 } else {
                     $Jawaban .= $_POST['jawaban']["{$i}"];
                 }
             }
             //echo $Jawaban;
             $encode = Soal::model()->getJawaban($id);
             //echo "<br>";
             $count = 0;
             $wrong = 0;
             for ($i = 0; $i < $_POST['NomorSoal']; $i++) {
                 //        echo $_POST['jawaban'][$i];
                 //echo $encode[$i]["jawaban"];
                 //          echo "*";
                 if ($_POST['jawaban'][$i + 1] == $encode[$i]["jawaban"]) {
                     //secho "<br>", $_POST['jawaban']["$i"]," dan ",$encode[$i]["jawaban"];
                     $count += 1;
                 } else {
                     $wrong += 1;
                 }
             }
             //var_dump($encode);
         }
     }
     //echo "<br>Anda benar : ",$count," dari ",$_POST['NomorSoal'], " soal";
     $nilai = 100 / $_POST['NomorSoal'] * $count;
     // echo "<br>",$nilai;
     $name = Yii::app()->user->name;
     $koneksi_server = mysqli_connect('localhost', 'root', '', 'toefl');
     if (mysqli_connect_errno()) {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
     mysqli_query($koneksi_server, "INSERT INTO t_grade(username,jawaban,grade)\n        VALUES ('{$name}', '{$Jawaban}','{$nilai}')");
     mysqli_close($koneksi_server);
     //}
     if (!isset($_POST['Submit_jawaban'])) {
         $this->render('ViewSoalQuiz', array('model' => $soalkuis, 'hasil' => $hasil));
     } else {
         $this->render('HasilQuiz', array('wew' => $nilai, 'wow' => $kosong, 'waw' => $wrong, 'wuw' => $count));
     }
 }
コード例 #2
0
ファイル: _soal.php プロジェクト: jumper2012/english_learning
    if ($f->idSoal->id_file != NULL) {
        ?>
<tr>
                    <td></td>
                    <td>
                        <?php 
        if (CHtml::encode(Soal::model()->namaWBS($f->idSoal->id_file)) == 'L') {
            $fileData = CHtml::encode(Soal::model()->namaSubWBS($f->idSoal->id_file));
            if (strlen($fileData) > 6) {
                $this->widget('ext.mediaElement.MediaElementPortlet', array('url' => Yii::app()->request->baseUrl . '/music/test/' . CHtml::encode(Soal::model()->namaSubWBS($f->idSoal->id_file)), 'mimeType' => 'audio/mp3'));
            }
        } else {
            if (CHtml::encode(Soal::model()->namaWBS($f->idSoal->id_file)) == "R") {
                $fileData = CHtml::encode(Soal::model()->namaSubWBS($f->idSoal->id_file));
                if (strlen($fileData) > 6) {
                    echo CHtml::link(CHtml::encode(Soal::model()->namaSubWBS($f->idSoal->id_file)), Yii::app()->baseUrl . '/document/test/' . CHtml::encode(Soal::model()->namaSubWBS($f->idSoal->id_file)));
                }
            }
        }
        ?>
                    </td>
                </tr><?php 
        echo $data->file;
    }
    ?>

            <tr style="width:5px">
                <td style="width:5px">
                    <?php 
    echo $id . ". ";
    ?>
コード例 #3
0
 public function actionViewSoalToeflTest($id)
 {
     //Koneksi ke Database
     $con = mysqli_connect('localhost', 'root', '', 'toefl');
     // Check connection
     if (mysqli_connect_errno()) {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
     $result = mysqli_query($con, "SELECT * FROM t_modultest where id_toefl = " . $id . " LIMIT 1");
     while ($row = mysqli_fetch_array($result)) {
         $idModulTest = $row['id_modulTest'];
         //idModulTest = 15
     }
     $hasil = Modultestsoal::model()->findAllByAttributes(array('id_modultest' => $idModulTest));
     $soalToefl = new Modultestsoal('search');
     $soalToefl->id_modultest = $idModulTest;
     //Hitung Score
     $kosong = 0;
     if ($_POST['Submit_jawaban_sementara']) {
         if (count($_POST['jawaban']) < 1) {
             echo "Anda belum menjawab soal satupun ";
         } else {
             $Jawaban = "";
             $nomor = 1;
             //var_dump($_POST['NomorSoal']);
             //echo "*";
             for ($i = 1; $i <= $_POST['NomorSoal']; $i++) {
                 if ($_POST['jawaban']["{$i}"] == NULL) {
                     $Jawaban .= "#";
                     $kosong += 1;
                 } else {
                     $Jawaban .= $_POST['jawaban']["{$i}"];
                 }
             }
             // echo $Jawaban ."<BR>";
             // echo $id."<BR>";
             $encode = Soal::model()->getJawabanToefl($idModulTest);
             //echo "<br>";
             //           var_dump($encode);
             $count = 0;
             $wrong = 0;
             for ($i = 0; $i < $_POST['NomorSoal']; $i++) {
                 //echo $_POST['jawaban'][$i];
                 //echo $encode[$i]["jawaban"];
                 //echo "*";
                 if ($_POST['jawaban'][$i + 1] == $encode[$i]["jawaban"]) {
                     //echo "<br>", $_POST['jawaban']["$i"]," dan ",$encode[$i]["jawaban"];
                     $count += 1;
                 } else {
                     $wrong += 1;
                 }
             }
             //var_dump($encode);
         }
     }
     //$nilai = (100 / $_POST['NomorSoal']) * $count;
     // echo "<br>",$nilai;
     //$name = Yii::app()->user->name;
     //$koneksi_server = mysqli_connect('localhost', 'root', '', 'toefl');
     //if (mysqli_connect_errno()) {
     //    echo "Failed to connect to MySQL: " . mysqli_connect_error();
     //}
     //mysqli_query($koneksi_server, "INSERT INTO t_grade(username,jawaban,grade)
     //        VALUES ('$name', '$Jawaban','$nilai')");
     //mysqli_close($koneksi_server);
     //}
     //Table Nilai
     $ScoreSesi1 = array(24, 25, 26, 27, 28, 29, 30, 31, 32, 32, 33, 35, 37, 38, 39, 41, 41, 42, 43, 44, 45, 45, 46, 47, 47, 48, 48, 49, 49, 50, 51, 51, 52, 52, 53, 54, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68);
     $ScoreSesi2 = array(20, 20, 21, 22, 23, 25, 26, 27, 29, 31, 33, 35, 36, 37, 38, 40, 40, 41, 43, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 63, 65, 67, 68);
     $ScoreSesi3 = array(21, 22, 23, 23, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 43, 44, 45, 46, 46, 47, 48, 48, 49, 50, 51, 52, 52, 53, 54, 54, 55, 56, 57, 58, 59, 60, 61, 63, 65, 66, 67);
     $Score = Yii::app()->user->getState('Score');
     if (!isset($_POST['Submit_jawaban_sementara'])) {
         $result = mysqli_query($con, "SELECT * FROM t_modultest where id_toefl = " . $id);
         $UrutanTemp = 0;
         $UrutanModul = 0;
         $NextModul = 0;
         while ($row = mysqli_fetch_array($result)) {
             $UrutanTemp++;
             if ($UrutanModul != 0) {
                 $NextModul = $row['id_modulTest'];
                 break;
             }
             if ($row['id_modulTest'] == $idModulTest) {
                 $UrutanModul = $UrutanTemp;
             }
         }
         $this->render('ViewSoalToeflSementara', array('model' => $soalToefl, 'hasil' => $hasil, 'NextModul' => $NextModul, 'UrutanModul' => $UrutanModul));
     } else {
         if (isset($_POST['Submit_jawaban_sementara'])) {
             $NextModul = $_POST['NextModul'];
             $UrutanModul = $_POST['UrutanModul'];
             if ($UrutanModul == 2) {
                 $Score += $ScoreSesi1[$count];
                 Yii::app()->user->setState('Score', $Score);
                 $hasil = Modultestsoal::model()->findAllByAttributes(array('id_modultest' => $NextModul));
                 $soalToefl = new Modultestsoal('search');
                 $soalToefl->id_modultest = $NextModul;
                 $result = mysqli_query($con, "SELECT * FROM t_modultest where id_modulTest = " . $NextModul);
                 while ($row = mysqli_fetch_array($result)) {
                     $idToefl = $row['id_toefl'];
                 }
                 $result = mysqli_query($con, "SELECT * FROM t_modultest where id_toefl = " . $idToefl);
                 $UrutanTemp2 = 0;
                 $UrutanModul2 = 0;
                 $NextModul2 = 0;
                 while ($row = mysqli_fetch_array($result)) {
                     $UrutanTemp2++;
                     if ($UrutanModul2 != 0) {
                         $NextModul2 = $row['id_modulTest'];
                         break;
                     }
                     if ($row['id_modulTest'] == $NextModul) {
                         $UrutanModul2 = $UrutanTemp2;
                     }
                 }
                 $this->render('ViewSoalToeflSementara', array('model' => $soalToefl, 'hasil' => $hasil, 'NextModul' => $NextModul2, 'UrutanModul' => $UrutanModul2));
             } else {
                 if ($UrutanModul == 3) {
                     $Score += $ScoreSesi2[$count];
                     Yii::app()->user->setState('Score', $Score);
                     $hasil = Modultestsoal::model()->findAllByAttributes(array('id_modultest' => $NextModul));
                     $soalToefl = new Modultestsoal('search');
                     $soalToefl->id_modultest = $NextModul;
                     $result = mysqli_query($con, "SELECT * FROM t_modultest where id_modulTest = " . $NextModul);
                     while ($row = mysqli_fetch_array($result)) {
                         $idToefl = $row['id_toefl'];
                     }
                     $result = mysqli_query($con, "SELECT * FROM t_modultest where id_toefl = " . $idToefl);
                     $UrutanTemp2 = 0;
                     $UrutanModul2 = 0;
                     $NextModul2 = 0;
                     while ($row = mysqli_fetch_array($result)) {
                         $UrutanTemp2++;
                         if ($UrutanModul2 != 0) {
                             $NextModul2 = $row['id_modulTest'];
                             break;
                         }
                         if ($row['id_modulTest'] == $NextModul) {
                             $UrutanModul2 = $UrutanTemp2;
                         }
                     }
                     $this->render('ViewSoalToeflSementara', array('model' => $soalToefl, 'hasil' => $hasil, 'NextModul' => $NextModul2, 'UrutanModul' => $UrutanModul2));
                 } else {
                     $Score += $ScoreSesi3[$count];
                     $SS = $Score;
                     $Score /= 3;
                     $Score *= 10;
                     Yii::app()->user->setState('Score', $Score);
                     $name = Yii::app()->user->name;
                     mysqli_query($con, "INSERT INTO t_grade(username,jawaban,grade)\n                    VALUES ('{$name}', '{$Jawaban}','{$Score}')");
                     $result = mysqli_query($con, "SELECT * FROM t_grade WHERE username = '******'");
                     while ($row = mysqli_fetch_array($result)) {
                         $idGrade = $row['id_grade'];
                     }
                     mysqli_query($con, "INSERT INTO t_toeflgrade(id_toefl, id_grade)\n                    VALUES ({$id}, {$idGrade})");
                     $this->render('HasilToefl', array('wew' => $Score, 'wow' => $idGrade, 'waw' => $id, 'wuw' => $count, 'dat' => $result));
                 }
             }
         }
     }
     mysqli_close($con);
 }
コード例 #4
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 Soal the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Soal::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #5
0
 public function storeSoal()
 {
     $lab_id = Input::get('lab_id');
     $praktikum_id = Input::get('praktikum_id');
     $modul_id = Input::get('modul_id');
     $soal = new Soal();
     $soal->soal_text = Input::get('soal_text');
     $soal->soal_point = Input::get('soal_point');
     $soal->soal_type = Input::get('soal_type');
     $soal->quiz_id = Input::get('quiz_id');
     $soal->save();
     $soals = DB::table('tb_soal')->orderBy('soal_id', 'desc')->first();
     if (Input::get('soal_type') == 1) {
         $jawaban = new Jawaban();
         $jawaban->jawaban_text = Input::get('pilihanA');
         $jawaban->jawaban_benar = Input::get('kunciSoalA');
         $jawaban->soal_id = $soals->soal_id;
         $jawaban->save();
         $jawaban = new Jawaban();
         $jawaban->jawaban_text = Input::get('pilihanB');
         $jawaban->jawaban_benar = Input::get('kunciSoalB');
         $jawaban->soal_id = $soals->soal_id;
         $jawaban->save();
         $jawaban = new Jawaban();
         $jawaban->jawaban_text = Input::get('pilihanC');
         $jawaban->jawaban_benar = Input::get('kunciSoalC');
         $jawaban->soal_id = $soals->soal_id;
         $jawaban->save();
         $jawaban = new Jawaban();
         $jawaban->jawaban_text = Input::get('pilihanD');
         $jawaban->jawaban_benar = Input::get('kunciSoalD');
         $jawaban->soal_id = $soals->soal_id;
         $jawaban->save();
         $jawaban = new Jawaban();
         $jawaban->jawaban_text = Input::get('pilihanE');
         $jawaban->jawaban_benar = Input::get('kunciSoalE');
         $jawaban->soal_id = $soals->soal_id;
         $jawaban->save();
     } else {
         $jawaban = new Jawaban();
         $jawaban->jawaban_text = Input::get('jawaban');
         $jawaban->jawaban_benar = 'true';
         $jawaban->soal_id = $soals->soal_id;
         $jawaban->save();
     }
     return Redirect::to('lab/' . $lab_id . '/praktikum/' . $praktikum_id . '/modul/' . $modul_id . '/listsoal/' . $soals->soal_id);
 }
コード例 #6
0
 public function actionSoalToefl($id)
 {
     $rnd = rand(0, 9999);
     $inputSoal = new InputSoal();
     if (isset($_POST['InputSoal'])) {
         $inputSoal->attributes = $_POST['InputSoal'];
         if ($inputSoal->validate()) {
             //create a file model
             $file = new File();
             $uploadedFile = CUploadedFile::getInstance($inputSoal, 'file');
             $fileName = "{$rnd}-{$uploadedFile}";
             $file->file = $fileName;
             $file->jenis = $inputSoal->jenis;
             if ($file->save()) {
                 //if(!empty($uploadedFile))
                 //$uploadedFile=CUploadedFile::getInstance($file,'file');
                 if (isset($uploadedFile)) {
                     if ($inputSoal->jenis == 'L') {
                         $uploadedFile->saveAs(Yii::app()->basePath . '/../music/test/' . $fileName);
                     } else {
                         if ($inputSoal->jenis == 'R') {
                             $uploadedFile->saveAs(Yii::app()->basePath . '/../document/test/' . $fileName);
                         }
                     }
                 }
                 $soal = new Soal();
                 $soal->attributes = $inputSoal->attributes;
                 $soal->id_file = $file->id_file;
                 if ($soal->save()) {
                     $kuissoal = new Modultestsoal();
                     $kuissoal->id_modultest = $id;
                     $kuissoal->id_soal = $soal->id_soal;
                     if ($kuissoal->save()) {
                         //redirect to index page
                         //Koneksi ke Database
                         $con = mysqli_connect('localhost', 'root', '', 'toefl');
                         // Check connection
                         if (mysqli_connect_errno()) {
                             echo "Failed to connect to MySQL: " . mysqli_connect_error();
                         }
                         $result = mysqli_query($con, "SELECT * FROM t_modultest where id_modulTest = " . $id);
                         while ($row = mysqli_fetch_array($result)) {
                             $idToefl = $row['id_toefl'];
                             //idModulTest = 15
                         }
                         $this->redirect(array('modulTest/viewSoalToeflTest', 'id' => $idToefl));
                     } else {
                         //get the error message
                         $inputSoal->addErrors($soal->getErrors());
                     }
                 } else {
                     //get the error message
                     $inputSoal->addErrors($soal->getErrors());
                 }
             } else {
                 //get the error message
                 $inputSoal->addErrors($soal->getErrors());
             }
         } else {
             //get the error message
             $inputSoal->addErrors($file->getErrors());
         }
     }
     //display input soal-form
     $this->render('Soal', array('model' => $inputSoal));
 }