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

Lab2: fix viewing student work on a sublevel #58666

Merged
merged 4 commits into from
May 23, 2024

Conversation

sanchitmalhotra126
Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 commented May 15, 2024

Fix for viewing student work as a teacher on a lab2 sublevel. This was broken because the get_or_create_for_level API needed a script level ID to check if the teacher could view the student's work, which is not present on a sublevel. The fix here is just to explicitly pass through the script level ID of the current or parent level so that we can correctly check if the teacher can view the student's work.

Demo (disregard the duplicate levels 8 and 9, that's a local bug with my DB seeding).

Lab2SublevelTeacherPanel.mov

Links

https://codedotorg.atlassian.net/browse/LABS-803

Testing story

Tested on Lab2 allthethings progression, music intro script, and Gen AI pilot script. Also tested with individual levels and standalone projects to make sure no behavior regressed.

const userId = useSelector(
(state: {progress: ProgressState}) =>
state.progress.viewAsUserId || undefined
const currentLevelId = useAppSelector(state => state.progress.currentLevelId);
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for updating all of these to use useAppSelector.

Comment on lines 331 to 333
script_level = params[:script_level_id] ?
ScriptLevel.cache_find(params[:script_level_id].to_i) :
level.script_levels.find_by_script_id(script_id)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a potential malicious case in which the request provides a script_level_id which is used here to check for permission, but which is unrelated to the level_id which is used below to actually retrieve the channel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh true, that's a good point...yeah it would make sense to have a stricter check here. Ideally we should be able to use the script ID in combination with sublevel ID to find the script level ID. I'll look into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this with a check in projects_controller which ensures that if a script level ID is provided, it either matches the provided level ID or is associated with a valid parent level of provided sublevel ID. Added a unit test for this too. Let me know if you think this feels strict enough!

Copy link
Member

Choose a reason for hiding this comment

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

I don't know these subsystems very well, but that seems like a good improvement, with good test coverage too, thanks!

@sanchitmalhotra126 sanchitmalhotra126 requested review from breville, a team and kobryan0619 and removed request for a team May 21, 2024 22:37
Copy link
Member

@breville breville left a comment

Choose a reason for hiding this comment

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

I'm not too familiar with these systems, but glad the extra validation is in place. The approach and the testing looks solid. Thanks for tackling this complex system!

Copy link
Contributor

@kobryan0619 kobryan0619 left a comment

Choose a reason for hiding this comment

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

As we say in the midwest, "uffda". This all looks good though. I focused on the items related to scriptId and leveId. I am wondering if we should have UI/Eyes test coverage on this at all?

@sanchitmalhotra126
Copy link
Contributor Author

As we say in the midwest, "uffda". This all looks good though. I focused on the items related to scriptId and leveId. I am wondering if we should have UI/Eyes test coverage on this at all?

Thanks! Good call on UI tests - I'll add a check to the existing lab2 bubble choice UI tests.

@sanchitmalhotra126 sanchitmalhotra126 merged commit 710ce4a into staging May 23, 2024
2 checks passed
@sanchitmalhotra126 sanchitmalhotra126 deleted the sanchit/lab2-teacher-panel-sublevel branch May 23, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants