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
Add a page to view all vocabulary in a course version #38760
Conversation
…ty to add new vocabulary and edit existing vocabulary
ac39bf0
to
4181588
Compare
Tagging @tess323 here too in case she has any thoughts about what I've got here and/or any follow-up steps |
This is awesome @bethanyaconnor! I agree in the short term search isn't necessary. If it would take less than a day (day and a half) to add lessons tagged with that vocab I would go ahead and do it! Anything longer we should chat about - my major question is will doing it here make it easier to do it on things like resources |
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.
I think /lib/levelbuilder seems like the right place to put this since thats where all the other new editors are.
style={styles.addButton} | ||
type="button" | ||
> | ||
<i className="fa fa-plus" style={{marginRight: 7}} /> Create New |
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.
nit: Should "Create New" be on the next line with "Vocabulary"?
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.
hmm prettier is breaking it up...I'll just move the whole thing to the next line
expect(wrapper.find('tr').length).to.equal(3); | ||
}); | ||
|
||
it('can remove a vocabulary', () => { |
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.
maybe add a test for checking you can add vocabulary?
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.
I was struggling on what to actually test for that path as the logic is mostly handled through another component. I'm adding a test that clicking the button actually brings up that component but not sure what else to add.
@@ -36,11 +36,25 @@ def update | |||
end | |||
end | |||
|
|||
# GET /courses/:course_name/vocab/edit |
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.
It makes sense to me to have this in this controller
@@ -43,4 +43,28 @@ class VocabulariesControllerTest < ActionController::TestCase | |||
vocabulary.reload | |||
assert_equal 'definition', vocabulary.definition | |||
end | |||
|
|||
test "can load edit page of unit group course version" 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.
nit: "can load vocab edit page..." (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.
Bethany this looks awesome! Thanks for building on this page that can be a template for future pages of this kind! One request for another test and some nits but overall looks good to me
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.
Awesome progress @bethanyaconnor , this looks great!
I wasn't sure which controller to put this in. The url suggests courses_controller but the fact that this page is really only about vocabulary suggests vocabularies_controller. I put this functionality in the latter for now, but it would be fairly easy to move
vocabularies_controller sounds right to me!
def find_matching_course_version | ||
matching_unit_group = UnitGroup.find_by_name(params[:course_name]) | ||
return matching_unit_group.course_version if matching_unit_group | ||
matching_standalone_course = Script.find_by_name(params[:course_name]) | ||
return matching_standalone_course&.get_course_version if matching_standalone_course&.is_course | ||
return nil | ||
end |
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.
The above method looks like it might be some of the mess you were talking about as it relates to course version. I don't see a way around this in the short term. in the future, we want to move properties like "name" out of the Script and UnitGroup and into the CourseVersion. Then, this kind of operation should be easier to perform.
Does any of this seem a bit more sane knowing that "name" should eventually get moved into CourseVersion?
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.
Yes that would be so much easier here! That's essentially what this function is looking for, except that we can't know which model holds the name until we look for it
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.
Furthermore -- one of the reasons I was considering not having this logic in vocabularies_controller
was because this helper function would need to be shared/duplicated when we write the All Resources page. I figured I could kick that can down the road and move it when it actually needs to be shared, but having a simpler way to query for a course would make this issue largely moot.
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.
Good point -- this doesn't really belong in the vocabularies controller. when it comes time to build the All Resources page, I think it would make sense to move this into the CourseVersion model. I don't think we'll get to moving the name out of Script and UnitGroup into CourseVersion until "Q2 Tech Debt".
matching_unit_group = UnitGroup.find_by_name(params[:course_name]) | ||
return matching_unit_group.course_version if matching_unit_group | ||
matching_standalone_course = Script.find_by_name(params[:course_name]) | ||
return matching_standalone_course&.get_course_version if matching_standalone_course&.is_course |
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.
on this line in particular, I think it might be better to do:
return matching_standalone_course&.get_course_version if matching_standalone_course&.is_course | |
return matching_standalone_course&.course_version if matching_standalone_course&.is_course |
I think this will do the same thing as the code you have here, but it's a bit more straight forward because we are already checking that we're handling the case where this script is not in a unit group.
This PR adds:
/courses/:course_name/vocab/edit
.Follow-up:
Other notes:
courses_controller
but the fact that this page is really only about vocabulary suggestsvocabularies_controller
. I put this functionality in the latter for now, but it would be fairly easy to moveScreenshot for http://localhost-studio.code.org:3000/courses/coursea-2021/vocab/edit
Deleting a vocabulary:
Editing a vocabulary
Links
Testing story
Reviewer Checklist: