Skip to content

Commit

Permalink
chore: fix code style violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pol Torrent i Soler committed Dec 16, 2024
1 parent 0d90600 commit 13836f0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
10 changes: 5 additions & 5 deletions edit_wq_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,24 @@ protected function definition_inner($mform) {
$mform->addElement('hidden', 'wirislang', current_language(), array('class' => 'wirislang'));
$mform->setType('wirislang', PARAM_TEXT);

// TODO: Delete this if when all questions are wq!
if (isset($this->question->wirisquestion)) {
$program = $this->question->wirisquestion->serialize();
} else {
// If the wirisquestion is not already loaded in memory, load it from the DB directly.
if (empty($this->question->id)) {
// New question.
$program = '<question/>';
} else {
// Existing question.
$wiris = $DB->get_record('qtype_wq', array('question' => $this->question->id));
if (empty($wiris)) {
// Corrupted question
$corruptwarning = $mform->createElement('html', '<div class="wiriscorruptquestionedit">' . get_string('corruptquestion_edit', 'qtype_wq') .'</div');
// Corrupted question.
$corruptwarning =
$mform->createElement('html', '<div class="wiriscorruptquestionedit">' . get_string('corruptquestion_edit', 'qtype_wq') . '</div');
$mform->insertElementBefore($corruptwarning, 'generalheader');
$program = '<question/>';
} else {
// Happy path
// Question found in the DB.
$program = $wiris->xml;
}
}
Expand All @@ -90,7 +91,6 @@ protected function definition_inner($mform) {
$defaultvalues = array();
$defaultvalues['wirisquestion'] = $program;
$mform->setDefaults($defaultvalues);

}
public function set_data($question) {
$this->base->set_data($question);
Expand Down
4 changes: 2 additions & 2 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class qtype_wq_question extends question_graded_automatically {

/**
* @var bool
* Whether this question is corrupt and its wirisquestion was removed from the database.
* Whether this question is corrupt and its wirisquestion was removed from the database.
*/
public $corrupt = false;

Expand Down Expand Up @@ -371,7 +371,7 @@ public function call_wiris_service($request) {
$service = $builder->getQuizzesService();

$isdebugmodeenabled = get_config('qtype_wq', 'debug_mode_enabled') == '1';
$islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1';
$islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1';

if ($isdebugmodeenabled) {
// @codingStandardsIgnoreLine
Expand Down
2 changes: 1 addition & 1 deletion questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ protected function make_question_instance($questiondata) {
protected function initialise_question_instance(question_definition $question, $questiondata) {
global $CFG;

/** @var qtype_wq_question $question */
$this->base->initialise_question_instance($question->base, $questiondata);

/** @var qtype_wq_question $question */
$question->id = &$question->base->id;
$question->idnumber = &$question->base->idnumber;
$question->category = &$question->base->category;
Expand Down
20 changes: 10 additions & 10 deletions step.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ public function is_attempt_limit_reached() {

$isreached = $c >= self::MAX_ATTEMPS_SHORTANSWER_WIRIS;

$islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1';
$islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1';
if ($islogmodeenabled) {
$errormessage = 'WIRISQUIZZES ATTEMPT LIMIT REACHED FOR STEP WITH ID ' .
($this->step != null ? $this->step->get_id() : $this->stepid);
$errormessage = 'WIRISQUIZZES ATTEMPT LIMIT REACHED FOR STEP WITH ID ' .
($this->step != null ? $this->step->get_id() : $this->stepid);
// @codingStandardsIgnoreLine
error_log($errormessage);
error_log($errormessage);
}

return $isreached;
}

Expand All @@ -267,13 +267,13 @@ public function inc_attempts(moodle_exception $e) {
$c = 0;
}

$islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1';
$islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1';
if ($islogmodeenabled) {
$errormessage = 'WIRISQUIZZES ATTEMPT ERROR --- INCREASING ATTEMPT COUNT TO ' . ($c + 1) . ' FOR STEP WITH ID ' .
($this->step != null ? $this->step->get_id() : $this->stepid) . PHP_EOL .
'EXCEPTION: ' . $e->getMessage();
$errormessage = 'WIRISQUIZZES ATTEMPT ERROR --- INCREASING ATTEMPT COUNT TO ' . ($c + 1) . ' FOR STEP WITH ID ' .
($this->step != null ? $this->step->get_id() : $this->stepid) . PHP_EOL .
'EXCEPTION: ' . $e->getMessage();
// @codingStandardsIgnoreLine
error_log($errormessage);
error_log($errormessage);
}

$this->set_var('_gc', $c + 1, false);
Expand Down
8 changes: 7 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
body.wrs_plugin.wrs_filter {
font-family: Arial;
}

span.wrs_plugin.wrs_filter {
font-weight: bold;
}

span.ok.wrs_plugin.wrs_filter {
color: #090;
}

span.error.wrs_plugin.wrs_filter {
color: #d00;
}

table.wrs_plugin.wrs_filter,
th.wrs_plugin.wrs_filter,
td.wrs_plugin.wrs_filter,
Expand All @@ -18,9 +22,11 @@ tr.wrs_plugin.wrs_filter {
border-collapse: collapse;
padding: 5px;
}

th.wrs_plugin.wrs_filter {
background-color: #eee;
}

img.wrs_plugin.wrs_filter {
border: none;
}
}

0 comments on commit 13836f0

Please sign in to comment.