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

Add a page to view all vocabulary in a course version #38760

Merged
merged 6 commits into from Feb 1, 2021

Conversation

bethanyaconnor
Copy link
Contributor

@bethanyaconnor bethanyaconnor commented Jan 27, 2021

This PR adds:

  • A page to view all vocabulary associated with a course version, at the url /courses/:course_name/vocab/edit.
  • The ability to add new vocabulary from that page
  • The ability to edit existing vocabulary from that page
  • The ability to permanently destroy vocabulary from that page

Follow-up:

  • I didn't add the ability to filter vocabulary because the most vocabulary in a course version is 48, easily searchable from the browser. This might not be a sustainable solution for vocabulary and filtering will be needed for the All Resources page
  • I'd like to add a way to see (or edit!) the lessons a vocabulary is in. I didn't do that in this PR as it didn't feel like critical functionality but I'll do it as a follow-up if others think that would be useful

Other notes:

  • 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
  • Along the same vein, I wasn't sure where to put the React component either so open to other suggestions!

Screenshot for http://localhost-studio.code.org:3000/courses/coursea-2021/vocab/edit
Screen Shot 2021-01-28 at 10 27 08 AM

Deleting a vocabulary:
Screen Recording 2021-01-28 at 10 28 47 AM

Editing a vocabulary
Screen Recording 2021-01-29 at 8 10 19 AM

Links

Testing story

Reviewer Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

…ty to add new vocabulary and edit existing vocabulary
Base automatically changed from add-edit-vocabulary to staging January 28, 2021 18:44
@bethanyaconnor bethanyaconnor changed the title Add a page to view all vocabulary in a course version, with the abili… Add a page to view all vocabulary in a course version Jan 28, 2021
@bethanyaconnor bethanyaconnor changed the base branch from staging to revert-38780-revert-38694-add-edit-vocabulary January 28, 2021 20:42
Base automatically changed from revert-38780-revert-38694-add-edit-vocabulary to staging January 28, 2021 23:39
@bethanyaconnor bethanyaconnor marked this pull request as ready for review January 29, 2021 16:03
@bethanyaconnor
Copy link
Contributor Author

Tagging @tess323 here too in case she has any thoughts about what I've got here and/or any follow-up steps

@tess323
Copy link

tess323 commented Jan 29, 2021

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

Copy link
Contributor

@dmcavoy dmcavoy left a 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
Copy link
Contributor

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"?

Copy link
Contributor Author

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', () => {
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

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).

Copy link
Contributor

@dmcavoy dmcavoy left a 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

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.

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!

Comment on lines 53 to 59
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
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

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:

Suggested change
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.

@bethanyaconnor bethanyaconnor merged commit 6a7500c into staging Feb 1, 2021
@bethanyaconnor bethanyaconnor deleted the all-vocab-edit-page branch February 1, 2021 20:56
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