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
Enforce plc stage conventions #13949
Conversation
…dules are grouped together in the correct way - content modules with content modules, practice modules with practice modules
…fix to alltheplcthings
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.
LGTM modulo a couple questions
learning_module_types = stages.map(&:flex_category) | ||
|
||
unless learning_module_types.uniq == [nil] || Set.new(learning_module_types) <= Set.new(Plc::LearningModule::MODULE_TYPES) | ||
raise "#{name}, either all stages must have flex categories that correspond to learning module types, or none of them should have categories" |
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.
any reason why we're not raising a more-specific RecordInvalid
error here and below?
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.
RecordInvalid happens when trying to persist an object to the DB. That's not happening here, so it's not really appropriate to raise that exception
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.
Actually I might be able to just raise this
raise "#{name}, either all stages must have flex categories that correspond to learning module types, or none of them should have categories" | ||
end | ||
|
||
unless learning_module_types.compact.empty? || learning_module_types.chunk { |x| x }.map(&:first) == learning_module_types.uniq |
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.
isn't the learning_module_types.compact.empty?
case redundant here?
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.
No - if the pd course has no flex categories, then learning_modules_types is [nil, nil, nil] in which case this is needed
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.
ah, I was falsely assuming that learning_module_types.chunk { |x| x }.map(&:first)
would give us [nil]
in that situation
dashboard/test/models/script_test.rb
Outdated
end | ||
end | ||
|
||
test 'Cannot setup script where some of the stages are missing flex categories' do |
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.
looks like ya forgot to update the name of this test
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.
Will change
For PLC scripts, either all stages should have flex categories or none of them should. Additionally, flex categories should be grouped together.