Ejemplo n.º 1
0
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
$model = Exams::findOne($id);
?>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['Message', 'MaxScore', 'NumQuestions']]);
?>
    
    
    <?php 
$result = ExamStudent::findOne(['ExamId' => $id, 'StudentId' => Yii::$app->user->identity->UserID]);
if ($result) {
    echo '<h3>Score: ' . $result->Score . '</h3>';
} else {
    echo '<h2>Questions</h2> <br />';
    $i = 1;
    $questions = ExamQuestion::findAll(['ExamId' => $id]);
    $form = ActiveForm::begin(['method' => 'post', 'action' => 'index.php?r=exams%2Fsubmitexam']);
    foreach ($questions as $question) {
        echo '<p> #' . $i . '. ' . $question->Question . '</p>';
        $choices = ExamQuestionChoices::findAll(['ExamQuestionId' => $question->ExamQuestionId]);
        foreach ($choices as $choice) {
            echo '<input type="radio" name="' . $question->ExamQuestionId . '" id="' . $choice->ExamQuestionChoicesId . '" value="' . $choice->ExamQuestionChoicesId . '" /><label for="' . $choice->ExamQuestionChoicesId . '"> ' . $choice->ChoiceDescription . '</label><br />';
        }
        echo '<br /><br />';
        $i++;