Skip to content

Commit 35e537f

Browse files
MaijjayMaija Y
and
Maija Y
authored
Make course instance joinable with a special code (#1314)
* Regeneratable code for joining course * Course accesses table * Join page for joining the course via join code * Added joinable_by_code_only to courses * Changed join code to work with course instead of course instance * Test and new course to seed * Test fix * Test fix * Small change to a test --------- Co-authored-by: Maija Y <[email protected]>
1 parent 5861eb0 commit 35e537f

File tree

47 files changed

+1055
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1055
-84
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DROP TABLE join_code_uses;
2+
ALTER TABLE courses DROP COLUMN is_joinable_by_code_only;
3+
ALTER TABLE courses DROP COLUMN join_code;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CREATE TABLE join_code_uses (
2+
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
3+
course_id UUID NOT NULL REFERENCES courses(id),
4+
user_id UUID NOT NULL REFERENCES users(id),
5+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
6+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
7+
deleted_at TIMESTAMP WITH TIME ZONE
8+
);
9+
10+
11+
CREATE TRIGGER set_timestamp BEFORE
12+
UPDATE ON join_code_uses FOR EACH ROW EXECUTE PROCEDURE trigger_set_timestamp();
13+
COMMENT ON TABLE join_code_uses IS 'This table is used to check if user has access to a course that is only joinable by a join code. The join code is located in courses table';
14+
COMMENT ON COLUMN join_code_uses.id IS 'A unique, stable identifier for the record.';
15+
COMMENT ON COLUMN join_code_uses.course_id IS 'Course that the user has access to.';
16+
COMMENT ON COLUMN join_code_uses.user_id IS 'User who has the access to the course.';
17+
COMMENT ON COLUMN join_code_uses.created_at IS 'Timestamp of when the record was created';
18+
COMMENT ON COLUMN join_code_uses.updated_at IS 'Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.';
19+
COMMENT ON COLUMN join_code_uses.deleted_at IS 'Timestamp when the record was deleted. If null, the record is not deleted.';
20+
21+
ALTER TABLE courses
22+
ADD COLUMN join_code varchar(1024),
23+
ADD COLUMN is_joinable_by_code_only BOOLEAN NOT NULL DEFAULT FALSE;
24+
COMMENT ON COLUMN courses.join_code IS 'Regeneratable code that is used to join the course. If a user uses the code they will be added to join_code_uses -table to get access to the course';
25+
COMMENT ON COLUMN courses.is_joinable_by_code_only IS 'Whether this course is only joinable by a join code that can be generated for a course instance'
+16-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/headless-lms/models/.sqlx/query-31935ca7a5eb235ff25de151ade3680cd9381921f3017f3413c61875548dc92b.json

-18
This file was deleted.
+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+18-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+16-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/headless-lms/models/.sqlx/query-786d41394659b910e6833a0ae0876193fe5ec3089cbe4da15565174322edbf9f.json

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/headless-lms/models/.sqlx/query-8202eb97a2b1f388a51758e7fcf8d69b2e68544fae551e3da0a41bc6e9a2de9c.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)