Skip to content
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

Merged
merged 9 commits into from
Oct 17, 2024

Conversation

Maijjay
Copy link
Contributor

@Maijjay Maijjay commented Sep 16, 2024

No description provided.

@@ -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(
Copy link
Member

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();
Copy link
Member

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 (
Copy link
Member

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
);
Copy link
Member

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';
Copy link
Member

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';
Copy link
Member

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.

@github-actions github-actions bot added the seed label Sep 23, 2024

// 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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitFor

@nygrenh nygrenh merged commit 35e537f into master Oct 17, 2024
17 checks passed
@nygrenh nygrenh deleted the generate-code-for-joining-course branch October 17, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants