Skip to content

Commit

Permalink
Fix coding style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PM84 committed Oct 16, 2023
1 parent 596c7dd commit 0dec3f9
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 212 deletions.
1 change: 0 additions & 1 deletion classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/

namespace mod_mootimeter\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_mootimeter course module viewed event class.
Expand Down
4 changes: 0 additions & 4 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

use coding_exception;
use dml_exception;
use stdClass;

defined('MOODLE_INTERNAL') || die();

/**
* The mod_mootimeter helper class.
Expand Down Expand Up @@ -221,7 +218,6 @@ public function get_rendered_page_content(object $page, object $cm, bool $withwr
'cmid' => $cm->id,
'title' => s($page->title),
'question' => s(self::get_tool_config($page, 'question')),
// 'isNewPage' => s($page->isNewPage),
'isediting' => $PAGE->user_is_editing(),
];
$params = array_merge($params, $toolhelper->get_renderer_params($page));
Expand Down
6 changes: 0 additions & 6 deletions classes/helper_add_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@

namespace mod_mootimeter;

use coding_exception;
use dml_exception;
use stdClass;

defined('MOODLE_INTERNAL') || die();

/**
* The mod_mootimeter helper class to add new page.
*
Expand Down
3 changes: 1 addition & 2 deletions classes/plugininfo/mootimetertool.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/

namespace mod_mootimeter\plugininfo;
defined('MOODLE_INTERNAL') || die();

use coding_exception;
use cache_exception;
Expand Down Expand Up @@ -140,7 +139,7 @@ public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $
return;
}

if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
if (!$hassiteconfig || !file_exists($this->full_path('settings.php'))) {
return;
}

Expand Down
91 changes: 0 additions & 91 deletions classes/toolhelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@

namespace mod_mootimeter;

defined('MOODLE_INTERNAL') || die();

use coding_exception;
use cache_exception;
use core\plugininfo\base, core_plugin_manager, moodle_url;
use dml_exception;
use stdClass;

/**
* The toolhelper methods must be implemented of each tool.
Expand Down Expand Up @@ -77,100 +73,13 @@ abstract public function get_renderer_params(object $page);
*/
abstract public function get_col_settings_tool(object $page);

/**
* Get the settings definitions.
*
* @param object $page
* @return array
* @deprecated since 28.09.2023
*/
// abstract public function get_tool_setting_definitions(object $page);

/**
* Will be executed after the page is created.
* @param object $page
* @return void
*/
abstract public function hook_after_new_page_created(object $page);

/**
* Get renderes setting output.
*
* @param mixed $page
* @return string
* @deprecated since 28.09.2023
*/
// public function get_tool_settings($page): string {
// global $OUTPUT;

// $settings = $this->get_tool_setting_definitions($page);
// return $OUTPUT->render_from_template("mod_mootimeter/settings", $settings);
// }

/**
* Get all tool settings parameters.
*
* @param object $page
* @return array
* @throws coding_exception
* @deprecated since 28.09.2023
*/
// public function get_tool_settings_parameters(object $page): array {

// $settings = $this->get_tool_setting_definitions($page);

// $parameters = [];

// if (empty($settings['settingsarray'])) {
// return $parameters;
// }

// foreach ($settings['settingsarray'] as $setting) {

// foreach ($setting as $key => $value) {
// switch ($key) {
// case 'text':
// $parameters[$setting['name']] = [
// 'tool' => $page->tool,
// 'type' => $key,
// 'pageid' => $page->id,
// 'name' => $setting['name'],
// 'value' => optional_param($setting['name'], "", PARAM_TEXT),
// ];
// break;
// case 'number':
// $parameters[$setting['name']] = [
// 'tool' => $page->tool,
// 'type' => $key,
// 'pageid' => $page->id,
// 'name' => $setting['name'],
// 'value' => optional_param($setting['name'], "", PARAM_INT),
// ];
// break;
// case 'select':
// $parameters[$setting['name']] = [
// 'tool' => $page->tool,
// 'type' => $key,
// 'pageid' => $page->id,
// 'name' => $setting['name'],
// 'value' => optional_param($setting['name'], "", PARAM_TEXT),
// ];
// break;
// case 'checkbox':
// $parameters[$setting['name']] = [
// 'tool' => $page->tool,
// 'type' => $key,
// 'pageid' => $page->id,
// 'name' => $setting['name'],
// 'value' => optional_param($setting['name'], "", PARAM_INT),
// ];
// break;
// }
// }
// }
// return $parameters;
// }

/**
* Checks if a select option is selected.
*
Expand Down
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function xmldb_mootimeter_upgrade($oldversion) {
$dbman->drop_field($table, $field);
}

// Create new field question
// Create new field question.
$field = new xmldb_field('question', XMLDB_TYPE_TEXT, null, null, null, null, null, 'title');

// Conditionally launch add field question.
Expand Down
9 changes: 0 additions & 9 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,6 @@ function mootimeter_extend_navigation($mootimeternode, $course, $module, $cm) {
* @param navigation_node $mootimeternode {@see navigation_node}
*/
function mootimeter_extend_settings_navigation($settingsnav, $mootimeternode = null) {

// Keeping this for documentation purposes.

// if (has_capability('mod/mootimeter:moderator', $settingsnav->get_page()->cm->context)) {
// $url = new moodle_url('/mod/mootimeter/teacherview.php', ['id' => $settingsnav->get_page()->cm->id]);
// $linktext =
// get_string("teacherview", "mod_mootimeter");
// $mootimeternode->add($linktext, $url);
// }
}

/**
Expand Down
8 changes: 0 additions & 8 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ public function definition() {
// Adding the standard "intro" and "introformat" fields.
$this->standard_intro_elements();

// Adding the rest of mod_mootimeter settings, spreading all them into this fieldset
// ... or adding more fieldsets ('header' elements) if needed for better logic.
// $mform->addElement('static', 'label1', 'mootimetersettings', get_string('mootimetersettings', 'mod_mootimeter'));
// $mform->addElement('header', 'mootimeterfieldset', get_string('mootimeterfieldset', 'mod_mootimeter'));

// Add standard grading elements.
// $this->standard_grading_coursemodule_elements();

// Add standard elements.
$this->standard_coursemodule_elements();

Expand Down
8 changes: 0 additions & 8 deletions tools/quiz/classes/external/get_answers.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ public static function execute(int $pageid): array {
public static function execute_returns() {
return new external_single_structure(
[
// 'values' => new external_multiple_structure(
// new external_value(PARAM_INT, 'Answer options count'),
// "Answervalues"
// ),
// 'labels'=>new external_multiple_structure(
// new external_value(PARAM_TEXT, 'Answer options text'),
// "Answerlabels"
// ),
'values' => new external_value(PARAM_TEXT, 'Answer options count'),
'labels' => new external_value(PARAM_TEXT, 'Answer options text'),
'chartsettings' => new external_value(PARAM_TEXT, 'chartsettings'),
Expand Down
11 changes: 1 addition & 10 deletions tools/quiz/classes/external/store_answeroption.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,10 @@ public static function execute(int $pageid, int $aoid, string $value, string $id
}

/**
* Describes the return structure of the service..
* Describes the return structure of the service.
*
* @return external_multiple_structure
*/
public static function execute_returns() {
// return new external_multiple_structure(
// new external_single_structure(
// [
// 'cmid' => new external_value(PARAM_INT, 'ID'),
// 'numerrors' => new external_value(PARAM_INT, 'Number of errors.'),
// 'numchecks' => new external_value(PARAM_INT, 'Number of checks.'),
// ]
// )
// );
}
}
52 changes: 11 additions & 41 deletions tools/quiz/classes/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ public function get_content_menu_tool(object $page) {
'data-iconenabled = "fa-check-square-o"',
'data-icondisabled = "fa-square-o"',
'data-tooltipenabled = "' . get_string('tooltip_content_menu_answercorrection', 'mootimetertool_quiz') . '"',
'data-tooltipdisabled = "' . get_string('tooltip_content_menu_answercorrection_disabled', 'mootimetertool_quiz') . '"',
'data-tooltipdisabled = "' .
get_string('tooltip_content_menu_answercorrection_disabled', 'mootimetertool_quiz') . '"',
];
$params['icon-check'] = [
'id' => 'toggleshowanswercorrectionid',
Expand All @@ -251,7 +252,10 @@ public function get_content_menu_tool(object $page) {
];
if (!empty(self::get_tool_config($page->id, 'showanswercorrection'))) {
$params['icon-check']['icon'] = "fa-check-square-o";
$params['icon-check']['tooltip'] = get_string('tooltip_content_menu_answercorrection_disabled', 'mootimetertool_quiz');
$params['icon-check']['tooltip'] = get_string(
'tooltip_content_menu_answercorrection_disabled',
'mootimetertool_quiz'
);
} else if (empty(self::get_tool_config($page->id, 'showanswercorrection'))) {
$params['icon-check']['icon'] = "fa-square-o";
$params['icon-check']['tooltip'] = get_string('tooltip_content_menu_answercorrection', 'mootimetertool_quiz');
Expand All @@ -276,18 +280,6 @@ public function get_content_menu_tool(object $page) {
];
}

// if (
// has_capability('mod/mootimeter:moderator', \context_module::instance($PAGE->cm->id))
// && self::get_tool_config($page->id, 'showresult') == self::MTMT_VIEW_RESULT_TEACHERPERMISSION
// ) {

// if (empty(self::get_tool_config($page->id, 'showonteacherpermission'))) {
// $params['icon-eye']['additional_class'] = " disabled";
// } else if (!empty(self::get_tool_config($page->id, 'showonteacherpermission'))) {
// $params['icon-eye']['additional_class'] .= "";
// }
// }

return $OUTPUT->render_from_template("mod_mootimeter/elements/snippet_content_menu", $params);
}

Expand Down Expand Up @@ -318,30 +310,6 @@ public function remove_answer_option(int $pageid, int $aoid): array {
return $return;
}

/**
* Get quiztype.
*
* @param int $pageid
* @return string
* @deprecated
*/
public function get_quiztype(int $pageid): string {
if (!empty(self::get_tool_config($pageid, 'ispoll'))) {
switch (self::get_tool_config($pageid, 'ispoll')) {
case self::MTMT_IS_QUIZ:
$ispoll = "isquiz";
break;
default:
$ispoll = "ispoll";
break;
}
} else {
$ispoll = "ispoll";
}

return $ispoll;
}

/**
* Get all parameters that are necessary for rendering the tools view.
*
Expand All @@ -350,7 +318,7 @@ public function get_quiztype(int $pageid): string {
* @deprecated
*/
public function get_renderer_params(object $page) {
global $USER, $PAGE;
global $USER;

// Parameter for initial wordcloud rendering.
$params['pageid'] = $page->id;
Expand Down Expand Up @@ -384,9 +352,11 @@ public function get_renderer_params(object $page) {
'pageid' => $page->id,
$inputtype . '_with_label_name' => 'multipleanswers[]',
$inputtype . '_with_label_value' => $answeroption->id,
$inputtype . '_with_label_additional_class' => 'mootimeter_settings_selector mootimeter-highlighter mootimeter-success',
$inputtype . '_with_label_additional_class' => 'mootimeter_settings_selector ' .
'mootimeter-highlighter mootimeter-success',
$inputtype . '_with_label_checked' => (in_array($answeroption->id, $useransweroptionsid)) ? "checked" : "",
$inputtype . '_with_label_additional_attribut' => (self::get_tool_config($page->id, 'showanswercorrection')) ? "disabled" : "",
$inputtype . '_with_label_additional_attribut' => (self::get_tool_config($page->id, 'showanswercorrection')) ?
"disabled" : "",
];
}

Expand Down
15 changes: 12 additions & 3 deletions tools/wordcloud/classes/external/store_answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public static function execute(int $pageid, string $answer): array {
]);

if (empty($answer) && strlen($answer) == 0) {
return ['code' => helper::ERRORCODE_EMPTY_ANSWER, 'string' => get_string('error_empty_answers', 'mootimetertool_wordcloud')];
return ['code' => helper::ERRORCODE_EMPTY_ANSWER, 'string' => get_string(
'error_empty_answers',
'mootimetertool_wordcloud'
), ];
}

$helper = new helper();
Expand All @@ -84,12 +87,18 @@ public static function execute(int $pageid, string $answer): array {
$submittedanswers = $wordcloud->get_user_answers('mtmt_wordcloud_answers', $page->id, 'answer', $USER->id);

if (count($submittedanswers) >= $maxnumberofanswers && $maxnumberofanswers != 0) {
return ['code' => helper::ERRORCODE_TO_MANY_ANSWERS, 'string' => get_string('error_to_many_answers', 'mootimetertool_wordcloud')];
return ['code' => helper::ERRORCODE_TO_MANY_ANSWERS, 'string' => get_string(
'error_to_many_answers',
'mootimetertool_wordcloud'
), ];
}

$submittedanswers = $wordcloud->get_answer_list_array($page->id, $USER->id);
if (!helper::get_tool_config($page->id, "allowduplicateanswers") && in_array($answer, $submittedanswers)) {
return ['code' => helper::ERRORCODE_DUPLICATE_ANSWER, 'string' => get_string('error_no_duplicate_answers', 'mootimetertool_wordcloud')];
return ['code' => helper::ERRORCODE_DUPLICATE_ANSWER, 'string' => get_string(
'error_no_duplicate_answers',
'mootimetertool_wordcloud'
), ];
}

$wordcloud->insert_answer($page, $answer);
Expand Down
Loading

0 comments on commit 0dec3f9

Please sign in to comment.