aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorThomas Hackl <hackl@data-quest.de>2022-12-07 07:17:21 +0000
committerThomas Hackl <hackl@data-quest.de>2022-12-07 07:17:21 +0000
commit3d8cb20aef2c55cadd38dccc3f51128d7e357ecf (patch)
treea144f9afa0c2b2bcb2622f61d89455fd84a85614 /db
parentd22c048e14a346feac17aa8983c0b89bf9010490 (diff)
Resolve "Erweiterung Courseware: Zertifikate, Erinnerungen und Rücksetzen des Fortschritts"
Closes #1660 Merge request studip/studip!1172
Diffstat (limited to 'db')
-rw-r--r--db/migrations/5.3.11_courseware_cron_events.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/db/migrations/5.3.11_courseware_cron_events.php b/db/migrations/5.3.11_courseware_cron_events.php
new file mode 100644
index 0000000..48dbfcf
--- /dev/null
+++ b/db/migrations/5.3.11_courseware_cron_events.php
@@ -0,0 +1,49 @@
+<?php
+
+require_once('lib/cronjobs/courseware.php');
+
+class CoursewareCronEvents extends Migration
+{
+ public function description()
+ {
+ return 'Prepares database tables for storing timestamps of courseware cron events, ' .
+ 'like certificate sending and reminders.';
+ }
+
+ public function up()
+ {
+ // Create a table for certificates
+ DBManager::get()->exec("CREATE TABLE IF NOT EXISTS `cw_certificates` (
+ `id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
+ `user_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
+ `course_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
+ `mkdate` INT(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ INDEX index_user_id (`user_id`),
+ INDEX index_course_id (`course_id`),
+ INDEX index_user_ourse (`user_id`, `course_id`)
+ )");
+
+ CoursewareCronjob::register()->schedulePeriodic(41, 1)->activate();
+ }
+
+ public function down()
+ {
+ CoursewareCronjob::unregister();
+
+ DBManager::get()->exec("DROP TABLE IF EXISTS `cw_certificates`");
+
+ $fields = [
+ 'COURSEWARE_CERTIFICATE_SETTINGS',
+ 'COURSEWARE_REMINDER_SETTINGS',
+ 'COURSEWARE_RESET_PROGRESS_SETTINGS',
+ 'COURSEWARE_LAST_REMINDER',
+ 'COURSEWARE_LAST_PROGRESS_RESET'
+ ];
+ DBManager::get()->execute("DELETE FROM `config` WHERE `field` IN (:fields)",
+ ['fields' => $fields]);
+ DBManager::get()->execute("DELETE FROM `config_values` WHERE `field` IN (:fields)",
+ ['fields' => $fields]);
+ }
+
+}