From 17b2a1edef71441d11117b265b54fe97d677513e Mon Sep 17 00:00:00 2001
From: Chris Sangwin <C.J.Sangwin@gmail.com>
Date: Wed, 11 Jul 2018 13:44:12 +0100
Subject: [PATCH] Code tidy, and ignore 3rd party libraries on code checker.
---
bulktestall.php | 2 +
bulktestindex.php | 2 +
deploy.php | 2 +
equivdemo.php | 2 +
exportone.php | 2 +
lang/en/qtype_stack.php | 3 +-
questiontestdelete.php | 2 +
questiontestedit.php | 3 ++
questiontestrun.php | 2 +
stack/answertest/atdecplaceswrong.class.php | 42 ++++++++++-----------
stack/bulktester.class.php | 2 +
stack/cas/installhelper.class.php | 4 +-
tests/behat/behat_qtype_stack.php | 2 +-
tests/input_textarea_test.php | 1 +
tests/multilang_test.php | 4 +-
tests/parser_test.php | 2 +
tests/restore_logic_test.php | 1 +
thirdpartylibs.xml | 25 ++++++++++++
tidyquestion.php | 2 +
19 files changed, 77 insertions(+), 28 deletions(-)
create mode 100644 thirdpartylibs.xml
diff --git a/bulktestall.php b/bulktestall.php
index 0077387d2..a15c31c5d 100644
--- a/bulktestall.php
+++ b/bulktestall.php
@@ -48,6 +48,8 @@ $PAGE->set_context($context);
$title = stack_string('bulktesttitle', $context->get_context_name());
$PAGE->set_title($title);
+require_login();
+
// Create the helper class.
$bulktester = new stack_bulk_tester();
$allpassed = true;
diff --git a/bulktestindex.php b/bulktestindex.php
index e28964e10..dcdd2fbe2 100644
--- a/bulktestindex.php
+++ b/bulktestindex.php
@@ -40,6 +40,8 @@ $PAGE->set_url('/question/type/stack/bulktestindex.php');
$PAGE->set_context($context);
$PAGE->set_title(stack_string('bulktestindextitle'));
+require_login();
+
// Create the helper class.
$bulktester = new stack_bulk_tester();
diff --git a/deploy.php b/deploy.php
index 2522962b3..079c1c0d7 100644
--- a/deploy.php
+++ b/deploy.php
@@ -46,6 +46,8 @@ $PAGE->set_url($nexturl); // Since this script always ends in a redirect.
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_pagelayout('admin');
+require_login();
+
// Process deploy if applicable.
$deploy = optional_param('deploy', null, PARAM_INT);
if (!is_null($deploy)) {
diff --git a/equivdemo.php b/equivdemo.php
index 18b5b7683..a5a0f621a 100644
--- a/equivdemo.php
+++ b/equivdemo.php
@@ -61,6 +61,8 @@ $PAGE->set_url('/question/type/stack/equivdemo.php', $urlparams);
$title = "Equivalence reasoning test cases";
$PAGE->set_title($title);
+require_login();
+
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
diff --git a/exportone.php b/exportone.php
index cf23d80a8..20496aa9a 100644
--- a/exportone.php
+++ b/exportone.php
@@ -50,6 +50,8 @@ $PAGE->set_url($nexturl); // Since this script always ends in a redirect.
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_pagelayout('admin');
+require_login();
+
// Set up the export format.
$qformat = new qformat_xml();
$filename = question_default_export_filename($COURSE, $questiondata) .
diff --git a/lang/en/qtype_stack.php b/lang/en/qtype_stack.php
index 68b258351..a9c6091ba 100644
--- a/lang/en/qtype_stack.php
+++ b/lang/en/qtype_stack.php
@@ -702,6 +702,7 @@ $string['stackOptions_AnsTest_values_NumRelative'] = "NumRelative";
$string['stackOptions_AnsTest_values_NumAbsolute'] = "NumAbsolute";
$string['stackOptions_AnsTest_values_NumSigFigs'] = "NumSigFigs";
$string['stackOptions_AnsTest_values_NumDecPlaces'] = "NumDecPlaces";
+$string['stackOptions_AnsTest_values_NumDecPlacesWrong'] = "NumDecPlacesWrong";
$string['stackOptions_AnsTest_values_UnitsSigFigs'] = "UnitsSigFigs";
$string['stackOptions_AnsTest_values_UnitsStrictSigFigs'] = "UnitsStrictSigFigs";
$string['stackOptions_AnsTest_values_UnitsRelative'] = "UnitsRelative";
@@ -831,7 +832,7 @@ $string['ATNumDecPlaces_OptNotInt'] = 'For ATNumDecPlaces the test option mus
$string['ATNumDecPlaces_NoDP'] = 'Your answer must be a decimal number, including a decimal point. ';
$string['ATNumDecPlaces_Wrong_DPs'] = 'Your answer has been given to the wrong number of decimal places.';
-$string['ATNumDecPlacesWrong_OptNotInt'] = 'For ATNumDecPlacesWrong the test option must be a positive integer, in fact "{$a->opt}" was received. ';
+$string['ATNumDecPlacesWrong_OptNotInt'] = 'For ATNumDecPlacesWrong the test option must be a positive integer, in fact "{$a->opt}" was received. ';
$string['ATSysEquiv_SA_not_list'] = 'Your answer should be a list, but it is not!';
$string['ATSysEquiv_SB_not_list'] = 'The teacher\'s answer is not a list. Please contact your teacher.';
diff --git a/questiontestdelete.php b/questiontestdelete.php
index 568ba6118..d8a54d8b4 100644
--- a/questiontestdelete.php
+++ b/questiontestdelete.php
@@ -52,6 +52,8 @@ $PAGE->set_url('/question/type/stack/questiontestdelete.php', $urlparams);
$title = stack_string('deletetestcase',
array('no' => $testcase, 'question' => format_string($question->name)));
+require_login();
+
if (data_submitted() && confirm_sesskey()) {
// User has confirmed. Actually delete the test case.
question_bank::get_qtype('stack')->delete_question_test($questionid, $testcase);
diff --git a/questiontestedit.php b/questiontestedit.php
index 0388d83c9..34617ef7c 100644
--- a/questiontestedit.php
+++ b/questiontestedit.php
@@ -65,6 +65,9 @@ $PAGE->set_url('/question/type/stack/questiontestedit.php', $urlparams);
$PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->set_pagelayout('popup');
+
+require_login();
+
// Create the question usage we will use.
$quba = question_engine::make_questions_usage_by_activity('qtype_stack', $context);
$quba->set_preferred_behaviour('adaptive');
diff --git a/questiontestrun.php b/questiontestrun.php
index 8a022df59..8a256bdd0 100644
--- a/questiontestrun.php
+++ b/questiontestrun.php
@@ -62,6 +62,8 @@ $PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->set_pagelayout('popup');
+require_login();
+
// Create some other useful links.
$qbankparams = $urlparams;
unset($qbankparams['questionid']);
diff --git a/stack/answertest/atdecplaceswrong.class.php b/stack/answertest/atdecplaceswrong.class.php
index 898856902..0427dce56 100644
--- a/stack/answertest/atdecplaceswrong.class.php
+++ b/stack/answertest/atdecplaceswrong.class.php
@@ -60,8 +60,8 @@ class stack_anstest_atdecplaceswrong extends stack_anstest {
$cascommands[] = "caschat0:{$this->sanskey}";
$cascommands[] = "caschat1:{$this->tanskey}";
$cascommands[] = "caschat2:ev({$this->atoption},simp)";
- $cascommands[] = "caschat3:numberp({$this->sanskey})";
- $cascommands[] = "caschat4:numberp({$this->tanskey})";
+ $cascommands[] = "caschat3:numberp({$this->sanskey})";
+ $cascommands[] = "caschat4:numberp({$this->tanskey})";
$cts = array();
foreach ($cascommands as $com) {
@@ -103,15 +103,15 @@ class stack_anstest_atdecplaceswrong extends stack_anstest {
return null;
}
- if ('' != $session->get_errors_key('caschat3')) {
- $this->aterror = 'TEST_FAILED';
- $this->atfeedback .= stack_string('TEST_FAILED', array('errors' => $session->get_errors_key('caschat3')));
- $anotes[] = 'ATNumDecPlacesWrong_ERR_sansnum';
- $this->atansnote = implode('. ', $anotes).'.';
- $this->atmark = 0;
- $this->atvalid = false;
- return null;
- }
+ if ('' != $session->get_errors_key('caschat3')) {
+ $this->aterror = 'TEST_FAILED';
+ $this->atfeedback .= stack_string('TEST_FAILED', array('errors' => $session->get_errors_key('caschat3')));
+ $anotes[] = 'ATNumDecPlacesWrong_ERR_sansnum';
+ $this->atansnote = implode('. ', $anotes).'.';
+ $this->atmark = 0;
+ $this->atvalid = false;
+ return null;
+ }
if ('' != $session->get_errors_key('caschat4')) {
$this->aterror = 'TEST_FAILED';
@@ -124,13 +124,13 @@ class stack_anstest_atdecplaceswrong extends stack_anstest {
}
// These should not throw an error. The test just returns false.
- if ('false' === $session->get_value_key('caschat3')) {
- $anotes[] = 'ATNumDecPlacesWrong_Sans_Not_Num';
- $this->atansnote = implode('. ', $anotes).'.';
- $this->atmark = 0;
- $this->atvalid = false;
- return null;
- }
+ if ('false' === $session->get_value_key('caschat3')) {
+ $anotes[] = 'ATNumDecPlacesWrong_Sans_Not_Num';
+ $this->atansnote = implode('. ', $anotes).'.';
+ $this->atmark = 0;
+ $this->atvalid = false;
+ return null;
+ }
if ('false' === $session->get_value_key('caschat4')) {
$anotes[] = 'ATNumDecPlacesWrong_Tans_Not_Num';
@@ -147,16 +147,16 @@ class stack_anstest_atdecplaceswrong extends stack_anstest {
// Ignore the decimal point by eliminating it.
$sa = str_replace('.', '', $sa);
- $ta = str_replace('.', '', $ta);
+ $ta = str_replace('.', '', $ta);
// Remove any leading zeros.
$sa = substr($sa, strcspn($sa, '123456789'));
$ta = substr($ta, strcspn($ta, '123456789'));
-
+
// Add sufficient trailing zeros.
// This condones any lack of trailing zeros (for this test).
$sa .= str_repeat('0', (int) $ndps);
- $ta .= str_repeat('0', (int) $ndps);
+ $ta .= str_repeat('0', (int) $ndps);
$sa = substr($sa, 0, (int) $ndps);
$ta = substr($ta, 0, (int) $ndps);
diff --git a/stack/bulktester.class.php b/stack/bulktester.class.php
index 84b14a279..ae91bc848 100644
--- a/stack/bulktester.class.php
+++ b/stack/bulktester.class.php
@@ -19,6 +19,8 @@
// @copyright 2015 The Open University.
// @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
+defined('MOODLE_INTERNAL') || die();
+
class stack_bulk_tester {
/**
diff --git a/stack/cas/installhelper.class.php b/stack/cas/installhelper.class.php
index e1154170d..67dff239c 100644
--- a/stack/cas/installhelper.class.php
+++ b/stack/cas/installhelper.class.php
@@ -16,9 +16,7 @@
defined('MOODLE_INTERNAL') || die();
-// The file provides helper code for creating the files needed to connect to the CAS.
-
-require_once(__DIR__.'/../../../../../config.php');
+// This provides helper code for creating the files needed to connect to the CAS.
require_once(__DIR__ . '/../../locallib.php');
require_once(__DIR__ . '/../utils.class.php');
diff --git a/tests/behat/behat_qtype_stack.php b/tests/behat/behat_qtype_stack.php
index 950b637ea..aa5936065 100644
--- a/tests/behat/behat_qtype_stack.php
+++ b/tests/behat/behat_qtype_stack.php
@@ -46,7 +46,7 @@ class behat_qtype_stack extends behat_base {
*
* @When /^I set up STACK using the PHPUnit configuration$/
*/
- public function iSetUpStackUsingThePhpunitConfiguration() {
+ public function isetupstackusingthephpunitconfiguration() {
// The require_once is here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../fixtures/test_maxima_configuration.php');
diff --git a/tests/input_textarea_test.php b/tests/input_textarea_test.php
index a3cb51d6a..a3098716f 100644
--- a/tests/input_textarea_test.php
+++ b/tests/input_textarea_test.php
@@ -179,6 +179,7 @@ class stack_textarea_input_test extends qtype_stack_testcase {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class testable_stack_textarea_input extends stack_textarea_input {
+ // @codingStandardsIgnoreLine
public function tokenize_list($in) {
return parent::tokenize_list($in);
}
diff --git a/tests/multilang_test.php b/tests/multilang_test.php
index 30ca7def0..524c154c5 100644
--- a/tests/multilang_test.php
+++ b/tests/multilang_test.php
@@ -21,8 +21,8 @@ require_once(__DIR__ . '/../lang/multilang.php');
// Unit tests for stack_multilang.
//
-// @copyright 2018 The University of Edinburgh
-// @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+// @copyright 2018 The University of Edinburgh.
+// @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
/**
* @group qtype_stack
diff --git a/tests/parser_test.php b/tests/parser_test.php
index f4f6389e8..f6fc81405 100644
--- a/tests/parser_test.php
+++ b/tests/parser_test.php
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Stack. If not, see <http://www.gnu.org/licenses/>.
+defined('MOODLE_INTERNAL') || die();
+
require_once(__DIR__ . '/../locallib.php');
require_once(__DIR__ . '/fixtures/test_base.php');
require_once(__DIR__ . '/../stack/cas/castext/castextparser.class.php');
diff --git a/tests/restore_logic_test.php b/tests/restore_logic_test.php
index bda993d90..2711c3242 100644
--- a/tests/restore_logic_test.php
+++ b/tests/restore_logic_test.php
@@ -65,6 +65,7 @@ class testable_restore_qtype_stack_plugin extends restore_qtype_stack_plugin {
return $this->log;
}
+ // @codingStandardsIgnoreLine
public function after_execute_question() {
// Make method public.
parent::after_execute_question();
diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml
new file mode 100644
index 000000000..41864283b
--- /dev/null
+++ b/thirdpartylibs.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<libraries>
+ <library>
+ <location>amd</location>
+ <name>JSXGraph</name>
+ <version>?</version>
+ <license>GNU LGPL or MIT License</license>
+ </library>
+ <library>
+ <location>thirdparty/php-peg</location>
+ <name>PHP-PEG</name>
+ <version>2.0.0</version>
+ <license>MIT, BSD, and GPL</license>
+ </library>
+ <library>
+ <location>stack/cas/castext/</location>
+ <name>PHP-PEG autogenerated PHP files</name>
+ <version>As for STACK</version>
+ <license>GPL</license>
+ </library>
+</libraries>
+
+
+
+
diff --git a/tidyquestion.php b/tidyquestion.php
index 4f323b0bf..558b793fc 100644
--- a/tidyquestion.php
+++ b/tidyquestion.php
@@ -49,6 +49,8 @@ $PAGE->set_title($title);
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_pagelayout('admin');
+require_login();
+
// The URL back to the preview page.
$returnurl = question_preview_url($questionid, null, null, null, null, $context);
--
GitLab