Skip to content

Commit c67054e

Browse files
committed
Fix incorrect table names
1 parent 4b1fc89 commit c67054e

7 files changed

Lines changed: 75 additions & 16 deletions

File tree

classes/privacy/provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class provider implements
4141
*/
4242
public static function get_metadata($collection): \core_privacy\local\metadata\collection {
4343
$collection->add_database_table(
44-
'tool_pdfdetect_assigns',
44+
'tool_corruptpdfdetector_assigns',
4545
[
4646
'email' => 'privacy:metadata:tool_corruppdfdetector:email',
4747
'userfullname' => 'privacy:metadata:tool_corruppdfdetector:userfullname',

classes/table/assignments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function __construct() {
8888
private function get_detected_assignments() {
8989
global $DB;
9090

91-
$records = $DB->get_records('tool_pdfdetect_assigns', [], 'detected ASC');
91+
$records = $DB->get_records('tool_corruptpdfdetector_assigns', [], 'detected ASC');
9292

9393
return $records;
9494
}
@@ -106,7 +106,7 @@ public function get_percentage() {
106106

107107
$submissioncount = $DB->count_records('assign_submission');
108108
$filecount = $DB->count_records_select(
109-
'tool_pdfdetect_assigns',
109+
'tool_corruptpdfdetector_assigns',
110110
'fixed = ?',
111111
[false],
112112
'COUNT(DISTINCT submissionid)'

classes/task/fix_assignments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function execute() {
4141
global $DB;
4242

4343
// Fetch all broken assignment submissions.
44-
$records = $DB->get_recordset('tool_pdfdetect_assigns', ['fixed' => false]);
44+
$records = $DB->get_recordset('tool_corruptpdfdetector_assigns', ['fixed' => false]);
4545

4646
foreach ($records as $submission) {
4747
$contenthash = $submission->filename;
@@ -53,7 +53,7 @@ public function execute() {
5353
$params
5454
);
5555
$submission->fixed = true;
56-
$DB->update_record('tool_pdfdetect_assigns', $submission);
56+
$DB->update_record('tool_corruptpdfdetector_assigns', $submission);
5757
}
5858
$records->close();
5959
}

classes/task/scan_assignments.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function execute() {
5454

5555
// Get the last submission id that had been checked in last run.
5656
$lastrun = $DB->get_records_sql('SELECT lastsubmissionid
57-
FROM {tool_pdfdetect_runs}
57+
FROM {tool_corruptpdfdetector_runs}
5858
ORDER BY runtime
5959
DESC LIMIT :one', ['one' => ONE]);
6060

@@ -78,7 +78,7 @@ public function execute() {
7878
$detectedsubmission = $this->detected_submission($submission);
7979
if ($detectedsubmission != null) {
8080
$pdfwitherror = $this->check_submission_combined_pdf($submission);
81-
$detected = $DB->get_record('tool_pdfdetect_assigns', ['submissionid' => $submission->id]);
81+
$detected = $DB->get_record('tool_corruptpdfdetector_assigns', ['submissionid' => $submission->id]);
8282
$detected->submitted = $submission->timemodified;
8383
if ($pdfwitherror != null) {
8484
$detected->detected = $pdfwitherror->detected;
@@ -89,12 +89,12 @@ public function execute() {
8989
} else {
9090
$detected->fixed = true;
9191
}
92-
$DB->update_record('tool_pdfdetect_assigns', $detected);
92+
$DB->update_record('tool_corruptpdfdetector_assigns', $detected);
9393
} else {
9494
$pdfwitherror = $this->check_submission_combined_pdf($submission);
9595
if ($pdfwitherror != null) {
9696
$detectednum++;
97-
$DB->insert_record('tool_pdfdetect_assigns', $pdfwitherror);
97+
$DB->insert_record('tool_corruptpdfdetector_assigns', $pdfwitherror);
9898
}
9999
}
100100
}
@@ -104,7 +104,7 @@ public function execute() {
104104
}
105105
$run->runtime = time();
106106
$run->detectednumber = $detectednum;
107-
$DB->insert_record('tool_pdfdetect_runs', $run);
107+
$DB->insert_record('tool_corruptpdfdetector_runs', $run);
108108
}
109109

110110
/**
@@ -136,7 +136,7 @@ private function get_pdf_file_for_assignment(assign $assignment, stdClass $submi
136136
}
137137

138138
/**
139-
* Detects a previously recorded submission in the 'tool_pdfdetect_assigns' table.
139+
* Detects a previously recorded submission in the 'tool_corruptpdfdetector_assigns' table.
140140
*
141141
* @param stdClass $submission The submission object containing the ID to look up in the database.
142142
*
@@ -147,7 +147,7 @@ private function detected_submission(stdClass $submission): ?stdClass {
147147

148148
$params = ['submissionid' => $submission->id];
149149
$select = $DB->sql_compare_text('submissionid') . ' = ' . $DB->sql_compare_text(':submissionid');
150-
$detectedsubmission = $DB->get_record_select('tool_pdfdetect_assigns', $select, $params);
150+
$detectedsubmission = $DB->get_record_select('tool_corruptpdfdetector_assigns', $select, $params);
151151

152152
if (!empty($detectedsubmission)) {
153153
return $detectedsubmission;

db/install.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
55
>
66
<TABLES>
7-
<TABLE NAME="tool_pdfdetect_assigns" COMMENT="Table to store affected assignments">
7+
<TABLE NAME="tool_corruptpdfdetector_assigns" COMMENT="Table to store affected assignments">
88
<FIELDS>
99
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
1010
<FIELD NAME="assignid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
@@ -27,7 +27,7 @@
2727
<INDEX NAME="submissionid" UNIQUE="true" FIELDS="submissionid"/>
2828
</INDEXES>
2929
</TABLE>
30-
<TABLE NAME="tool_pdfdetect_runs" COMMENT="Table to store completed runs">
30+
<TABLE NAME="tool_corruptpdfdetector_runs" COMMENT="Table to store completed runs">
3131
<FIELDS>
3232
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
3333
<FIELD NAME="lastsubmissionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>

db/upgrade.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Upgrade logic.
19+
*
20+
* @package tool_corruptpdfdetector
21+
* @copyright Catalyst IT
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
25+
/**
26+
* Performs data migrations and updates on upgrade.
27+
*
28+
* @param integer $oldversion
29+
* @return boolean
30+
*/
31+
function xmldb_tool_corruptpdfdetector_upgrade($oldversion = 0) {
32+
global $CFG, $DB;
33+
34+
require_once($CFG->libdir . '/db/upgradelib.php'); // Core Upgrade-related functions.
35+
36+
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
37+
38+
if ($oldversion < 2026042301) {
39+
// Rename table tool_pdfdetect_assigns to tool_corruptpdfdetector_assigns.
40+
$table = new xmldb_table('tool_pdfdetect_assigns');
41+
42+
if ($dbman->table_exists($table)) {
43+
$dbman->rename_table($table, 'tool_corruptpdfdetector_assigns');
44+
}
45+
46+
// Rename table tool_pdfdetect_runs to tool_corruptpdfdetector_runs.
47+
$table = new xmldb_table('tool_pdfdetect_runs');
48+
49+
if ($dbman->table_exists($table)) {
50+
$dbman->rename_table($table, 'tool_corruptpdfdetector_runs');
51+
}
52+
53+
// Corruptpdfdetector savepoint reached.
54+
upgrade_plugin_savepoint(true, 2026042301, 'tool', 'corruptpdfdetector');
55+
}
56+
57+
return true;
58+
}
59+

version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
defined('MOODLE_INTERNAL') || die();
2727

2828
$plugin->component = 'tool_corruptpdfdetector';
29-
$plugin->release = 2026042300;
30-
$plugin->version = 2026042300;
29+
$plugin->release = 2026042301;
30+
$plugin->version = 2026042301;
3131
$plugin->requires = 2024100700;
3232
$plugin->supported = [405, 405];
3333
$plugin->maturity = MATURITY_ALPHA;

0 commit comments

Comments
 (0)