Skip to content

Commit

Permalink
Fixes PHP 8.2: Dynamic Properties are deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Carlos Rodríguez-del-Pino committed Jun 4, 2024
1 parent e7085b2 commit 717c660
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 23 deletions.
7 changes: 5 additions & 2 deletions classes/similarity/similarity_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ abstract class similarity_base {
protected $size;
protected $sizeh;
protected $vecfrec;
protected $hashses;
protected $hashes;
public $cluster;
public $fid;
public $id;

// Array to convert string operators to numbers.
static protected $valueconverter = [];
Expand Down Expand Up @@ -195,7 +198,7 @@ public function show_info($ext = false) {
$htmls = vpl_s($this->vecfrec);
$ret .= 'vecfrec=' . $htmls . '<br>';
$htmls = vpl_s($this->hashes);
$ret .= 'hashses=' . $htmls . '<br>';
$ret .= 'hashes=' . $htmls . '<br>';
}

return $ret;
Expand Down
4 changes: 2 additions & 2 deletions forms/overrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ public function validation($data, $files) {
if ($update !== null) {
// Update or create an override.
$override = $optionsform->get_data();
vpl_truncate_vpl($override); // Trim and cut password if too large.
unset($override->id); // The id field of the form is not the override id - do not use it.
if ($override !== null) {
vpl_truncate_vpl($override); // Trim and cut password if too large.
unset($override->id); // The id field of the form is not the override id - do not use it.
foreach ($fields as $field) {
if (!isset($override->{'override_' . $field})) {
$override->$field = null;
Expand Down
4 changes: 4 additions & 0 deletions similarity/similarity_base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class vpl_files_pair {
public $s1;
public $s2;
public $s3;
public $level;
public $level1;
public $level2;
public $level3;
public $id;
private $clusternumber;
public function __construct($first = null, $second = null, $s1 = 0, $s2 = 0, $s3 = 0) {
Expand Down
9 changes: 5 additions & 4 deletions similarity/tokenizer_html.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class vpl_tokenizer_html extends vpl_tokenizer_base {
const IN_TAGATTRNAME = 5;
const IN_TAGATTRVALUE = 6;
protected $tokens;
protected $linenumber;
protected function add_pending(&$rawpending, $state) {
$pending = strtolower( $rawpending );
$rawpending = '';
Expand All @@ -47,11 +48,11 @@ protected function add_pending(&$rawpending, $state) {
if ($state == self::IN_TAGEND) {
$pending .= '/';
}
$this->tokens[] = new vpl_token( vpl_token_type::OPERATOR, $pending, $this->line_number );
$this->tokens[] = new vpl_token( vpl_token_type::OPERATOR, $pending, $this->linenumber );
}
public function parse($filedata) {
$this->tokens = [];
$this->line_number = 1;
$this->linenumber = 1;
$state = self::REGULAR;
$pending = '';
$l = strlen( $filedata );
Expand All @@ -67,13 +68,13 @@ public function parse($filedata) {
$next = '';
}
if ($previous == self::LF) {
$this->line_number ++;
$this->linenumber ++;
}
if ($current == self::CR) {
if ($next == self::LF) {
continue;
} else {
$this->line_number ++;
$this->linenumber ++;
$current = self::LF;
}
}
Expand Down
12 changes: 7 additions & 5 deletions views/previoussubmissionslist.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,16 @@ function vpl_actions_menu($id, $userid, $subid) {
$table->align = [
'right',
'left',
'right',
'left',
'left',
];
$table->nowrap = [
true,
true,
true,
$table->wrap = [
'nowrap',
'nowrap',
'',
'nowrap',
];

$submissionslist = $vpl->user_submissions( $userid );
$submissions = [];
$nsub = count( $submissionslist );
Expand Down
22 changes: 12 additions & 10 deletions vpl.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ class mod_vpl {
*/
protected $errors = [];

/**
* An internal cache for grade information.
*
*/
protected $gradeinfo = null;

/**
* The graders of this activity and group cached
*
Expand Down Expand Up @@ -1175,12 +1181,8 @@ public function is_submit_able($userid = null) {
* @return bool
*/
public function is_group_activity() {
if (! isset( $this->group_activity )) {
$cm = $this->get_course_module();
$this->group_activity = $cm->groupingid > 0 && $this->get_instance()->worktype == 1;
// TODO check groups_get_activity_groupmode($cm)==SEPARATEGROUPS.
}
return $this->group_activity;
$cm = $this->get_course_module();
return $cm->groupingid > 0 && $this->get_instance()->worktype == 1;
}

/**
Expand Down Expand Up @@ -1395,19 +1397,19 @@ public function get_scale() {
*/
public function get_grade_info() {
global $CFG, $USER;
if (! isset( $this->grade_info )) {
$this->grade_info = false;
if (! isset( $this->gradeinfo )) {
$this->gradeinfo = false;
if ($this->get_instance()->grade != 0) { // If 0 then NO GRADE.
$userid = ($this->has_capability( VPL_GRADE_CAPABILITY ) || $this->has_capability(
VPL_MANAGE_CAPABILITY )) ? null : $USER->id;
require_once($CFG->libdir . '/gradelib.php');
$gradinginfo = grade_get_grades( $this->get_course()->id, 'mod', 'vpl', $this->get_instance()->id, $userid );
foreach ($gradinginfo->items as $gi) {
$this->grade_info = $gi;
$this->gradeinfo = $gi;
}
}
}
return $this->grade_info;
return $this->gradeinfo;
}

/**
Expand Down

0 comments on commit 717c660

Please sign in to comment.