Browse Source

Applied fixed from FlintCI + Codacy

root 7 years ago
parent
commit
c756bdf1cc

+ 3 - 1
plugin/test2pdf/config.php

@@ -1,8 +1,10 @@
 <?php
 /* For licensing terms, see /license.txt */
 /**
- * Config the plugin
+ * Config the plugin.
+ * 
  * @package chamilo.plugin.test2pdf
+ * 
  * @author Jose Angel Ruiz <desarrollo@nosolored.com>
  */
 require_once __DIR__.'/../../main/inc/global.inc.php';

+ 1 - 1
plugin/test2pdf/index.php

@@ -1,7 +1,7 @@
 <?php
 /* For license terms, see /license.txt */
 /**
- * Show form
+ * Show form.
  */
 require_once 'config.php';
 require_once 'src/index.test2pdf.php';

+ 3 - 2
plugin/test2pdf/install.php

@@ -2,11 +2,12 @@
 /* For license terms, see /license.txt */
 /**
  * This script is included by main/admin/settings.lib.php and generally
- * includes things to execute in the main database (settings_current table)
+ * includes things to execute in the main database (settings_current table).
+ * 
  * @package chamilo.plugin.test2pdf
  */
 /**
- * Initialization
+ * Initialization.
  */
 require_once __DIR__.'/config.php';
 if (!api_is_platform_admin()) {

+ 2 - 2
plugin/test2pdf/lang/english.php

@@ -11,5 +11,5 @@ $strings['DownloadOnlyAnswer'] = "Download answers";
 $strings['DownloadAll'] = "Download all";
 $strings['PluginDisabledFromAdminPanel'] = "The plugin has been disabled from the admin panel";
 $strings['AnswersColumn'] = "Answers: ";
-$strings['Statement']= "Statement";
-$strings['PageX']= "Page %s";
+$strings['Statement'] = "Statement";
+$strings['PageX'] = "Page %s";

+ 2 - 2
plugin/test2pdf/lang/french.php

@@ -11,5 +11,5 @@ $strings['DownloadOnlyAnswer'] = "Télécharger les réponses";
 $strings['DownloadAll'] = "Tout télécharger";
 $strings['PluginDisabledFromAdminPanel'] = "Le plugin a été désactivé depuis la page d'administration";
 $strings['AnswersColumn'] = "Réponses: ";
-$strings['Statement']= "Énoncé";
-$strings['PageX']= "Page %s";
+$strings['Statement'] = "Énoncé";
+$strings['PageX'] = "Page %s";

+ 2 - 2
plugin/test2pdf/lang/spanish.php

@@ -11,5 +11,5 @@ $strings['DownloadOnlyAnswer'] = "Descargar respuestas";
 $strings['DownloadAll'] = "Descargar todo";
 $strings['PluginDisabledFromAdminPanel'] = "La herramienta está deshabilitada desde la administración";
 $strings['AnswersColumn'] = "Respuestas: ";
-$strings['Statement']= "Enunciado";
-$strings['PageX']= "Página %s";
+$strings['Statement'] = "Enunciado";
+$strings['PageX'] = "Página %s";

+ 2 - 1
plugin/test2pdf/plugin.php

@@ -2,7 +2,8 @@
 /* For license terms, see /license.txt */
 /**
  * This script is a configuration file for the date plugin. You can use it as a master for other platform plugins (course plugins are slightly different).
- * These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins)
+ * These settings will be used in the administration interface for plugins (Chamilo configuration settings->Plugins).
+ * 
  * @package chamilo.plugin.test2pdf
  */
 /**

+ 3 - 3
plugin/test2pdf/src/download-pdf.php

@@ -48,7 +48,7 @@ if ($_GET['type'] == 'question' || $_GET['type'] == 'all') {
         }
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetTextColor(64);
-        $pdf->MultiCell(0, 7, ($key+$j).' - '.$infoQuestion['question'], 0, 'L', false);
+        $pdf->MultiCell(0, 7, ($key + $j).' - '.$infoQuestion['question'], 0, 'L', false);
         if (!empty($infoQuestion['description'])) {
             $pdf->WriteHTML(removeQuotes($infoQuestion['description']));
         }
@@ -83,7 +83,7 @@ if ($_GET['type'] == 'answer' || $_GET['type'] == 'all') {
                 $infoQuestion['type'] == 14
             ) {
                 $infoAnswer = getAnswers($courseId, $value);
-                $answers .= ' '.($key+$j).' -';
+                $answers .= ' '.($key + $j).' -';
                 foreach ($infoAnswer as $key2 => $value2) {
                     if ($value2['correct'] == 1) {
                         $answers .= ' '.$letters[$key2].',';
@@ -97,7 +97,7 @@ if ($_GET['type'] == 'answer' || $_GET['type'] == 'all') {
                 $infoAnswer = getAnswers($courseId, $value);
                 foreach ($infoAnswer as $key2 => $value2) {
                     if ($value2['correct'] == 1) {
-                        $answers .= ' '.($key+$j).' - '.$letters[$key2].' ';
+                        $answers .= ' '.($key + $j).' - '.$letters[$key2].' ';
                         break;
                     }
                 }

+ 98 - 83
plugin/test2pdf/src/test2pdf.lib.php

@@ -1,18 +1,22 @@
 <?php
 /* For license terms, see /license.txt */
 /**
- * Functions
+ * Functions.
+ * 
  * @package chamilo.plugin.test2pdf
  */
 
-$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'];
+$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
+ * List exercises.
+ * 
  * @param int $courseId Course ID
  * @param int $sessionId Session ID
- * @return array Results (list of exercice details)
+ * 
  * @throws Exception
+ * 
+ *  * @return array Results (list of exercice details)
  */
 
 function showExerciseCourse($courseId, $sessionId = 0)
@@ -39,9 +43,11 @@ function showExerciseCourse($courseId, $sessionId = 0)
 }
 
 /**
- * List quiz details
- * @return array Results (list of quiz details)
+ * List quiz details.
+ * 
  * @throws Exception
+ * 
+ * @return array Results (list of quiz details)
  */
 function getInfoQuiz($courseId, $id)
 {
@@ -56,9 +62,11 @@ function getInfoQuiz($courseId, $id)
 }
 
 /**
- * List question_id
- * @return array Results (list question ID)
+ * List question_id.
+ * 
  * @throws Exception
+ * 
+ * @return array Results (list question ID)
  */
 function getQuestions($courseId, $quizId, $sessionId = 0)
 {
@@ -87,9 +95,11 @@ function getQuestions($courseId, $quizId, $sessionId = 0)
 }
 
 /**
- * List question details
- * @return array Results (list of question details)
+ * List question details.
+ *
  * @throws Exception
+ * 
+ * @return array Results (list of question details)
  */
 function getInfoQuestion($courseId, $id)
 {
@@ -107,9 +117,11 @@ function getInfoQuestion($courseId, $id)
 }
 
 /**
- * List answer details
- * @return array Results (list of answer by question_id)
+ * List answer details.
+ * 
  * @throws Exception
+ * 
+ * @return array Results (list of answer by question_id)
  */
 function getAnswers($courseId, $id)
 {
@@ -129,91 +141,94 @@ function getAnswers($courseId, $id)
 }
 
 /**
- * Remove all html tag
+ * Remove all html tag.
+ * 
  * @param string $string The string to be stripped of HTML
+ * 
  * @return string clean of html tag
  */
 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("&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);
+    $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;
 }
 
 /**
- * Remove all html tag
+ * Remove all html tag.
+ * 
  * @param string $string The string to be stripped of accents
+ * 
  * @return string clean of html tag
  */
 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);
+    $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;
 }

+ 17 - 14
plugin/test2pdf/src/test2pdf_plugin.class.php

@@ -1,35 +1,38 @@
 <?php
 /**
- * Plugin class for the Test2Pdf plugin
+ * Plugin class for the Test2Pdf plugin.
+ * 
  * @package chamilo.plugin.test2pdf
+ * 
  * @author Jose Angel Ruiz <desarrollo@nosolored.com>
  */
 class Test2pdfPlugin extends Plugin
 {
     public $isCoursePlugin = true;
-    /**
-     *
-     * @return StaticPlugin
-     */
-    public static function create()
-    {
-        static $result = null;
-        return $result ? $result : $result = new self();
-    }
-
+    
     protected function __construct()
     {
         parent::__construct(
             '1.0',
             'Jose Angel Ruiz - NoSoloRed (original author)',
             [
-                'enable_plugin' => 'boolean'
+                'enable_plugin' => 'boolean',
             ]
         );
     }
+    
+    /**
+     * @return StaticPlugin
+     */
+    public static function create()
+    {
+        static $result = null;
+        
+        return $result ? $result : $result = new self();
+    }
 
     /**
-     * This method creates the tables required to this plugin
+     * This method creates the tables required to this plugin.
      */
     public function install()
     {
@@ -48,7 +51,7 @@ class Test2pdfPlugin extends Plugin
     }
 
     /**
-     * This method drops the plugin tables
+     * This method drops the plugin tables.
      */
     public function uninstall()
     {

+ 5 - 5
plugin/test2pdf/src/view-pdf.php

@@ -1,11 +1,12 @@
 <?php
 /* For license terms, see /license.txt */
 /**
- * Configuration script for the Test to Pdf plugin
+ * Configuration script for the Test to Pdf plugin.
+ * 
  * @package chamilo.plugin.test2pdf
  */
 /**
- * Initialization
+ * Initialization.
  */
 require_once '../config.php';
 api_protect_course_script(true);
@@ -18,12 +19,11 @@ if ($enable) {
     $tpl = new Template($templateName);
     $courseId = api_get_course_int_id();
     $sessionId = api_get_session_id();
-    
-    // Leer Datos y Mostrar tabla
+
     $infoExercise = showExerciseCourse($courseId, $sessionId);
     $tpl->assign('infoExercise', $infoExercise);
     $tpl->assign('course_id', $courseId);
-    
+
     $listing_tpl = 'test2pdf/view/view-pdf.tpl';
     $content = $tpl->fetch($listing_tpl);
     $tpl->assign('content', $content);

+ 5 - 4
plugin/test2pdf/start.php

@@ -2,10 +2,10 @@
 /* For license terms, see /license.txt */
 
 /**
- * This script initiates a test2pdf plugin
+ * This script initiates a test2pdf plugin.
+ * 
  * @package chamilo.plugin.test2pdf
  */
-
 require_once __DIR__.'/../../vendor/autoload.php';
 
 $course_plugin = 'test2pdf'; //needed in order to load the plugin lang variables
@@ -18,10 +18,11 @@ $enable = $plugin->get('enable_plugin') == 'true';
 
 if ($enable) {
     $url = 'src/view-pdf.php?'.api_get_cidreq();
-    header('Location: ' . $url);
+    header('Location: '.$url);
     exit;
 } else {
     Display::addFlash(Display::return_message($plugin->get_lang('PluginDisabledFromAdminPanel')));
-    header('Location:'.api_get_path(WEB_PATH).'courses/'.api_get_course_id().'/index.php?id_session='.api_get_session_id());
+    $url = api_get_path(WEB_PATH).'courses/'.api_get_course_id().'/index.php?id_session='.api_get_session_id();
+    header('Location:'.$url);
     exit;
 }

+ 3 - 2
plugin/test2pdf/uninstall.php

@@ -3,11 +3,12 @@
 /**
  * This script is included by main/admin/settings.lib.php when unselecting a plugin
  * and is meant to remove things installed by the install.php script in both
- * the global database and the courses tables
+ * the global database and the courses tables.
+ * 
  * @package chamilo.plugin.test2pdf
  */
 /**
- * Queries
+ * Queries.
  */
 require_once __DIR__.'/config.php';
 Test2pdfPlugin::create()->uninstall();