Exemplo n.º 1
0
 /**
  * Creates a new Pregunta model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pregunta();
     $modelRespuestaExamen = [new RespuestaExamen()];
     $model->load(Yii::$app->request->post());
     $modelRespuestaExamen = DynamicFormModel::createMultiple(RespuestaExamen::className());
     DynamicFormModel::loadMultiple($modelRespuestaExamen, Yii::$app->request->post());
     $valid = $model->validate() && DynamicFormModel::validateMultiple($modelRespuestaExamen);
     if ($valid) {
         $this->negocio->savePregunta1($model, $modelRespuestaExamen);
         $dataProvider = new ActiveDataProvider(['query' => RespuestaExamen::find()->where(['id_pregunta' => $model->id])->orderBy('id')]);
         return $this->redirect(['view', 'id' => $model->id, 'dataProvider' => $dataProvider]);
     } else {
         return $this->render('create', ['model' => $model, 'modelRespuestaExamen' => empty($modelsRespuestaExamen) ? [new RespuestaExamen()] : $modelsRespuestaExamen]);
     }
 }
Exemplo n.º 2
0
 /**
  * Lists all RespuestaExamen models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => RespuestaExamen::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 3
0
            <div class="container-items"><!-- widgetBody -->
            <?php 
foreach ($preguntas as $i => $pregunta) {
    ?>
                <div class="item panel panel-default"><!-- widgetItem -->
                    <div class="panel-heading">
                        <h3 class="panel-title pull-left"><?php 
    echo $pregunta->nro_pregunta . "-" . $pregunta->descripcion_pregunta;
    ?>
</h3>
                        <div class="clearfix"></div>
                    </div>
                    <div class="panel-body">
                        
                        <?php 
    echo $form->field($respuestasAlumno[$i], "[{$i}]id_respuesta")->radioList(ArrayHelper::map(RespuestaExamen::find()->where(['id_pregunta' => $pregunta->id])->all(), 'id', 'descripcion_respuesta'))->label(false);
    $form->field($respuestasAlumno[$i], "[{$i}]id_inscripcion", ['options' => ['value' => $idInscripcion]])->hiddenInput()->label(false);
    ?>
                    </div>
                </div>
            <?php 
}
?>
            </div>
        </div>
    </div><!-- .panel -->
    <?php 
DynamicFormWidget::end();
?>
    <div class="form-group">
        <?php