Skip to content

Commit

Permalink
improve code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-web committed Dec 18, 2023
1 parent 3fee086 commit c4ff803
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1']
moodle-branch: ['MOODLE_402_STABLE', 'MOODLE_403_STABLE']
database: [pgsql, mariadb]
php: ['8.1']
moodle-branch: ['MOODLE_403_STABLE']
database: [mariadb]

steps:
- name: Check out repository code
Expand Down
2 changes: 0 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ To release a new version of JSXGraph into the filter follow the steps below:
Use the release notes from GitHub.
10. Comment under the Google Groups post of JSXGraph release: https://groups.google.com/g/jsxgraph.

For seeing travis prechecks go here: https://travis-ci.org/github/jsxgraph/moodle-filter_jsxgraph

Moodle Plugin CI: https://moodlehq.github.io/moodle-plugin-ci/
30 changes: 15 additions & 15 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class filter_jsxgraph extends moodle_text_filter {
*
* @var String
*/
private const BOARDID_CONST = "BOARDID";
private const BOARDID_CONST = "BOARDID";

/**
* Name for JavaScript constant array of board ids.
Expand Down Expand Up @@ -160,14 +160,14 @@ class filter_jsxgraph extends moodle_text_filter {
private $versionmoodle = null;

/**
* Main filter function
* Main filter function.
*
* @param String $text
* @param Array $options
* @param String $text Moodle standard.
* @param Array $options Moodle standard.
*
* @return String
*/
public function filter($text, array $options = array()) {
public function filter($text, array $options = []) {
// To optimize speed, search for a <jsxgraph> tag (avoiding to parse everything on every text).
if (!is_int(strpos($text, '<' . static::TAG))) {
return $text;
Expand Down Expand Up @@ -311,7 +311,7 @@ private function get_replaced_node($node, $index) {
/**
* Combine global code and code contained in $node. Define some JavaScript constants. Apply this code to the dom.
*
* @param $node domNode
* @param $node domNode JSXGraph node.
*
* @return void
*/
Expand All @@ -321,7 +321,7 @@ private function apply_js($node) {
$code = "";

// Load global JavaScript code from administrator settings.
// --------------------------------------------------------
// ........................................................

if ($this->settings['globalJS'] !== '' && $attributes['useGlobalJS'][0]) {
$code .=
Expand All @@ -332,7 +332,7 @@ private function apply_js($node) {
}

// Define BOARDID constants and some accessibility.
// ------------------------------------------------
// ................................................

$code .=
"// Define BOARDID constants.\n" .
Expand All @@ -358,7 +358,7 @@ private function apply_js($node) {
"}\n";

// Load code from <jsxgraph>-node.
// -------------------------------
// ...............................

$usercode = $this->document->saveHTML($node);
// Remove <jsxgraph> tags.
Expand All @@ -372,20 +372,20 @@ private function apply_js($node) {
$code .= $usercode;

// Surround the code with version-specific strings.
// ------------------------------------------------
// ................................................

$surroundings = $this->get_code_surroundings();
$code = $surroundings["pre"] . "\n\n" . $code . $surroundings["post"];

// Convert HTML-entities in code.
// ------------------------------
// ..............................

if ($this->settings['HTMLentities'] && $attributes['entities']) {
$code = html_entity_decode($code);
}

// Paste the code.
// ---------------
// ...............

// POI: Version differences.
if ($this->versionmoodle["is_newer_version"]) {
Expand Down Expand Up @@ -423,7 +423,7 @@ private function apply_js($node) {
private function get_code_surroundings() {
$result = [
'pre' => '',
'post' => ''
'post' => '',
];

$condition = '';
Expand Down Expand Up @@ -816,7 +816,7 @@ private function load_library($libname) {
global $PAGE;

$libs = [
'formulas' => 'formulas_extension/JSXQuestion.js'
'formulas' => 'formulas_extension/JSXQuestion.js',
];

if (!array_key_exists($libname, $libs)) {
Expand Down Expand Up @@ -951,7 +951,7 @@ private function get_adminsettings() {
];

$trims = [
'globalJS'
'globalJS',
];

// Read and save settings.
Expand Down

0 comments on commit c4ff803

Please sign in to comment.