Library Content - Filter library content by CAPA problem type - #6346
Conversation
There was a problem hiding this comment.
This filtering should happen in LibraryToolsService.update_children as it has the following benefits:
- It happens once per XBlock, not once per student as in this version.
- It automatically updates "This component will be replaced by N components ..." in studio
However, I was unable to achieve that. update_children operates on XModuleDescriptors, not XModules, while filtering by CAPA problem type requires examining LoncapaProblem, which is available on CapaModule only. Unfortunately, the context here does not allow fetching XMoudule from XModuleDescriptor, as it uses CachedDescriptorSystem, which does not have all the machinery to support XModule => attempts to fetch XModule by XModuleDescriptor or usage key results in UndefinedContext.
@cpennington @dmitchell are there any ways to get actual CapaModule in such a context? To save you a little bit of digging, entry point for LibraryToolsService.update_children is LibraryContentDescriptor.editor_saved
102047e to
c051785
Compare
There was a problem hiding this comment.
It's odd that you're returning True if you don't know if it matches. You could parse the xml in the data field, but that seems horrid. (i.e., just do a substring search for self.capa_type in block.data.) This assumes that capa_type == the xml tag names (e.g., optionresponse | multiplechoiceresponse | choiceresponse...). The interesting thing about these is that a single block can have many (or none) capa types.
There was a problem hiding this comment.
@dmitchell thanks for suggestion. capa_type is indeed xml tag names, so this is a very low-level approach, but could do the trick actually. Until CAPA problem format changes, but it doesn't look like it happens too often.
0f0821c to
ea03428
Compare
d6fa6c0 to
e19e166
Compare
|
@mattdrayer @chrisndodge this is ready for review. Please note that I'm on vacation 12/31/2014 - 01/04/2015, so I'll only have one day (tomorrow) to address review notes. Thus it would be nice to have this PR reviewed today. |
|
Added a sandbox with the current code: LMS at http://content-libraries.sandbox.opencraft.com/ and Studio at http://content-libraries.sandbox.opencraft.com:18010/ |
There was a problem hiding this comment.
Is there a way we could do this via introspection in some way rather than explicitly listing all of this out? Basically, this approach leads to more things a developer has to do in order to add/remove CAPA problems. I don't think there's much activity regarding CAPA modules, but I figured I would ask.
There was a problem hiding this comment.
@chrisndodge names for basic and advanced groups are taken from XML templates used for "Add Component". Others are my guess on how it should be named. Unfortunately there are no human names on response types and there are no simple rule for guessing that automatically. So, there are virtually two (and a half) options:
- List them here as of now
1.5. Invent a rule that would cover most, than list exceptions here - Add
human_nameproperty for all capa response types - this result s in shotgun-style changes, so decided to stick with (1)
Also, please note that these names are in sync with CAPA template names, and those names are taken from yaml file names.
There was a problem hiding this comment.
@dan-f recently added (or avoided adding and did what you did) a category display name mechanism for xblocks which should generalize to this.
There was a problem hiding this comment.
It looks like you may be able to get the list of capa_types via introspection. You'd need to get all the subclasses of LoncapaResponse and get the tags property from them. Mapping these to the human readable names is still a problem but we should solve it by moving the human readable names to class properties on these classes, imho, rather than spreading out the mappings throughout the code. @cahrens either T&L should do this or should pick up on it after @e-kolpakov does it for his need and T&L should remove the hardcoded strings and get the class property instead.
There was a problem hiding this comment.
I think the work should be done as part of this PR rather than creating technical debt.
There was a problem hiding this comment.
You shouldn't need to manually trace the subclasses -- we already collect that information in responsetypes.registry (it's a TagRegistry). I agree with @dmitchell that we should just add the human readable name as a class property.
There was a problem hiding this comment.
@dmitchell @ormsbee @cahrens I was thinking of the option you described as well and decided that shotgun-style edits of adding a property to every capa problem would be a greater evil than having them all stored externally. There were probably other considerations, since initially it was implemented to work against input types, rather than response types. Anyway, looks like I guessed wrong :)
I'm on vacation, so just stopped by to answer notes and left some hints for @Kelketek, who will be taking care of this PR while I'm away. So, notes: we're talking about types in common/lib/capa/capa/responsetypes.py. There's also registry member in that module, which is a TagRegistry instance from common/lib/capa/capa/registry.py. Types will need human_name property, registry is to be used to build capa_types dictionary in library_content_module.py
There was a problem hiding this comment.
Can you indicate what formatting rules might exist here. I see an 'any' ENUM value, but should this otherwise be a comma-separated list? Or is it "any" or just one type? In any case, I'd suggest filling out the help message here with more specific instructions to the studio user.
There was a problem hiding this comment.
@chrisndodge It's one type or no filtering at all. I'll update the help message (tomorrow though, it's pretty late for me already)
|
@chrisndodge added a minor feature according to the discussion here: https://openedx.atlassian.net/browse/SOL-122?focusedCommentId=94008&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-94008 In two words: it now checks there are enough child blocks passing filter test in libraries (i.e. >= "Count" setting) |
8056ce2 to
a487da4
Compare
|
Updated the sandbox with the current code: LMS at http://content-libraries.sandbox.opencraft.com/ and Studio at http://content-libraries.sandbox.opencraft.com:18010/ |
a487da4 to
9fc92ac
Compare
|
@explorerleslie @cahrens @frrrances @cptvitamin @dmitchell I believe this is ready for more thorough review. Please note I'm off 12/31/2014-1/4/2015, so most likely someone else will address any notes while I'm away. |
There was a problem hiding this comment.
Can you or someone add a story to the T&L backlog to do this TODO and change this to a reference to that story?
There was a problem hiding this comment.
There's already an TNL story for this-- https://openedx.atlassian.net/browse/TNL-993. I think just the comment needs to be updated.
|
👍 conditional on using |
There was a problem hiding this comment.
Suggested rewrite for this error message:
"There are no matching problem types in the specified libraries. Select another problem type."
|
@dmitchell @catong I've pushed some changes that should address these issues. Jenkins is reporting failures, but I can't reproduce them locally. |
16809dd to
76d3f35
Compare
… of XML templates in tests
* Added tests for `problem_types` CapaDescriptor property * Improved indentation in tests * Improved validation messages
01649f4 to
ee0508d
Compare
ee0508d to
4c89f2c
Compare
|
@cahrens This should be ready, but Jenkins keeps crashing every time I try to trigger a build. |
|
@e-kolpakov @Kelketek Because this PR will conflict with the Scope.settings PR 6399, I tried merging the branches together locally and sorting out the conflicts. In doing so I found a bug in 6399 (now fixed) and some ways to simplify the code in this branch. So I've just pushed a commit with those simplifications and some preemptive changes that will make it way easier to resolve conflicts with 6399. The main simplification stems from the fact that LibraryContentModule's Feel free to amend or revert this change if you see any problems with it... |
|
@cahrens diff coverage report Jenkins shows is a bit wrong: it compares this branch to Missing coverage in this PR:
With these added tests this PR have 100% test coverage. So if 95% coverage for overall feature branch still concerns you I would suggest adding a new story for improving test coverage and repaying technical debt (if any). This PR/feature is not about pushing coverage on content-libraries branch to 100% after all :) |
|
@bradenmacdonald just to let you know, at a glance everything (both tests and Studio) works just fine with your improvements - thank you! |
0db325e to
e394125
Compare
|
Updated the sandbox with the latest code: http://content-libraries.sandbox.opencraft.com:18010/ |
There was a problem hiding this comment.
Since ↻ is no longer in the string that is scraped, translators won't see it. Therefore your comment doesn't really apply.
What WOULD be useful though is that you make the placeholder named and explain what will go there. For example, a placeholder named "refresh_icon" and a note for translators that refresh_icon is ↻. That way they can decide if the placement should be elsewhere relative to the text. As it is, they have no idea what will be substituted for {0}.
"{refresh_icon} Update now.".format(refresh_icon=↻), with appropriate translator comment above.
There was a problem hiding this comment.
@cahrens sure, will do in a minute, don't go away too far :)
|
Once the string translation is updated and you get a green build, 👍 |
98877dc to
631ec95
Compare
Retriggering Jenkins
631ec95 to
af1b085
Compare
|
@antoviaque lo, we have a green build! And there was much rejoicing. |
…-by-problem-type Library Content - Filter library content by CAPA problem type
Background: This PR contains the LibraryContent XBlock, which allows to display library content in a course.
JIRA ticket: SOL-122
Discussions: Architecture discussed extensively on the wiki and in meetings, then the revised proposal was presented to the Arch Council on Oct. 21 and given thumbs up.
Dependencies: https://github.com/edx/edx-platform/pull/6155 (probably will require a rebase after 6155 merged)
Sandbox URL: LMS at http://content-libraries.sandbox.opencraft.com/ and Studio at http://content-libraries.sandbox.opencraft.com:18010/
Internal code reviews PRs: open-craft#24
Partner information: 3rd party-hosted open edX instance, for an edX solutions client.
Testing instructions: