Student self enrolment active model update - #2
Conversation
ibi420
left a comment
There was a problem hiding this comment.
Hello Nouri-devv, I’ve tested this and can confirm it has been well implemented. All tests pass successfully, and the implementation is solid. Great work on this, and thank you for the opportunity to review your contribution.
JosephKS10
left a comment
There was a problem hiding this comment.
Great work @nouri-devv!
I ran into a few testing issues on my side and wanted to share in case it helps the team:
-
Had to rebuild the Docker container with --no-cache to ensure a clean environment.
-
The test database was missing some critical records:
- Roles: Student (1), Tutor (2), Convenor (3), Admin (4), Auditor (5)
- TeachingPeriod: id=3
- Basic unit/tutorial stream data
To fix the errors, I manually added these records in the Rails console:
rails console
Roles
Role.find_or_create_by(id: 1) { |r| r.name = "Student"; r.description = "Student" }
Role.find_or_create_by(id: 2) { |r| r.name = "Tutor"; r.description = "Tutor" }
Role.find_or_create_by(id: 3) { |r| r.name = "Convenor"; r.description = "Convenor" }
Role.find_or_create_by(id: 4) { |r| r.name = "Admin"; r.description = "Admin" }
Role.find_or_create_by(id: 5) { |r| r.name = "Auditor"; r.description = "Auditor" }
**TeachingPeriod**
TeachingPeriod.create!(
id: 3,
period: 'T1-2025',
start_date: '2025-01-01',
end_date: '2025-04-30',
year: 2025,
active_until: '2025-12-31'
)
After this, I was able to successfully run the specific test:
rails test test/models/task_definition_test.rb:272
Everything looks good, great work!
gauravmyana2002
left a comment
There was a problem hiding this comment.
Hey @nouri-devv nice work on updating the model
Did face the same issue as @JosephKS10 did but now it is solved so according to me everything looks good.
Thank you.
|
Thank you @JosephKS10 and @gauravmyana2002, yes me and Joseph went through that and narrowed down the issue. From my understanding, it seems that db:reset does not create the testing db. I think the issue Joseph was facing was a configuration issue beyond this work, I ran some other tests and was having the issue if the db:reset was ran before it. |
Description
For this task I updated the TaskDefinition and TutorialStream models to add support for tutorial self-enrolment.
The change adds two new fields on the
task_definitionstable:tutorial_self_enrolment_enabled→ a boolean flag that turns the feature on/offtutorial_self_enrolment_stream_id→ a foreign key pointing to a tutorial stream that students can self-enrol intoI also added the associations between models, validation to make sure the enrolment stream belongs to the same unit, and a reverse association on the TutorialStream side.
Type of change
This is part of a new feature for the student self enrollment.
How Has This Been Tested?
Manual Testing in Rails Console
TaskDefinitionwith self-enrolment enabled → it saved successfully, associations linked up correctly.Checklist:
If you have any questions, please contact @macite or @jakerenzella.
Automated Test (
test/models/task_definition_test.rb)