Skip to content

Commit

Permalink
Correct parameter types
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottVerbeek committed Jan 15, 2024
1 parent d415cce commit d6f6ef5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
12 changes: 9 additions & 3 deletions stack/cas/cassession2.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ public function get_by_key(string $key) {
*/
public function get_errors($implode = true, $withcontext = true) {
$errors = array();
if (is_null($this->timeouterrmessage)) {
$this->timeouterrmessage = '';
}
$this->timeouterrmessage = trim($this->timeouterrmessage);

foreach ($this->statements as $num => $statement) {
Expand Down Expand Up @@ -565,9 +568,12 @@ public function get_keyval_representation($evaluatedvalues = false): string {
}

public function get_debuginfo() {
if (trim($this->timeouterrmessage) !== '') {
return $this->timeouterrmessage;
$info = $this->timeouterrmessage;

if (!$info || trim($info) == '') {
return '';
}
return '';

return $info;
}
}
2 changes: 1 addition & 1 deletion stack/cas/parsingrules/801_singleton_numeric.filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function filter(MP_Node $ast, array &$errors, array &$answernotes, stack_
// then we should have the $m and $p and even $sgn if needed.
// If conversion toward floats is needed we can do that
// and we can check the bad form 1e23*10^45.
if (stripos($m, 'e') !== false || !$this->power) {
if ($m && (stripos($m, 'e') !== false || !$this->power)) {
// Could have a separate error.
$node->position['invalid'] = true;
$answernotes[] = 'Illegal_power';
Expand Down
2 changes: 1 addition & 1 deletion stack/input/dropdown/dropdown.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class stack_dropdown_input extends stack_input {

protected function internal_contruct() {
$options = $this->get_parameter('options');
if (trim($options) != '') {
if ($options && trim($options) != '') {
$options = explode(',', $options);
foreach ($options as $option) {
$option = strtolower(trim($option));
Expand Down
4 changes: 2 additions & 2 deletions stack/input/inputbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function __construct($name, $teacheranswer, $options = null, $parameters
*/
protected function internal_contruct() {
$options = $this->get_parameter('options');
if (trim($options) != '') {
if ($options && trim($options) != '') {
$options = explode(',', $options);
foreach ($options as $option) {
$option = strtolower(trim($option));
Expand Down Expand Up @@ -695,7 +695,7 @@ public function validate_student_response($response, $options, $teacheranswer, s
$ta = '0';
$trivialta = true;
if (array_key_exists($index, $tvalidator)) {
if (!('' == trim($tvalidator[$index]))) {
if ($tvalidator[$index] && '' != trim($tvalidator[$index])) {
$ta = $tvalidator[$index];
$trivialta = false;
}
Expand Down
4 changes: 4 additions & 0 deletions stack/mathsoutput/mathsoutputbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ function ($match) {
* @return string the content ready to pass to format_text.
*/
public function process_display_castext($text, $replacedollars, qtype_stack_renderer $renderer = null) {
if (!$text) {
return '';
}

if ($replacedollars) {
$text = $this->replace_dollars($text);
}
Expand Down

0 comments on commit d6f6ef5

Please sign in to comment.