public function actionSoal($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 Quizsoal();
                     $kuissoal->id_quiz = $id;
                     $kuissoal->id_soal = $soal->id_soal;
                     if ($kuissoal->save()) {
                         //redirect to index page
                         $this->redirect(array('quiz/viewSoalQuiz', 'id' => $id));
                     } 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));
 }