From aab8d73b91de53593eff829cfa9e17b4e9a719d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20K=C3=B6hler?= <lukas.koehler@h-da.de>
Date: Tue, 2 Oct 2018 11:31:00 +0200
Subject: [PATCH] sql scripts

---
 config/opensubmit/clearAll.sql     |  3 +
 config/opensubmit/courses.sql      | 14 -----
 config/opensubmit/initDatabase.sql | 89 ++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 14 deletions(-)
 create mode 100644 config/opensubmit/clearAll.sql
 delete mode 100644 config/opensubmit/courses.sql
 create mode 100644 config/opensubmit/initDatabase.sql

diff --git a/config/opensubmit/clearAll.sql b/config/opensubmit/clearAll.sql
new file mode 100644
index 0000000..70da9f9
--- /dev/null
+++ b/config/opensubmit/clearAll.sql
@@ -0,0 +1,3 @@
+DELETE FROM opensubmit_assignment_test_machines;
+DELETE FROM opensubmit_assignment;
+DELETE FROM opensubmit_course;
\ No newline at end of file
diff --git a/config/opensubmit/courses.sql b/config/opensubmit/courses.sql
deleted file mode 100644
index 405e674..0000000
--- a/config/opensubmit/courses.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (1, 'Roth-Fr1y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (2, 'Roth-Fr1x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (3, 'Roth-Fr2x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (4, 'Roth-Fr2y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (5, 'Ruehl-Fr2x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (6, 'Ruehl-Fr2y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (7, 'Ruehl-Fr4x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (8, 'Ruehl-Fr4y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (9, 'Ruehl-Do5x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (10, 'Peter-Fr5x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (11, 'Peter-Fr5y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (12, 'Peter-Fr6x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-INSERT INTO public.opensubmit_course (id, title, created, homepage, active, owner_id, lti_key, lti_secret) VALUES (13, 'Peter-Fr6y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true, 1, null, null);
-
diff --git a/config/opensubmit/initDatabase.sql b/config/opensubmit/initDatabase.sql
new file mode 100644
index 0000000..8182a4c
--- /dev/null
+++ b/config/opensubmit/initDatabase.sql
@@ -0,0 +1,89 @@
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Roth-Fr1y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='m.roth'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Roth-Fr1x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='m.roth'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Roth-Fr2x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='m.roth'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Roth-Fr2y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='m.roth'), null, null);
+
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Ruehl-Fr2x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='s.ruehl'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Ruehl-Fr2y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='s.ruehl'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Ruehl-Fr4x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='s.ruehl'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Ruehl-Fr4y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='s.ruehl'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Ruehl-Do5x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='s.ruehl'), null, null);
+
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Peter-Fr5x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='l.koehler'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Peter-Fr5y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='l.koehler'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Peter-Fr6x', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='l.koehler'), null, null);
+
+INSERT INTO public.opensubmit_course (title, created, homepage, active, owner_id, lti_key, lti_secret)
+ VALUES ('Peter-Fr6y', now(), 'https://lernen.h-da.de/course/view.php?id=8252', true,
+ (select id from auth_user where username='l.koehler'), null, null);
+
+
+
+INSERT INTO public.opensubmit_assignment (title, download, created, publish_at, soft_deadline, hard_deadline,
+has_attachment, attachment_test_timeout, attachment_test_validity, validity_script_download, attachment_test_full,
+course_id, "gradingScheme_id", description, max_authors)
+SELECT
+'Praktikum 3', 'https://lernen.h-da.de/pluginfile.php/344926/mod_resource/content/1/Praktikum3.pdf',
+'2018-10-02 07:00:29.652859', '2018-10-01 07:00:29.652859', null,
+'2019-07-01 09:00:00.000000', true, 30, 'testscripts/validate.py', false, '', c.id, null, '', 1
+FROM (SELECT id FROM opensubmit_course) c;
+
+INSERT INTO public.opensubmit_assignment (title, download, created, publish_at, soft_deadline, hard_deadline,
+has_attachment, attachment_test_timeout, attachment_test_validity, validity_script_download, attachment_test_full,
+course_id, "gradingScheme_id", description, max_authors)
+SELECT
+'Praktikum 4', 'https://lernen.h-da.de/pluginfile.php/344927/mod_resource/content/1/Praktikum4.pdf',
+'2018-10-02 07:00:29.652859', '2018-10-01 07:00:29.652859', null,
+'2019-07-01 09:00:00.000000', true, 30, 'testscripts/validate.py', false, '', c.id, null, '', 1
+FROM (SELECT id FROM opensubmit_course) c;
+
+INSERT INTO public.opensubmit_assignment (title, download, created, publish_at, soft_deadline, hard_deadline,
+has_attachment, attachment_test_timeout, attachment_test_validity, validity_script_download, attachment_test_full,
+course_id, "gradingScheme_id", description, max_authors)
+SELECT
+'Praktikum 5', 'https://lernen.h-da.de/pluginfile.php/344935/mod_resource/content/1/Praktikum5.pdf',
+'2018-10-02 07:00:29.652859', '2018-10-01 07:00:29.652859', null,
+'2019-07-01 09:00:00.000000', true, 30, 'testscripts/validate.py', false, '', c.id, null, '', 1
+FROM (SELECT id FROM opensubmit_course) c;
+
+
+
+INSERT INTO opensubmit_assignment_test_machines (assignment_id, testmachine_id)
+SELECT a.id, t.id
+FROM  (SELECT id from opensubmit_assignment) a,
+     (SELECT id from opensubmit_testmachine) t;
\ No newline at end of file
-- 
GitLab