Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2458/head
jmontoyaa 8 years ago
commit 61df9eacb7
  1. 2
      plugin/test2pdf/database.php
  2. 2
      plugin/test2pdf/install.php
  3. 1
      plugin/test2pdf/lang/english.php
  4. 2
      plugin/test2pdf/plugin.php
  5. 579
      plugin/test2pdf/src/download-pdf.php
  6. 1
      plugin/test2pdf/src/index.test2pdf.php
  7. 225
      plugin/test2pdf/src/test2pdf.lib.php
  8. 28
      plugin/test2pdf/src/test2pdf_plugin.class.php
  9. 38
      plugin/test2pdf/src/view-pdf.php
  10. 12
      plugin/test2pdf/start.php

@ -24,4 +24,4 @@ $sql = "CREATE TABLE IF NOT EXISTS $table (
enable INT(1)
)";
Database::query($sql);
*/
*/

@ -10,6 +10,6 @@
*/
require_once dirname(__FILE__) . '/config.php';
if (!api_is_platform_admin()) {
die ('You must have admin permissions to install plugins');
die('You must have admin permissions to install plugins');
}
Test2pdfPlugin::create()->install();

@ -13,4 +13,3 @@ $strings['PluginDisabledFromAdminPanel'] = "The plugin has been disabled from th
$strings['AnswersColumn'] = "Answers: ";
$strings['Statement']= "Statement";
$strings['PageX']= "Page %s";

@ -7,6 +7,6 @@
*/
/**
* Plugin details (must be present)
*/
*/
require_once dirname(__FILE__) . '/config.php';
$plugin_info = Test2pdfPlugin::create()->get_info();

@ -13,8 +13,8 @@ require_once 'test2pdf_plugin.class.php';
$test2pdfPlugin = Test2pdfPlugin::create();
$enable = $test2pdfPlugin->get('enable_plugin');
if($enable != "true"){
header('Location: ../../../index.php');
if ($enable != "true") {
header('Location: ../../../index.php');
}
require('../class/fpdf.php');
@ -26,214 +26,216 @@ $id_quiz = (int) $_GET['id_quiz'];
class PDF extends FPDF
{
function Header()
{
global $title_course;
global $title_quiz;
public function Header()
{
global $title_course;
global $title_quiz;
$logo = '../resources/img/logo.png';
$this->Image($logo,10,0);
// Title
$this->SetFont('Courier','I',14);
$this->Cell(0,5,$title_course,0,1,'R');
$this->SetFont('Helvetica','I',14);
$this->Cell(0,5,$title_quiz,0,1,'R');
// Line break
$this->SetLineWidth(0.5);
$this->SetDrawColor(60,120,255);
$this->Line(10, 24, 200, 24);
$this->SetLineWidth(0.4);
$this->SetDrawColor(200);
$this->Line(11, 24.5, 199, 24.5);
$this->Ln(10);
}
function Footer()
{
global $test2pdfPlugin;
// Position at 1.5 cm from bottom
$this->SetY(-15);
$y = $this->GetY();
// Line break
$this->SetLineWidth(0.5);
$this->SetDrawColor(60,120,255);
$this->Line(10, $y, 200, $y);
$this->SetLineWidth(0.4);
$this->SetDrawColor(200);
$this->Line(11, $y+0.5, 199, $y+0.5);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Text color in gray
$this->SetTextColor(128);
// Page number
$this->Cell(0,10,utf8_decode(sprintf($test2pdfPlugin->get_lang('PageX'), $this->PageNo())),0,0,'C');
$this->Cell(0,10,date('Y'),0,0,'R');
}
var $B;
var $I;
var $U;
var $HREF;
var $fontList;
var $issetfont;
var $issetcolor;
function PDF($orientation='P', $unit='mm', $format='A4')
{
//Call parent constructor
$this->__construct($orientation,$unit,$format);
//Initialization
$this->B=0;
$this->I=0;
$this->U=0;
$this->HREF='';
$this->fontlist=array('arial', 'times', 'courier', 'helvetica', 'symbol');
$this->issetfont=false;
$this->issetcolor=false;
}
function WriteHTML($html)
{
//HTML parser
$html=strip_tags($html,"<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><style>"); //supprime tous les tags sauf ceux reconnus
$html=str_replace("\n",' ',$html); //remplace retour à la ligne par un espace
$a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); //éclate la chaîne avec les balises
foreach($a as $i=>$e)
{
if($i%2==0)
{
//Text
if($this->HREF)
$this->PutLink($this->HREF,$e);
else
$this->Write(5,stripslashes(txtentities($e)));
}
else
{
//Tag
if($e[0]=='/')
$this->CloseTag(strtoupper(substr($e,1)));
else
{
//Extract attributes
$a2=explode(' ',$e);
$tag=strtoupper(array_shift($a2));
$attr=array();
foreach($a2 as $v)
{
if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
$attr[strtoupper($a3[1])]=$a3[2];
}
$this->OpenTag($tag,$attr);
}
}
}
}
function OpenTag($tag, $attr)
{
//Opening tag
switch($tag){
case 'STRONG':
$this->SetStyle('B',true);
break;
case 'EM':
$this->SetStyle('I',true);
break;
case 'B':
case 'I':
case 'U':
$this->SetStyle($tag,true);
break;
case 'A':
$this->HREF=$attr['HREF'];
break;
case 'IMG':
if(isset($attr['SRC']) && (isset($attr['WIDTH']) || isset($attr['HEIGHT']))) {
if(!isset($attr['WIDTH']))
$attr['WIDTH'] = 0;
if(!isset($attr['HEIGHT']))
$attr['HEIGHT'] = 0;
$this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT']));
}
break;
case 'TR':
case 'BLOCKQUOTE':
case 'BR':
$this->Ln(5);
break;
case 'P':
$this->Ln(10);
break;
case 'FONT':
if (isset($attr['COLOR']) && $attr['COLOR']!='') {
$coul=hex2dec($attr['COLOR']);
$this->SetTextColor($coul['R'],$coul['V'],$coul['B']);
$this->issetcolor=true;
}
if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist)) {
$this->SetFont(strtolower($attr['FACE']));
$this->issetfont=true;
}
break;
}
}
function CloseTag($tag)
{
//Closing tag
if($tag=='STRONG')
$tag='B';
if($tag=='EM')
$tag='I';
if($tag=='B' || $tag=='I' || $tag=='U')
$this->SetStyle($tag,false);
if($tag=='A')
$this->HREF='';
if($tag=='FONT'){
if ($this->issetcolor==true) {
$this->SetTextColor(0);
}
if ($this->issetfont) {
$this->SetFont('arial');
$this->issetfont=false;
}
}
}
function SetStyle($tag, $enable)
{
//Modify style and select corresponding font
$this->$tag+=($enable ? 1 : -1);
$style='';
foreach(array('B','I','U') as $s)
{
if($this->$s>0)
$style.=$s;
}
$this->SetFont('',$style);
}
function PutLink($URL, $txt)
{
//Put a hyperlink
$this->SetTextColor(0,0,255);
$this->SetStyle('U',true);
$this->Write(5,$txt,$URL);
$this->SetStyle('U',false);
$this->SetTextColor(0);
}
$logo = '../resources/img/logo.png';
$this->Image($logo, 10, 0);
// Title
$this->SetFont('Courier', 'I', 14);
$this->Cell(0, 5, $title_course, 0, 1, 'R');
$this->SetFont('Helvetica', 'I', 14);
$this->Cell(0, 5, $title_quiz, 0, 1, 'R');
// Line break
$this->SetLineWidth(0.5);
$this->SetDrawColor(60, 120, 255);
$this->Line(10, 24, 200, 24);
$this->SetLineWidth(0.4);
$this->SetDrawColor(200);
$this->Line(11, 24.5, 199, 24.5);
$this->Ln(10);
}
public function Footer()
{
global $test2pdfPlugin;
// Position at 1.5 cm from bottom
$this->SetY(-15);
$y = $this->GetY();
// Line break
$this->SetLineWidth(0.5);
$this->SetDrawColor(60, 120, 255);
$this->Line(10, $y, 200, $y);
$this->SetLineWidth(0.4);
$this->SetDrawColor(200);
$this->Line(11, $y+0.5, 199, $y+0.5);
// Arial italic 8
$this->SetFont('Arial', 'I', 8);
// Text color in gray
$this->SetTextColor(128);
// Page number
$this->Cell(0, 10, utf8_decode(sprintf($test2pdfPlugin->get_lang('PageX'), $this->PageNo())), 0, 0, 'C');
$this->Cell(0, 10, date('Y'), 0, 0, 'R');
}
public $B;
public $I;
public $U;
public $HREF;
public $fontList;
public $issetfont;
public $issetcolor;
public function PDF($orientation='P', $unit='mm', $format='A4')
{
//Call parent constructor
$this->__construct($orientation, $unit, $format);
//Initialization
$this->B=0;
$this->I=0;
$this->U=0;
$this->HREF='';
$this->fontlist=['arial', 'times', 'courier', 'helvetica', 'symbol'];
$this->issetfont=false;
$this->issetcolor=false;
}
public function WriteHTML($html)
{
//HTML parser
$html=strip_tags($html, "<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><style>"); //supprime tous les tags sauf ceux reconnus
$html=str_replace("\n", ' ', $html); //remplace retour à la ligne par un espace
$a=preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //éclate la chaîne avec les balises
foreach ($a as $i=>$e) {
if ($i%2==0) {
//Text
if ($this->HREF) {
$this->PutLink($this->HREF, $e);
} else {
$this->Write(5, stripslashes(txtentities($e)));
}
} else {
//Tag
if ($e[0]=='/') {
$this->CloseTag(strtoupper(substr($e, 1)));
} else {
//Extract attributes
$a2=explode(' ', $e);
$tag=strtoupper(array_shift($a2));
$attr=[];
foreach ($a2 as $v) {
if (preg_match('/([^=]*)=["\']?([^"\']*)/', $v, $a3)) {
$attr[strtoupper($a3[1])]=$a3[2];
}
}
$this->OpenTag($tag, $attr);
}
}
}
}
public function OpenTag($tag, $attr)
{
//Opening tag
switch ($tag) {
case 'STRONG':
$this->SetStyle('B', true);
break;
case 'EM':
$this->SetStyle('I', true);
break;
case 'B':
case 'I':
case 'U':
$this->SetStyle($tag, true);
break;
case 'A':
$this->HREF=$attr['HREF'];
break;
case 'IMG':
if (isset($attr['SRC']) && (isset($attr['WIDTH']) || isset($attr['HEIGHT']))) {
if (!isset($attr['WIDTH'])) {
$attr['WIDTH'] = 0;
}
if (!isset($attr['HEIGHT'])) {
$attr['HEIGHT'] = 0;
}
$this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT']));
}
break;
case 'TR':
case 'BLOCKQUOTE':
case 'BR':
$this->Ln(5);
break;
case 'P':
$this->Ln(10);
break;
case 'FONT':
if (isset($attr['COLOR']) && $attr['COLOR']!='') {
$coul=hex2dec($attr['COLOR']);
$this->SetTextColor($coul['R'], $coul['V'], $coul['B']);
$this->issetcolor=true;
}
if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist)) {
$this->SetFont(strtolower($attr['FACE']));
$this->issetfont=true;
}
break;
}
}
public function CloseTag($tag)
{
//Closing tag
if ($tag=='STRONG') {
$tag='B';
}
if ($tag=='EM') {
$tag='I';
}
if ($tag=='B' || $tag=='I' || $tag=='U') {
$this->SetStyle($tag, false);
}
if ($tag=='A') {
$this->HREF='';
}
if ($tag=='FONT') {
if ($this->issetcolor==true) {
$this->SetTextColor(0);
}
if ($this->issetfont) {
$this->SetFont('arial');
$this->issetfont=false;
}
}
}
public function SetStyle($tag, $enable)
{
//Modify style and select corresponding font
$this->$tag+=($enable ? 1 : -1);
$style='';
foreach (['B','I','U'] as $s) {
if ($this->$s>0) {
$style.=$s;
}
}
$this->SetFont('', $style);
}
public function PutLink($URL, $txt)
{
//Put a hyperlink
$this->SetTextColor(0, 0, 255);
$this->SetStyle('U', true);
$this->Write(5, $txt, $URL);
$this->SetStyle('U', false);
$this->SetTextColor(0);
}
}
//Obtener nombre del curso y nombre del ejercicio
//$info_course = CourseManager::get_course_information_by_id($course_id);
$info_course = api_get_course_info_by_id($course_id);
$info_quiz = getInfoQuiz($course_id,$id_quiz);
$info_quiz = getInfoQuiz($course_id, $id_quiz);
$title_course = utf8_decode(removeHtml($info_course['title']));
$title_quiz = utf8_decode(removeHtml($info_quiz['title']));
@ -246,96 +248,95 @@ $array_question_id = getQuestions($course_id, $id_quiz);
// Go through all questions and get the answers
if ($_GET['type'] == 'question' || $_GET['type'] == 'all') {
$j = 1;
foreach ($array_question_id as $key => $value) {
$InfoQuestion = getInfoQuestion($course_id, $value);
if ($pdf->GetY() > 240) {
$pdf->AddPage();
}
$pdf->SetFont('Arial','',12);
$pdf->SetTextColor(64);
if (trim($InfoQuestion['description'])!='') {
$j = 0;
$pdf->WriteHTML(utf8_decode(removeQuotes($InfoQuestion['description'])));
$pdf->Ln();
} else {
$pdf->MultiCell(0,7,($key+$j).' - '.utf8_decode($InfoQuestion['question']),0,'L',false);
}
/*
if($InfoQuestion['question'] == "Enunciado"){
$j = 0;
$pdf->MultiCell(0,7,utf8_decode($InfoQuestion['question']),0,'L',false);
if(trim($InfoQuestion['description'])!=''){
$pdf->WriteHTML(utf8_decode(quitar_acentos($InfoQuestion['description'])));
$pdf->Ln();
}
}else{
$pdf->MultiCell(0,7,($key+$j).' - '.utf8_decode($InfoQuestion['question']),0,'L',false);
}*/
$InfoAnswer = getAnswers($course_id, $value);
foreach ($InfoAnswer as $key2 => $value2) {
$pdf->SetFont('Arial','I',10);
$pdf->SetTextColor(96);
$pdf->Cell(1,7,'',0,0);
$pdf->Rect($pdf->GetX()+2,$pdf->GetY(),4,4);
$pdf->Cell(7,7,'',0,0);
$pdf->MultiCell(0,5,$letters[$key2].' - '.utf8_decode(removeHtml($value2['answer'])),0,'L',false);
$pdf->Ln(1);
}
$pdf->Ln(4);
}
$j = 1;
foreach ($array_question_id as $key => $value) {
$InfoQuestion = getInfoQuestion($course_id, $value);
if ($pdf->GetY() > 240) {
$pdf->AddPage();
}
$pdf->SetFont('Arial', '', 12);
$pdf->SetTextColor(64);
if (trim($InfoQuestion['description'])!='') {
$j = 0;
$pdf->WriteHTML(utf8_decode(removeQuotes($InfoQuestion['description'])));
$pdf->Ln();
} else {
$pdf->MultiCell(0, 7, ($key+$j).' - '.utf8_decode($InfoQuestion['question']), 0, 'L', false);
}
/*
if($InfoQuestion['question'] == "Enunciado"){
$j = 0;
$pdf->MultiCell(0,7,utf8_decode($InfoQuestion['question']),0,'L',false);
if(trim($InfoQuestion['description'])!=''){
$pdf->WriteHTML(utf8_decode(quitar_acentos($InfoQuestion['description'])));
$pdf->Ln();
}
}else{
$pdf->MultiCell(0,7,($key+$j).' - '.utf8_decode($InfoQuestion['question']),0,'L',false);
}*/
$InfoAnswer = getAnswers($course_id, $value);
foreach ($InfoAnswer as $key2 => $value2) {
$pdf->SetFont('Arial', 'I', 10);
$pdf->SetTextColor(96);
$pdf->Cell(1, 7, '', 0, 0);
$pdf->Rect($pdf->GetX()+2, $pdf->GetY(), 4, 4);
$pdf->Cell(7, 7, '', 0, 0);
$pdf->MultiCell(0, 5, $letters[$key2].' - '.utf8_decode(removeHtml($value2['answer'])), 0, 'L', false);
$pdf->Ln(1);
}
$pdf->Ln(4);
}
}
$j=1;
if ($_GET['type'] == 'answer' || $_GET['type'] == 'all') {
$array_resp = array();
foreach ($array_question_id as $key => $value) {
$InfoQuestion = getInfoQuestion($course_id,$value);
if ($InfoQuestion['question'] == $test2pdfPlugin->get_lang('Statement')) {
$j = 0;
} else {
$respuestas = '';
$InfoQuestion = getInfoQuestion($course_id,$value);
if ($InfoQuestion['type']==2 || $InfoQuestion['type']==9 || $InfoQuestion['type']==11 || $InfoQuestion['type']==12 || $InfoQuestion['type']==14) {
$InfoAnswer = getAnswers($course_id,$value);
$respuestas .= ' '.($key+$j).' -';
foreach ($InfoAnswer as $key2 => $value2) {
if ($value2['correct'] == 1) {
$respuestas .= ' '.$letters[$key2].',';
}
}
$i = strrpos($respuestas,',');
$respuestas = substr($respuestas,0,$i);
$respuestas .= ' ';
$array_resp[] = $respuestas;
} else {
$InfoAnswer = getAnswers($course_id,$value);
foreach ($InfoAnswer as $key2 => $value2) {
if ($value2['correct'] == 1) {
$respuestas .= ' '.($key+$j).' - '.$letters[$key2].' ';
break;
}
}
$array_resp[] = $respuestas;
}
}
}
$pdf->SetFont('Arial','',12);
$pdf->SetTextColor(64);
$pdf->Cell(0, 7, utf8_decode($test2pdfPlugin->get_lang('AnswersColumn')), 0, 1, 'L', false);
$array_resp = [];
foreach ($array_question_id as $key => $value) {
$InfoQuestion = getInfoQuestion($course_id, $value);
if ($InfoQuestion['question'] == $test2pdfPlugin->get_lang('Statement')) {
$j = 0;
} else {
$respuestas = '';
$InfoQuestion = getInfoQuestion($course_id, $value);
if ($InfoQuestion['type']==2 || $InfoQuestion['type']==9 || $InfoQuestion['type']==11 || $InfoQuestion['type']==12 || $InfoQuestion['type']==14) {
$InfoAnswer = getAnswers($course_id, $value);
$respuestas .= ' '.($key+$j).' -';
foreach ($InfoAnswer as $key2 => $value2) {
if ($value2['correct'] == 1) {
$respuestas .= ' '.$letters[$key2].',';
}
}
$i = strrpos($respuestas, ',');
$respuestas = substr($respuestas, 0, $i);
$respuestas .= ' ';
$array_resp[] = $respuestas;
} else {
$InfoAnswer = getAnswers($course_id, $value);
foreach ($InfoAnswer as $key2 => $value2) {
if ($value2['correct'] == 1) {
$respuestas .= ' '.($key+$j).' - '.$letters[$key2].' ';
break;
}
}
$array_resp[] = $respuestas;
}
}
}
$pdf->SetFont('Arial', '', 12);
$pdf->SetTextColor(64);
$pdf->Cell(0, 7, utf8_decode($test2pdfPlugin->get_lang('AnswersColumn')), 0, 1, 'L', false);
$pdf->SetFont('Arial', 'I', 10);
$pdf->SetTextColor(64, 64, 255);
$i = 1;
foreach ($array_resp as $resp) {
$pdf->Cell(50, 6, $resp, 0);
if($i%4 == 0){
$pdf->Ln();
}
$i++;
}
$pdf->SetFont('Arial', 'I', 10);
$pdf->SetTextColor(64, 64, 255);
$i = 1;
foreach ($array_resp as $resp) {
$pdf->Cell(50, 6, $resp, 0);
if ($i%4 == 0) {
$pdf->Ln();
}
$i++;
}
}
$pdf->Output();

@ -4,4 +4,3 @@
* Index of the Test to pdf plugin courses list
* @package chamilo.plugin.test2pdf
*/

@ -11,7 +11,7 @@ require_once '../../../main/inc/global.inc.php';
require_once '../config.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
$letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
$letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
/**
* List exercises
@ -25,7 +25,7 @@ function showExerciseCourse($course_id, $session_id = 0)
$course_id = (int) $course_id;
$session_id = (int) $session_id;
$tableQuiz = Database::get_course_table(TABLE_QUIZ_TEST);
$tableLpItem = Database::get_course_table(TABLE_LP_ITEM);
$tableLpItem = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT a.*
FROM $tableQuiz a
LEFT JOIN $tableLpItem b
@ -35,10 +35,10 @@ function showExerciseCourse($course_id, $session_id = 0)
AND (a.active = 1 OR (item_type = 'quiz' AND b.c_id = $course_id))
ORDER BY a.title ASC;";
$res = Database::query($sql);
if (!$res) {
die("Error Database $tableQuiz");
}
$aux = array();
if (!$res) {
die("Error Database $tableQuiz");
}
$aux = [];
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
@ -46,7 +46,7 @@ function showExerciseCourse($course_id, $session_id = 0)
}
/**
* List quiz details
* List quiz details
* @return array Results (list of quiz details)
* @throws Exception
*/
@ -54,12 +54,12 @@ function getInfoQuiz($c_id, $id)
{
$c_id = (int) $c_id;
$id = (int) $id;
$tableQuiz = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT * FROM $tableQuiz WHERE c_id = $c_id AND iid = $id";
$tableQuiz = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT * FROM $tableQuiz WHERE c_id = $c_id AND iid = $id";
$res = Database::query($sql);
if (!$res) {
die("Error Database $tableQuiz");
}
if (!$res) {
die("Error Database $tableQuiz");
}
$row = Database::fetch_assoc($res);
return $row;
}
@ -73,27 +73,27 @@ function getQuestions($c_id, $quizId)
{
$c_id = (int) $c_id;
$quizId = (int) $quizId;
$tableQuizQuestion = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$tableQuestion = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT a.question_id AS question_id
$tableQuizQuestion = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$tableQuestion = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT a.question_id AS question_id
FROM $tableQuizQuestion a
INNER JOIN $tableQuestion b ON a.question_id = b.iid
WHERE a.c_id = $c_id AND b.c_id = a.c_id AND a.exercice_id = $quizId
AND (b.type IN (1, 2, 9, 10, 11, 12, 14))
ORDER BY question_order ASC;";
$res = Database::query($sql);
if (!$res) {
die("Error Database $tableQuizQuestion");
}
$aux = array();
$res = Database::query($sql);
if (!$res) {
die("Error Database $tableQuizQuestion");
}
$aux = [];
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row['question_id'];
}
return $aux;
$aux[] = $row['question_id'];
}
return $aux;
}
/**
* List question details
* List question details
* @return array Results (list of question details)
* @throws Exception
*/
@ -101,15 +101,15 @@ function getInfoQuestion($c_id, $id)
{
$c_id = (int) $c_id;
$id = (int) $id;
$tableQuestion = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT * FROM $tableQuestion
$tableQuestion = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT * FROM $tableQuestion
WHERE c_id = $c_id
AND iid = $id
AND (type IN (1, 2, 9, 10, 11, 12, 14))";
$res = Database::query($sql);
if (!$res) {
die("Error Database $tableQuestion");
}
if (!$res) {
die("Error Database $tableQuestion");
}
$row = Database::fetch_assoc($res);
return $row;
}
@ -123,19 +123,19 @@ function getAnswers($c_id, $id)
{
$c_id = (int) $c_id;
$id = (int) $id;
$tableQuizAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
$sql = "SELECT * FROM $tableQuizAnswer
$tableQuizAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
$sql = "SELECT * FROM $tableQuizAnswer
WHERE c_id = $c_id AND question_id = $id
ORDER BY position ASC;";
$res = Database::query($sql);
if (!$res) {
die("Error Database $tableQuizAnswer");
}
$aux = array();
if (!$res) {
die("Error Database $tableQuizAnswer");
}
$aux = [];
while ($row = Database::fetch_assoc($res)) {
$aux[] = $row;
}
return $aux;
$aux[] = $row;
}
return $aux;
}
/**
@ -145,49 +145,49 @@ function getAnswers($c_id, $id)
*/
function removeHtml($string)
{
$txt=str_replace("<html>","",$string);
$txt=str_replace("<head>","",$txt);
$txt=str_replace("<title>","",$txt);
$txt=str_replace("</title>","",$txt);
$txt=str_replace("</head>","",$txt);
$txt=str_replace("<body>","",$txt);
$txt=str_replace("</body>","",$txt);
$txt=str_replace("</html>","",$txt);
$txt=strip_tags($txt);
$txt=str_replace(chr(13).chr(10),"",$txt);
$txt=str_replace("<html>", "", $string);
$txt=str_replace("<head>", "", $txt);
$txt=str_replace("<title>", "", $txt);
$txt=str_replace("</title>", "", $txt);
$txt=str_replace("</head>", "", $txt);
$txt=str_replace("<body>", "", $txt);
$txt=str_replace("</body>", "", $txt);
$txt=str_replace("</html>", "", $txt);
$txt=strip_tags($txt);
$txt=str_replace(chr(13).chr(10), "", $txt);
/*
$txt=str_replace("&nbsp;"," ",$txt);
$txt=str_replace("&Aacute;","Á",$txt);
$txt=str_replace("&aacute;","á",$txt);
$txt=str_replace("&Eacute;","É",$txt);
$txt=str_replace("&eacute;","é",$txt);
$txt=str_replace("&Iacute;","Í",$txt);
$txt=str_replace("&iacute;","í",$txt);
$txt=str_replace("&Oacute;","Ó",$txt);
$txt=str_replace("&oacute;","ó",$txt);
$txt=str_replace("&Uacute;","Ú",$txt);
$txt=str_replace("&uacute;","ú",$txt);
$txt=str_replace("&Ntilde;","Ñ",$txt);
$txt=str_replace("&ntilde;","ñ",$txt);
$txt=str_replace("&agrave;","à",$txt);
$txt=str_replace("&Agrave;","À",$txt);
$txt=str_replace("&iexcl;","¡",$txt);
$txt=str_replace("&middot;","·",$txt);
$txt=str_replace("&Ccedil;","Ç",$txt);
$txt=str_replace("&ccedil;","ç",$txt);
$txt=str_replace("&quot;",'"',$txt);
$txt=str_replace("&ordf;",'ª',$txt);
$txt=str_replace("&ordm;",'º',$txt);
$txt=str_replace("&amp;",'&',$txt);
$txt=str_replace("&bull;",'•',$txt);
$txt=str_replace("&iquest;",'¿',$txt);
$txt=str_replace("&euro;",'EUR',$txt);
$txt=str_replace("&uuml;",'ü',$txt);
$txt=str_replace("&Uuml;",'Ü',$txt);
$txt=str_replace("&uml;",'¨',$txt);*/
return $txt;
/*
$txt=str_replace("&nbsp;"," ",$txt);
$txt=str_replace("&Aacute;","Á",$txt);
$txt=str_replace("&aacute;","á",$txt);
$txt=str_replace("&Eacute;","É",$txt);
$txt=str_replace("&eacute;","é",$txt);
$txt=str_replace("&Iacute;","Í",$txt);
$txt=str_replace("&iacute;","í",$txt);
$txt=str_replace("&Oacute;","Ó",$txt);
$txt=str_replace("&oacute;","ó",$txt);
$txt=str_replace("&Uacute;","Ú",$txt);
$txt=str_replace("&uacute;","ú",$txt);
$txt=str_replace("&Ntilde;","Ñ",$txt);
$txt=str_replace("&ntilde;","ñ",$txt);
$txt=str_replace("&agrave;","à",$txt);
$txt=str_replace("&Agrave;","À",$txt);
$txt=str_replace("&iexcl;","¡",$txt);
$txt=str_replace("&middot;","·",$txt);
$txt=str_replace("&Ccedil;","Ç",$txt);
$txt=str_replace("&ccedil;","ç",$txt);
$txt=str_replace("&quot;",'"',$txt);
$txt=str_replace("&ordf;",'ª',$txt);
$txt=str_replace("&ordm;",'º',$txt);
$txt=str_replace("&amp;",'&',$txt);
$txt=str_replace("&bull;",'•',$txt);
$txt=str_replace("&iquest;",'¿',$txt);
$txt=str_replace("&euro;",'EUR',$txt);
$txt=str_replace("&uuml;",'ü',$txt);
$txt=str_replace("&Uuml;",'Ü',$txt);
$txt=str_replace("&uml;",'¨',$txt);*/
return $txt;
}
/**
@ -197,37 +197,37 @@ function removeHtml($string)
*/
function removeQuotes($string)
{
//$txt=strip_tags($cadena);
$txt=str_replace("&nbsp;"," ",$string);
$txt=str_replace("&Aacute;","Á",$txt);
$txt=str_replace("&aacute;","á",$txt);
$txt=str_replace("&Eacute;","É",$txt);
$txt=str_replace("&eacute;","é",$txt);
$txt=str_replace("&Iacute;","Í",$txt);
$txt=str_replace("&iacute;","í",$txt);
$txt=str_replace("&Oacute;","Ó",$txt);
$txt=str_replace("&oacute;","ó",$txt);
$txt=str_replace("&Uacute;","Ú",$txt);
$txt=str_replace("&uacute;","ú",$txt);
$txt=str_replace("&Ntilde;","Ñ",$txt);
$txt=str_replace("&ntilde;","ñ",$txt);
$txt=str_replace("&quot;",'"',$txt);
$txt=str_replace("&ordf;",'ª',$txt);
$txt=str_replace("&ordm;",'º',$txt);
$txt=str_replace("&amp;",'&',$txt);
$txt=str_replace("&bull;",'•',$txt);
$txt=str_replace("&iquest; &",'¿',$txt);
$txt=str_replace("&agrave;","à",$txt);
$txt=str_replace("&Agrave;","À",$txt);
$txt=str_replace("&iexcl;","¡",$txt);
$txt=str_replace("&middot;","·",$txt);
$txt=str_replace("&Ccedil;","Ç",$txt);
$txt=str_replace("&ccedil;","ç",$txt);
$txt=str_replace("&euro;",'EUR',$txt);
$txt=str_replace("&uuml;",'ü',$txt);
$txt=str_replace("&Uuml;",'Ü',$txt);
$txt=str_replace("uml;",'¨',$txt);
return $txt;
//$txt=strip_tags($cadena);
$txt=str_replace("&nbsp;", " ", $string);
$txt=str_replace("&Aacute;", "Á", $txt);
$txt=str_replace("&aacute;", "á", $txt);
$txt=str_replace("&Eacute;", "É", $txt);
$txt=str_replace("&eacute;", "é", $txt);
$txt=str_replace("&Iacute;", "Í", $txt);
$txt=str_replace("&iacute;", "í", $txt);
$txt=str_replace("&Oacute;", "Ó", $txt);
$txt=str_replace("&oacute;", "ó", $txt);
$txt=str_replace("&Uacute;", "Ú", $txt);
$txt=str_replace("&uacute;", "ú", $txt);
$txt=str_replace("&Ntilde;", "Ñ", $txt);
$txt=str_replace("&ntilde;", "ñ", $txt);
$txt=str_replace("&quot;", '"', $txt);
$txt=str_replace("&ordf;", 'ª', $txt);
$txt=str_replace("&ordm;", 'º', $txt);
$txt=str_replace("&amp;", '&', $txt);
$txt=str_replace("&bull;", '•', $txt);
$txt=str_replace("&iquest; &", '¿', $txt);
$txt=str_replace("&agrave;", "à", $txt);
$txt=str_replace("&Agrave;", "À", $txt);
$txt=str_replace("&iexcl;", "¡", $txt);
$txt=str_replace("&middot;", "·", $txt);
$txt=str_replace("&Ccedil;", "Ç", $txt);
$txt=str_replace("&ccedil;", "ç", $txt);
$txt=str_replace("&euro;", 'EUR', $txt);
$txt=str_replace("&uuml;", 'ü', $txt);
$txt=str_replace("&Uuml;", 'Ü', $txt);
$txt=str_replace("uml;", '¨', $txt);
return $txt;
}
/**
@ -243,7 +243,7 @@ function hex2dec($color = '#000000')
$vert = hexdec($V);
$B = substr($color, 5, 2);
$bleu = hexdec($B);
$tbl_couleur = array();
$tbl_couleur = [];
$tbl_couleur['R'] = $rouge;
$tbl_couleur['V'] = $vert;
$tbl_couleur['B'] = $bleu;
@ -271,4 +271,3 @@ function txtentities($html)
$trans = array_flip($trans);
return strtr($html, $trans);
}

@ -1,5 +1,5 @@
<?php
/* For license terms, see /license.txt
/* For license terms, see /license.txt
/* To show the plugin course icons you need to add these icons:
* main/img/icons/22/ranking.png
* main/img/icons/64/ranking.png
@ -15,12 +15,12 @@
*/
class Test2pdfPlugin extends Plugin
{
public $isCoursePlugin = true;
public $isCoursePlugin = true;
/**
*
* @return StaticPlugin
*/
static function create()
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
@ -31,18 +31,18 @@ class Test2pdfPlugin extends Plugin
parent::__construct(
'1.0',
'Jose Angel Ruiz - NoSoloRed (original author)',
array(
'enable_plugin' => 'boolean'
)
[
'enable_plugin' => 'boolean'
]
);
}
/**
* This method creates the tables required to this plugin
*/
function install()
public function install()
{
//Installing course settings
//Installing course settings
$this->install_course_fields_in_all_courses();
require_once api_get_path(SYS_PLUGIN_PATH) . 'test2pdf/database.php';
}
@ -50,14 +50,14 @@ class Test2pdfPlugin extends Plugin
/**
* This method drops the plugin tables
*/
function uninstall()
public function uninstall()
{
//Deleting course settings
//Deleting course settings
$this->uninstall_course_fields_in_all_courses($this->course_settings);
$tablesToBeDeleted = array(
TABLE_TEST2PDF
);
$tablesToBeDeleted = [
TABLE_TEST2PDF
];
foreach ($tablesToBeDeleted as $tableToBeDeleted) {
$table = Database::get_main_table($tableToBeDeleted);
$sql = "DROP TABLE IF EXISTS $tableToBeDeleted";

@ -16,23 +16,23 @@ $plugin = Test2pdfPlugin::create();
$t2p_plugin = $plugin->get('enable_plugin');
if ($t2p_plugin === 'true') {
$templateName = $plugin->get_lang('ViewExercises');
$tpl = new Template($templateName);
$course_id = api_get_course_int_id();
// Leer Datos y Mostrar tabla
$iconInfo = api_get_path(WEB_PLUGIN_PATH) . 'test2pdf/resources/img/24/info.png';
$iconDownload = api_get_path(WEB_PLUGIN_PATH) . 'test2pdf/resources/img/32/download.png';
$info_exercise = showExerciseCourse($course_id);
$tpl->assign('infoExercise', $info_exercise);
$tpl->assign('course_id', $course_id);
$tpl->assign('iconInfo',$iconInfo);
$tpl->assign('iconDownload',$iconDownload);
$listing_tpl = 'test2pdf/view/view-pdf.tpl';
$content = $tpl->fetch($listing_tpl);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
$templateName = $plugin->get_lang('ViewExercises');
$tpl = new Template($templateName);
$course_id = api_get_course_int_id();
// Leer Datos y Mostrar tabla
$iconInfo = api_get_path(WEB_PLUGIN_PATH) . 'test2pdf/resources/img/24/info.png';
$iconDownload = api_get_path(WEB_PLUGIN_PATH) . 'test2pdf/resources/img/32/download.png';
$info_exercise = showExerciseCourse($course_id);
$tpl->assign('infoExercise', $info_exercise);
$tpl->assign('course_id', $course_id);
$tpl->assign('iconInfo', $iconInfo);
$tpl->assign('iconDownload', $iconDownload);
$listing_tpl = 'test2pdf/view/view-pdf.tpl';
$content = $tpl->fetch($listing_tpl);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
} else {
header('Location: ../../../index.php');
}
header('Location: ../../../index.php');
}

@ -19,9 +19,9 @@ $plugin = Test2pdfPlugin::create();
$t2p_plugin = $plugin->get('enable_plugin');
if ($t2p_plugin == "true") {
$url = 'src/view-pdf.php?'.api_get_cidreq();
header('Location: ' . $url);
exit;
}else{
echo get_lang('PluginDisabledFromAdminPanel');
}
$url = 'src/view-pdf.php?'.api_get_cidreq();
header('Location: ' . $url);
exit;
} else {
echo get_lang('PluginDisabledFromAdminPanel');
}

Loading…
Cancel
Save