<?php include "valida.php"; define('AT_INCLUDE_PATH', 'include/'); include_once AT_INCLUDE_PATH . 'funciones_bd.php'; $phase = $_GET['phase']; $paso = $_GET['step']; if (!$phase && !$paso) { return false; } elseif ($paso == "0") { return false; } $data_connection = new funciones_BD(); //obteniendo el conjunto de preguntas para un paso: $res_consulta = $data_connection->getQuestionsForStep($paso); //creando el array de elementos $questions_load = array(); while ($pregunta = mysql_fetch_array($res_consulta, MYSQL_ASSOC)) { $questions_load[$pregunta['id_pregunta']] = $pregunta['enunciado']; } //para depuracion y verificar si el array de elementos que se pasa al componente select se esta creando bien: //print_r($steps_load); /** *El siguiente codigo HTML se reemplaza en el div que se llama pasoAjax de la pagina add_questions.php */ ?> <div class="col-lg-12"> <table class="table table-responsive table-striped table-hover "> <thead> <tr>
$pregunta_data_results = $conn->getQuestionDataByID($id_pregun); $preg_data = mysql_fetch_array($pregunta_data_results, MYSQL_ASSOC); //agregandole al array la respuesta que tiene asociada la pregunta: $preg_data['resp_pregunta'] = $valor_resp; //agregando el intento: $preg_data['intento'] = $intento_pregunt; //agregando el intento en el que esta el estudiante despues de que ha enviado el test por primera vez: $preg_data['intento_respond'] = $intento_resp_preg; //agregandole al array de la pregunta el ID del test que es muy importante para saber a que test pertenecen las preguntas: $preg_data['id_test'] = $id_test_activo; //agregando las preguntas al array pregs_test_activo: array_push($pregs_test_activo, $preg_data); } } else { //esto se ejecuta cuando el test no existe y se va a crear uno nuevo: $questions = $conn->getQuestionsForStep($paso_pregs); $questions_tmp = array(); while ($row = mysql_fetch_array($questions, MYSQL_ASSOC)) { //echo "</br>".$row['id_pregunta']." - ".$row['id_paso']." "; $row['resp_pregunta'] = ""; //OJO: Aca se añade el campo resp_pregunta pero vacio porque el test es nuevo y no se ha respondido la pregunta $row['intento'] = "0"; //OJO: Debido a que el test es nuevo el campo intento debe ir con 0. debido a que seria el intento 0. $row['intento_respond'] = 0; //Debido a que el test es nuevo el intento de responder esta pregunta se inicializa en 0 //se agrega la pregunta al array: array_push($questions_tmp, $row); } //se imprime el array para verificar si vienen todos los resultados: //print_r($questions_tmp); //$question_rand = array_rand($questions_tmp,$num_pregs);