public static function getExamIndex($course_module_id) { $info = ConnectionInfo::create(); /** @var MySqlConnection $dbh */ $dbh = MySqlConnection::create($info); /** @var \PDOStatement $statement */ $statement = $dbh->prepare('SELECT quiz.id FROM mdl_course_modules AS cmi JOIN mdl_quiz AS quiz ON quiz.id = cmi.instance WHERE cmi.id = :id'); $statement->bindParam(':id', $course_module_id); $statement->setFetchMode(PDO::FETCH_ASSOC); $statement->execute(); $result = $statement->fetchAll(); $result = reset($result); return $result['id']; }
<?php use Crayon\Database\ConnectionInfo; use Crayon\Database\MySqlConnection; use Crayon\Model\Examen; include 'vendor/autoload.php'; include 'src/autoloader.php'; $connection_info = ConnectionInfo::create(); /** @var MySqlConnection $db */ $db = MySqlConnection::create($connection_info); // Obtenemos los exámenes $query = 'SELECT * FROM mdl_quiz'; $stmnt = $db->prepare($query); $stmnt->setFetchMode(PDO::FETCH_ASSOC); $stmnt->execute(); $examenes = $stmnt->fetchAll(); foreach ($examenes as $examen) { $examenid = $examen; /** @var Examen $_examen */ $examen = Examen::create($examen); $_examen = $examen->json_dump(); $template = file_get_contents(__DIR__ . '/assets/html/Template.html'); $_examen = strtr($template, array('@json_data' => $_examen)); file_put_contents(__DIR__ . '/output/quiz' . $examen->examen['id'] . '.html', $_examen); } //// Inicializamos el cliente //$scapper = new Goutte\Client(); //// Recordar settear COOKIE de autentificación. //$scapper->setHeader('Cookie', COOKIE); //$sections = array(3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,25,26,27,28,29,30,31,32,33,34,36,37,38,39,40,41,42,43,44,45); //foreach ($sections as $s) {