-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make course instance joinable with a special code #1314
Conversation
@@ -852,6 +859,25 @@ WHERE ce.course_instance_id = $1 | |||
Ok(res.map(|r| r.student_duration_seconds).unwrap_or_default()) | |||
} | |||
|
|||
pub async fn generate_join_code_for_course_instance( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better function name would be set_join_code_for_course_instance
Res::CourseInstance(*id), | ||
) | ||
.await?; | ||
let code = Uuid::new_v4().to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a random string would be better. Also, we have to keep in mind that these strings should be long enough that no one can guess them, and we have to keep them easy to type.
You could for example generate a random string that excludes look-alike characters. (https://rust-lang-nursery.github.io/rust-cookbook/algorithms/randomness.html#create-random-passwords-from-a-set-of-user-defined-characters)
@@ -0,0 +1,13 @@ | |||
CREATE TABLE course_accesses ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
join_code_uses
user_id UUID NOT NULL REFERENCES users(id), | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
deleted_at TIMESTAMP WITH TIME ZONE | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the updated_at column and then the trigger to update it automatically.
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
deleted_at TIMESTAMP WITH TIME ZONE | ||
); | ||
COMMENT ON TABLE course_accesses IS 'This table is used to check if user has access to a course that is only joinable by a special code'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this comment explain how this table is related to the course_instances.join_code.
@@ -0,0 +1,3 @@ | |||
ALTER TABLE course_instances | |||
ADD COLUMN join_code varchar(1024); | |||
COMMENT ON COLUMN course_instances.join_code IS 'Regeneratable code that is used to join the course'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain the join_code_uses table.
|
||
// Check that student can't see to the course | ||
await student1Page.goto("http://project-331.local/org/uh-mathstat/courses/joinable-by-code-only") | ||
await student1Page.getByText("Unauthorized", { exact: true }).click() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitFor
No description provided.