Skip to content

Commit

Permalink
fix: delete unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
eynimeni committed Jan 10, 2024
1 parent 246999b commit fa58ce5
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions classes/catcontext.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,56 +463,6 @@ public function getname():string {
return $this->name;
}

/**
* Compare the context to contexts in db. Returns similar context if found, else false.
*
* @return stdClass|boolean
*/
public function compare_to_existing_contexts() {

global $DB;

$record = (object)[
'name' => $this->name,
'description' => $this->description,
'descriptionformat' => $this->descriptionformat,
'starttimestamp' => $this->starttimestamp,
'endtimestamp' => $this->endtimestamp,
'json' => $this->json,
'usermodified' => $this->usermodified,
'timecreated' => $this->timecreated,
'timemodified' => $this->timemodified,
'timecalculated' => $this->timecalculated,
];

// Only if the id is not empty, we add the id key.
if (!empty($this->id)) {
$record->id = $this->id;
}

$explodedname = explode("_", $this->name);

$dbrecords = $DB->get_records_sql(
"SELECT * FROM {local_catquiz_catcontext}"
);

// Check if $record->name contains
// If context was created less than 2 minutes ago, and it's for the same scale, we return it.
$time = intval(time());
foreach ($dbrecords as $dbrecord) {
// TODO change again to 120!
if ($time - intval($dbrecord->timecreated) < 1200
&& str_contains($dbrecord->name, $explodedname[1])
&& str_contains($dbrecord->name, $explodedname[2])
) {
$this->id = $dbrecord->id;
return $dbrecord;
}
}
// If no record was found, return false.
return false;
}

/**
* Returns the time when the items of this context have last been updated.
* @return int
Expand Down

0 comments on commit fa58ce5

Please sign in to comment.