123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <?php
- //ini_set('display_errors', 1);
- //error_reporting(E_ALL);
- require_once './ims-blti/blti.php';
- setlocale(LC_TIME, 'es_MX.UTF-8');
- require_once("../include/nocache.php");
- require_once("../include/bd_pdo.php");
- require_once("../include/util.php");
- include_once('../include/xTemplate/xtemplate.class.php'); // including mpdf.php
- include_once('../include/mpdf/autoload.php'); // including mpdf.php
- $lti = new BLTI("Pl4n&Syll4bus", false, false);
- if (!$lti->valid) {//si está fuera de moodle consulta por variables get (para pruebas)
- if(!empty($_GET["shortname"]) && !empty($_GET["periodo"]) && !empty($_GET["username"])){
- $clave_ulsa = intval(substr($_GET["username"], 2));//clave como entero
- $tmp = explode("-", $_GET["shortname"]);//Shortname
- $gpo_nom = $tmp[0];
- $iniciales = $tmp[1];
- $mat = $tmp[3];
- $periodo_id = $_GET["periodo"]; //Obtenerlo de parametros
- }else{
- $errorDesc = $lti->message;
- $errorDesc .="- No se pueden obtener los datos del curso para generar el pdf.";
- echo $errorDesc;
- exit();
- }
- }else {// LTI de conexión a moodle
- if(substr_count($lti->info["context_label"], "-")<3){//valida que el shortname tenga 3 o más -
- echo "<h1>Error</h1><p>No se puede hacer la consulta porque el shortaname no es válido.</p>";
- exit();
- }
- $clave_ulsa = intval(substr($lti->info["ext_user_username"], 2));//clave como entero
- $tmp = explode("-", $lti->info["context_label"]);//Shortname
- $gpo_nom = $tmp[0];// Gpo
- $iniciales = $tmp[1]; //Iniciales de materia
- $mat = $tmp[3];//ID materia
- $periodo_id = $lti->info["custom_periodo"]; //Obtener periodo de parametros de herramienta externa
- }
- if($gpo_nom != "ELECTIVA"){//No es electiva
- //Obtiene id gpo a partir de nombre
- $stmt = $pdo->prepare('SELECT * FROM fs_grupo(NULL, :per, :nombre)');
- $stmt->bindParam(":per", $periodo_id);
- $stmt->bindParam(":nombre", $gpo_nom);
- if(!$stmt->execute()){
- echo "Error al consultar la clave de usuario";
- exit();
- }else{
- $gpo_rs = $stmt->fetch();
- if(empty($gpo_rs)){
- echo "No existe el grupo";
- exit();
- }
- $gpo = $gpo_rs["Grupo_id"];
- }
- $stmt->closeCursor();
- //----------
-
- $stmt = $pdo->prepare('Select * from fs_profesoresmateriagrupo(:per, :mat, :gpo, NULL, NULL)');
- $stmt->bindParam(":per", $periodo_id);
- $stmt->bindParam(":mat", $mat);
- $stmt->bindParam(":gpo", $gpo);
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- echo "Ocurrió un error al obtener los datos de los profesores ".$t[2];
- exit();
- }
- $profesor_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $usr = $profesor_rs[0]["Usuario_id"];
- $usr_nombre = $profesor_rs[0]["Usuario_nombre"]." ".$profesor_rs[0]["Usuario_apellidos"];
- //----------
- $stmt = $pdo->prepare('Select * from fs_syllabus(:periodo, :prof, :mat, :gpo, NULL )');
- $stmt->bindParam(":periodo", $periodo_id);
- $stmt->bindParam(":mat", $mat);
- $stmt->bindParam(":gpo", $gpo);
- $syllabus_rs = array();
- foreach ($profesor_rs as $pr){
- $usr = $pr["Usuario_id"];
- $usr_nombre = $pr["Usuario_nombre"]." ".$pr["Usuario_apellidos"];
- $stmt->bindParam(":prof", $usr);
- if(!$stmt->execute()){
- $errorDesc = "Error al cargar los datos del alumno";
- echo $errorDesc;
- print_r($stmt->errorInfo());
- exit();
- }
- //$syllabus_rs = $stmt->fetch();
- $s_rs = $stmt->fetch();
- if(!empty($s_rs)){
- //break;
- $syllabus_rs[] = $s_rs;
- }
- }
- $stmt->closeCursor();
- }else{
- $usr = $tmp[4];//Último campo del shortname es is del usuario de electiva
- $stmt = $pdo->prepare('Select * from fs_usuario(:id)');
- $stmt->bindParam(":id", $usr);
- if(!$stmt->execute()){
- $t = $stmt->errorInfo();
- echo "Ocurrió un error al obtener los datos de los profesores ".$t[2];
- exit();
- }
- $profesor_rs = $stmt->fetch();
- $stmt->closeCursor();
- $usr_nombre = $profesor_rs["Usuario_nombre"]." ".$profesor_rs["Usuario_apellidos"];
- //----------
-
- $stmt = $pdo->prepare('Select * from fs_syllabus(:periodo, :prof, NULL, NULL, :sub )');
- $stmt->bindParam(":periodo", $periodo_id);
- $stmt->bindParam(":prof", $usr);
- $stmt->bindParam(":sub", $mat);
-
- if(!$stmt->execute()){
- $errorDesc = "Error al cargar los datos del alumno";
- echo $errorDesc;
- print_r($stmt->errorInfo());
- exit();
- }
- $syllabus_rs = [];
- //$syllabus_rs = $stmt->fetch();
- $s_rs = $stmt->fetch();
- $syllabus_rs[] = $s_rs;
- $gpo = $syllabus_rs["Grupo_id"];
- $stmt->closeCursor();
- }
-
- if(empty($syllabus_rs) || count($syllabus_rs)==0){
- echo "<h1 style='text-align:center; margin:2em 0'>No hay contenido guardado para el syllabus</h1>";
- exit();
- }
- // -------------
- $stmt = $pdo->prepare('Select * from fs_periodo(:periodo, NULL, NULL, NULL )');
- $stmt->bindParam(":periodo", $periodo_id);
- if(!$stmt->execute()){
- $errorDesc = "Error al cargar los datos del alumno";
- echo $errorDesc;
- print_r($stmt->errorInfo());
- exit();
- }
- $periodo_rs = $stmt->fetch();
- $stmt->closeCursor();
- $stmt = $pdo->prepare('Select * from fs_horariogrupo(:gpo, NULL, false) AS hg INNER JOIN "Dia" d ON hg."Dia_id" = d."Dia_id" WHERE "Materia_id" = :mat ORDER BY d."Dia_id", hg."Horario_hora"');
- $stmt->bindParam(":gpo", $gpo);
- $stmt->bindParam(":mat", $mat);
- if(!$stmt->execute()){
- $errorDesc = "Error al cargar los datos del horario";
- echo $errorDesc;
- print_r($stmt->errorInfo());
- exit();
- }
- $horario_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- //-----
- $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
- $fontDirs = $defaultConfig['fontDir'];
- $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
- $fontData = $defaultFontConfig['fontdata'];
- $mpdf = new \Mpdf\Mpdf([
- 'mode' => 'utf-8',
- 'format' => [215, 279],
- 'orientation' => 'P',
- 'margin_left' => 14,
- 'margin_right' => 14,
- 'margin_top' => 27,
- 'margin_bottom' => 27,
- 'fontDir' => array_merge($fontDirs, [
- __DIR__ . '/../fonts/indivisaFont/ttf',
- ]),
- 'fontdata' => $fontData + [
- 'indivisa-display' => [
- 'R' => 'IndivisaDisplaySans-Regular.ttf',
- ],
- 'indivisa-title' => [
- 'R' => 'IndivisaDisplaySerif-RegularItalic.ttf',
- ],
- 'indivisa-text' => [
- 'R' => 'IndivisaTextSans-Regular.ttf',
- ]
- ],
- 'default_font' => 'indivisa-text',
- ]);
- //$mpdf->SetDisplayMode('fullpage');
- $stylesheet = "<style>";
- $stylesheet .= file_get_contents('../css/indivisa.css'); // external css
- $stylesheet .= file_get_contents('../apsa/css/syllabus.css'); // external css
- $stylesheet .= "</style>";
- $xtpl = new XTemplate('../apsa/tpl/syllabus.tpl.html');
- $i=0;
- foreach($syllabus_rs as $data){
- $mat_nombre = isset($data["Submateria_desc"])?$data["Submateria_desc"]:$data["Materia_desc"];
- $xtpl->assign("MATERIA", $mat_nombre." ".$gpo_nom);
- $xtpl->assign("SEMESTRE", $data["Materia_semestre"]);
- $xtpl->assign("PERIODO", $periodo_rs["Periodo_desc"]);
- $xtpl->assign("PROFESOR", $usr_nombre);
- foreach($horario_rs as $h){
- $hora = substr($h["Horario_hora"], 0, 5);
- if($h["Salon_desc"]==""){
- $salon = "Salón pendiente";
- }else{
- $salon = $h["Salon_desc"];
- if($h["Salon_desc_larga"] != ""){
- $salon .=" (".$h["Salon_desc_larga"].")";
- }
- }
-
- $xtpl->assign("DIA", $h["Dia_desc"]);
- $xtpl->assign("HORA", $hora);
- $xtpl->assign("SALON", $salon);
- $xtpl->parse("main.content.fechas");
- }
-
- //---Atributos
- //Obtiene mapa
- $stmt = $pdo->prepare('select * from fs_atributoegreso_materia(:mat)');
- $stmt->bindParam(":mat", $mat);
- if(!$stmt->execute()){
- header("Location: ".$pag."?error=5");
- }else{
- $atributos_rs = $stmt->fetchAll();
- }
- //----
- $datos = array(
- array("titulo"=>"Información de la asignatura", "bd"=>"informacion", "subbloques"=>
- array(
- array("subtitulo"=>"Descripción","bd"=>"desc", "nobreak"=>false),
- array("subtitulo"=>"Objetivos","bd"=>"obj", "nobreak"=>false),
- array("subtitulo"=>"Capacidades y habilidades que desarrollar","bd"=>"capacidades", "nobreak"=>false),
- array("subtitulo"=>"Prerrequisitos","bd"=>"prerrequisitos", "nobreak"=>false),
- array("subtitulo"=>"Temario","bd"=>"temario", "nobreak"=>false),
- array("subtitulo"=>"Construcción de la calificación final","bd"=>"calificacion", "nobreak"=>true),
- array("subtitulo"=>"Fechas importantes","bd"=>"fechas", "nobreak"=>true),
- )
- ),
- array("titulo"=>"Lineamientos generales", "bd"=>"", "subbloques"=>
- array(
- array("subtitulo"=>"De la asistencia y puntualidad","bd"=>"asistencia", "nobreak"=>false),
- array("subtitulo"=>"Del comportamiento en clase","bd"=>"comportamiento", "nobreak"=>false),
- array("subtitulo"=>"De los exámenes","bd"=>"examenes", "nobreak"=>false),
- array("subtitulo"=>"De las tareas, prácticas y exposiciones","bd"=>"tareas", "nobreak"=>false),
- array("subtitulo"=>"Trabajos de investigación","bd"=>"investigacion", "nobreak"=>false),
-
- )
- ),
- array("titulo"=>"Bibliografía recomendada", "bd"=>"bibliografia", "subbloques"=>
- array(
- array("subtitulo"=>"","bd"=>"", "nobreak"=>true, "texto"=>"La/el docente que imparte la presente materia, en sus opiniones, posturas o críticas, citas o referencias de consulta, por la metodología didáctica que utiliza, por las herramientas pedagógicas de apoyo en la práctica educativa y, el desarrollo de los contenidos que integran el programa de la presente asignatura o por la implementación del modelo educativo de la Universidad, no tiene por objeto obstaculizar, restringir, impedir, menoscabar, anular o suprimir la orientación sexual, identidad o expresión de género de su alumnado; por ello, partiendo de su derecho de libertad de cátedra, enseña y promueve la construcción de conocimientos con objetividad e imparcialidad, sin censura ni restricciones, propiciando el debate y el análisis de los temas para enriquecer el aprendizaje, sin tener más límite que el respeto a los derechos del estudiantado."),
- )
- )
- );
- $atributos = false;
- foreach($datos as $bloque){
- $xtpl->assign("TITULO", $bloque["titulo"]);
- if($bloque["bd"]!= ""){
- $xtpl->assign("INFO", $data["Syllabus_".$bloque["bd"]]);
- $xtpl->parse("main.content.bloque.titulo.info");
- $xtpl->parse("main.content.bloque.titulo");
- $xtpl->parse("main.content.bloque");
- }
- if(!$atributos ){
- $atributos = true;
- if(count($atributos_rs) > 0){
- $html = "<ul>";
- foreach($atributos_rs as $atr){
- $html.="<li><b>Atributo {$atr["AtributoEgreso_id"]} nivel {$atr["AtributoNivel_desc"]}:</b> {$atr["AtributoEgreso_desc"]}</li>";
- }
- $html.="</ul>";
- $xtpl->assign("SUBTITULO", "Atributos de egreso");
- $xtpl->assign("INFO", $html);
- $xtpl->parse("main.content.bloque.subbloque");
- $xtpl->parse("main.content.bloque");
- }
- }
- foreach($bloque["subbloques"] as $subbloque){
- $xtpl->assign("SUBTITULO", $subbloque["subtitulo"]);
- if($subbloque["bd"]!= ""){
- $xtpl->assign("INFO", $data["Syllabus_".$subbloque["bd"]]);
- }else{
- $xtpl->assign("INFO", $subbloque["texto"]);
- }
- if($subbloque["nobreak"]) $xtpl->parse("main.content.bloque.subbloque_nobreak");
- else $xtpl->parse("main.content.bloque.subbloque");
- $xtpl->parse("main.content.bloque");
- }
- }
-
- $i++;
- if($i < count($syllabus_rs)){
- $xtpl->parse("main.content.pagebreak");
- }
- $xtpl->parse("main.content");
- }
- $xtpl->parse("main");
- /*if(isset($lti->info["html"])){
- echo $stylesheet;
- $xtpl->out("main"); exit;
- }*/
- //echo $stylesheet;
- //$xtpl->out("main"); exit;
- $header = '<table style="width:100%"><tr>
- <td><img src="../img/logopdf.png" width="40mm" class=""></td>
- <td align="right"><h1 class="titulo">SYLLABUS | FACULTAD DE INGENIERÍA</h1></td>
- </tr></table>';
- $mpdf->SHYlang = 'es';
- $mpdf-> SetTitle('Syllabus -' . $mat_nombre);
- $mpdf-> SetAuthor('Facultad de Ingeniería. © Universidad La Salle A.C. '.date("Y").' Todos los derechos Reservados.');
- $mpdf->SetHTMLHeader($header);//se pone como fondo
- $mpdf->SetHTMLFooter('<img src="../img/footer_docs.png" >');//se pone como fondo
- $mpdf->WriteHTML($stylesheet);
- if(!isset($errorDesc))
- $mpdf->WriteHTML($xtpl->text("main"));
- else
- $mpdf->WriteHTML($errorDesc);
- $mpdf->Output("syllabus_".getIniciales($mat_nombre)."_".$gpo_nom.".pdf", 'I');//Inline Download
- ?>
|