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

When generating PLC course set all course type and published state information #44478

Merged
merged 7 commits into from
Jan 25, 2022

Conversation

dmcavoy
Copy link
Contributor

@dmcavoy dmcavoy commented Jan 23, 2022

Scripts that are part of PLC courses generate a Unit Group with the same name as the one saved in the professional_learning_course on script. The Unit Group is created in generate_plc_objects and is not serialized. We need a way to set things like the audiences on the unit group in order to be able to make sure access to the plc course is set to the right audiences (as well as published states and instruction type). Therefore we must rely on the script to get the unit groups settings for instructor_audience, participant_audience, instruction_type and published_state. This is not the ideal solution to fix this, but because we do no currently have time to invest in cleaning up the plc course models and this set up of unit groups for plc courses, this is the best we can do right now. By setting the unit group based on the settings of the script which has just been saved we could end up with multiple scripts in the same plc course with different settings. We will be creating a guide to publishing plc courses to hopefully help prevent issues here.

This will be followed by a PR with a migration to update the current UnitGroups for PLC Courses in all environments: #44479

Links

Slack Thread

Testing story

  • Added new unit test

@dmcavoy dmcavoy changed the title When generating PLC course make sure that published state, instructio… When generating PLC course set all course type and published state information Jan 25, 2022
@dmcavoy dmcavoy requested a review from a team January 25, 2022 01:45
Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

this looks like the right idea to me @dmcavoy , but given the potentially fragile nature of this solution I'd be in favor of beefing up the unit tests a bit.

assert_equal 'teacher', unit_group.participant_audience
assert_equal 'self_paced', unit_group.instruction_type
assert_equal 'stable', unit_group.published_state
end
Copy link
Member

Choose a reason for hiding this comment

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

are there any cases we care about where the plc unit already has a unit group (from a previous invocation of generate_plc_objects) and we need to change published state, instruction type or audience? My reading of get_instruction_type is that it would look to unit group first, and so a change to the unit's instruction type wouldn't actually get picked up.

Unless we are confident this will never happen, my suggestion would be to add a test case covering these values changing, whatever the desired behavior is in that case (e.g. it could be to raise an exception if these values are not supposed to change).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pushing on this. We should be just directly checking instruction_type instead of going to get_instruction_type here because we only care about what the script has set for instruction_type.

Copy link
Member

Choose a reason for hiding this comment

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

per offline conversation, this seems good in terms of unit tests. there are some cases which may make sense to either add safeguards for or else carefully document:

  • DLP courses are usually created by cloning. by default cloned courses start in the in_development state. need to be clear about how to get these into beta (either by clearly documenting that an engineer should do this right after cloning, or by modifying the clone script)

Comment on lines 211 to 214
unit_group.published_state = get_published_state if unit_group.published_state != get_published_state
unit_group.instruction_type = get_instruction_type if unit_group.instruction_type != get_instruction_type
unit_group.participant_audience = get_participant_audience if unit_group.participant_audience != get_participant_audience
unit_group.instructor_audience = get_instructor_audience if unit_group.instructor_audience != get_instructor_audience
Copy link
Member

Choose a reason for hiding this comment

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

are the if unit_group.foo != foo clauses actually doing anything, given you already have the if unit_group.changed? check below? my suggestion would be to add test cases covering all the behavior you care about, and then consider removing the if clauses on lines 211-214 if you can do so without breaking the tests.

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.

None yet

2 participants