From 332ba77f6940aabc07c7e7dcaeaa4a8e65269ff2 Mon Sep 17 00:00:00 2001 From: Dragon Dionysius Date: Mon, 4 Feb 2019 04:15:22 +0100 Subject: [PATCH] fixed import coding style and use html_writer whenever html tags need to be written --- attempt.php | 6 +++--- classes/question/bank/question_bank_filter.php | 6 +++--- classes/question/bank/studentquiz_bank_view.php | 8 ++++---- db/uninstall.php | 2 +- db/upgrade.php | 4 ++-- index.php | 10 +++++----- migrate.php | 2 +- preview.php | 2 +- questionbank.ajax.php | 2 +- renderer.php | 6 +++--- reportrank.php | 6 +++--- reportstat.php | 6 +++--- view.php | 6 +++--- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/attempt.php b/attempt.php index 4ceb74ea..098b211b 100644 --- a/attempt.php +++ b/attempt.php @@ -22,9 +22,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(dirname(dirname(__FILE__))) . '/config.php'); +require_once(__DIR__ . '/../../config.php'); require_once($CFG->libdir . '/questionlib.php'); -require_once(dirname(__FILE__) . '/locallib.php'); +require_once(__DIR__ . '/locallib.php'); // Get parameters. $cmid = required_param('cmid', PARAM_INT); @@ -217,7 +217,7 @@ $html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $actionurl, 'enctype' => 'multipart/form-data', 'id' => 'responseform')); -$html .= ''; +$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'cmid', 'value' => $cmid, 'class' => 'cmid_field')); // Output the question. $html .= $questionusage->render_question($slot, $options, (string)$slot); diff --git a/classes/question/bank/question_bank_filter.php b/classes/question/bank/question_bank_filter.php index a1cdf26c..8ab9c19b 100644 --- a/classes/question/bank/question_bank_filter.php +++ b/classes/question/bank/question_bank_filter.php @@ -24,9 +24,9 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot.'/lib/formslib.php'); -require_once($CFG->dirroot.'/user/filters/text.php'); -require_once($CFG->dirroot.'/user/filters/date.php'); +require_once($CFG->dirroot . '/lib/formslib.php'); +require_once($CFG->dirroot . '/user/filters/text.php'); +require_once($CFG->dirroot . '/user/filters/date.php'); /** * Question bank filter form intance diff --git a/classes/question/bank/studentquiz_bank_view.php b/classes/question/bank/studentquiz_bank_view.php index 7b76bcb9..dcef9e43 100755 --- a/classes/question/bank/studentquiz_bank_view.php +++ b/classes/question/bank/studentquiz_bank_view.php @@ -349,7 +349,7 @@ public function process_actions_needing_ui() { if (optional_param('deleteselected', false, PARAM_BOOL)) { // Add an explanation about questions in use. if ($inuse) { - $questionnames .= '
'.get_string('questionsinuse', 'question'); + $questionnames .= \html_writer::empty_tag('br').get_string('questionsinuse', 'question'); } $deleteurl = new \moodle_url($baseurl, array('deleteselected' => $questionlist, 'confirm' => md5($questionlist), @@ -361,7 +361,7 @@ public function process_actions_needing_ui() { } else if (optional_param('approveselected', false, PARAM_BOOL)) { // Add an explanation about questions in use. if ($inuse) { - $questionnames .= '
'.get_string('questionsinuse', 'studentquiz'); + $questionnames .= \html_writer::empty_tag('br').get_string('questionsinuse', 'studentquiz'); } $approveurl = new \moodle_url($baseurl, array('approveselected' => $questionlist, 'confirm' => md5($questionlist), @@ -549,7 +549,7 @@ protected function display_question_list($contexts, $pageurl, $categoryandcontex protected function display_question_list_rows() { $output = ''; - $output .= '
'; + $output .= \html_writer::start_div('categoryquestionscontainer'); ob_start(); $this->start_table(); $rowcount = 0; @@ -561,7 +561,7 @@ protected function display_question_list_rows() { $this->end_table(); $output .= ob_get_contents(); ob_end_clean(); - $output .= "
\n"; + $output .= \html_writer::end_div(); return $output; } diff --git a/db/uninstall.php b/db/uninstall.php index 2394cb24..7a38cb50 100644 --- a/db/uninstall.php +++ b/db/uninstall.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot.'/course/lib.php'); +require_once($CFG->dirroot . '/course/lib.php'); require_once(__DIR__ . '/../lib.php'); /** diff --git a/db/upgrade.php b/db/upgrade.php index ec002c92..e0944f7a 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die(); -require_once(dirname(__DIR__) . '/locallib.php'); +require_once(__DIR__ . '/../locallib.php'); /** * Execute StudentQuiz upgrade from the given old version @@ -321,7 +321,7 @@ function xmldb_studentquiz_upgrade($oldversion) { // Update capabilities list and permission types, to make sure the defaults are set after this upgrade. if ($oldversion < 2017112602) { // Load current access definition for easier iteration. - require_once(dirname(__DIR__) . '/db/access.php'); + require_once(__DIR__ . '/../db/access.php'); // Load all contexts this has to be defined. // Only system context needed, as by default it's inherited from there. // if someone did make an override, it's intentional. diff --git a/index.php b/index.php index 50fffc47..9a48307e 100644 --- a/index.php +++ b/index.php @@ -22,8 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(dirname(__DIR__)).'/config.php'); -require_once(__DIR__ .'/lib.php'); +require_once(__DIR__ . '/../../config.php'); +require_once(__DIR__ . '/lib.php'); $id = required_param('id', PARAM_INT); if (!$course = $DB->get_record('course', array('id' => $id))) { @@ -95,10 +95,10 @@ // Link to the instance. $class = ''; if (!$studentquiz->visible) { - $class = ' class="dimmed"'; + $class = 'dimmed'; } - $data[] = "coursemodule\">" . - format_string($studentquiz->name, true) . ''; + $data[] = html_writer::tag('a', format_string($studentquiz->name, true), array( + 'href' => "view.php?id=" . $studentquiz->coursemodule, 'class' => $class)); $table->data[] = $data; } // End of loop over studentquiz instances. diff --git a/migrate.php b/migrate.php index c0f9114d..e288289f 100644 --- a/migrate.php +++ b/migrate.php @@ -23,7 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(dirname(__DIR__)).'/config.php'); +require_once(__DIR__ . '/../../config.php'); require_once(__DIR__ . '/viewlib.php'); require_once(__DIR__ . '/renderer.php'); diff --git a/preview.php b/preview.php index 8346dccd..17589d97 100644 --- a/preview.php +++ b/preview.php @@ -120,7 +120,7 @@ if ($question) { echo html_writer::start_tag('form', array('method' => 'post', 'action' => $actionurl, 'enctype' => 'multipart/form-data', 'id' => 'responseform')); - echo ''; + echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'cmid', 'value' => $cmid, 'class' => 'cmid_field')); echo $quba->render_question($slot, $options, 'i'); diff --git a/questionbank.ajax.php b/questionbank.ajax.php index 8777c30f..b14093c0 100644 --- a/questionbank.ajax.php +++ b/questionbank.ajax.php @@ -24,7 +24,7 @@ define('AJAX_SCRIPT', true); -require_once(dirname(dirname(__DIR__)).'/config.php'); +require_once(__DIR__ . '/../../config.php'); require_once($CFG->dirroot . '/mod/quiz/locallib.php'); require_once($CFG->dirroot . '/question/editlib.php'); diff --git a/renderer.php b/renderer.php index 6c55d74c..a04aed75 100755 --- a/renderer.php +++ b/renderer.php @@ -261,9 +261,9 @@ public function render_progress_bar($info, $texttotal=null, $bicolor=false) { $percentone = round(100 * ($info->one / $info->total)); if (!empty($texttotal)) { - $text = '' . $texttotal . ''; + $text = html_writer::tag('text', $texttotal, array('xml:space' => 'preserve', 'text-anchor' => 'start', 'font-family' => 'Helvetica, Arial, sans-serif', + 'font-size' => '12', 'font-weight' => 'bold', 'id' => 'svg_text', 'x' => '50%', 'y' => '50%', 'alignment-baseline' => 'middle', 'text-anchor' => 'middle', + 'stroke-width' => '0', 'stroke' => '#000', 'fill' => '#000')); } else { $text = ''; } diff --git a/reportrank.php b/reportrank.php index 556062a0..a29caaef 100644 --- a/reportrank.php +++ b/reportrank.php @@ -22,9 +22,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(dirname(__DIR__)).'/config.php'); -require_once(__DIR__.'/reportlib.php'); -require_once(__DIR__.'/classes/event/studentquiz_report_rank_viewed.php'); +require_once(__DIR__ . '/../../config.php'); +require_once(__DIR__ . '/reportlib.php'); +require_once(__DIR__ . '/classes/event/studentquiz_report_rank_viewed.php'); $cmid = optional_param('id', 0, PARAM_INT); if (!$cmid) { diff --git a/reportstat.php b/reportstat.php index 91219171..3d6b7521 100644 --- a/reportstat.php +++ b/reportstat.php @@ -22,9 +22,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(dirname(__DIR__)).'/config.php'); -require_once(__DIR__.'/reportlib.php'); -require_once(__DIR__.'/classes/event/studentquiz_report_quiz_viewed.php'); +require_once(__DIR__ . '/../../config.php'); +require_once(__DIR__ . '/reportlib.php'); +require_once(__DIR__ . '/classes/event/studentquiz_report_quiz_viewed.php'); $cmid = optional_param('id', 0, PARAM_INT); if (!$cmid) { diff --git a/view.php b/view.php index 6c816af8..a4f5d44e 100755 --- a/view.php +++ b/view.php @@ -25,10 +25,10 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(dirname(__DIR__)).'/config.php'); +require_once(__DIR__ . '/../../config.php'); require_once(__DIR__ . '/viewlib.php'); -require_once(__DIR__.'/classes/event/studentquiz_questionbank_viewed.php'); -require_once(__DIR__.'/reportlib.php'); +require_once(__DIR__ . '/classes/event/studentquiz_questionbank_viewed.php'); +require_once(__DIR__ . '/reportlib.php'); // Get parameters. if (!$cmid = optional_param('cmid', 0, PARAM_INT)) {