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

LibraryContent - Display content from a library in a course (SOL-5, SOL-6, SOL-7, SOL-8, SOL-117) #6155

Conversation

e-kolpakov
Copy link
Contributor

Instructions to test:

  1. Create a Library with some content, and a course
  2. In the course, go to Settings > Advanced Settings and add "library_content" to advanced_modules.
  3. Go to Content > Outline. Create a new section and subsection, then edit it. Click "Advanced" and add a new "library_content" block.
  4. Once the block is added, click "Edit" to edit its settings. Most are explained on the settings editor. For the "Library" setting, you must click "Add", then paste the LibraryLocator of your library. This looks like library-v1:ProblemX+PR0B. (It's in the URL when you go to the library in studio). Hit Save.
  5. Click "Update now with latest components from the library".
  6. Optional: Click "View >" to preview all the blocks found in the library.
  7. Hit "Publish", then go to the LMS. Browse into the course, and you should see that the block is replaced by random blocks from the library. To test the randomization, click the lowest "STAFF DEBUG INFO" link underneath the module, then click "Delete Student State", then refresh the page.

Author concerns:

  1. LibraryContent is implemented as an XModule - should likely to be implemented as XBlock, though it's unclear if the necessary infrastructure is yet implemented in the runtime[s].
  2. Tests assert against displayed text -- will break if (when) text changed; see inline notes for details on this.

@openedx-webhooks
Copy link

Thanks for the pull request, @e-kolpakov! I've created OSPR-260 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • edx-code email threads
  • timeline information ('this must be merged by XX date', and why that is)
  • partner information ('this is a course on edx.org')
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will still be done via the Github pull request interface. As a reminder, our process documentation is here.

@e-kolpakov
Copy link
Contributor Author

This is a WIP for some time as there are some improvements to be done (e.g. bokchoy tests), so submitting for preliminary review and a place to host conversations regarding.

@e-kolpakov e-kolpakov changed the title (WIP) Content Libraries - Library Course XBlock (WIP) LibraryContent - Display content from a library in a course (SOL-5, SOL-6) Dec 5, 2014


@XBlock.wants('user')
class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDescriptor, StudioEditableDescriptor):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cpennington this library content block is implemented as an XModule now, since it was initially implemented like so. I've tried converting it to a XBlock and had some difficulties, mainly due to high coupling to XModule ecosystem (MakoModuleDescriptor, StudioEditableDescriptor)

So the questions are:

  • Are there any existing helpers similar to MetadataOnlyEditingDescriptor for XBlocks? As of now this LibraryContentModule does not use it directly, but essentially do exactly the same thing.
  • If it's not, what is an expected way to handle studio edits? I believe having custom js + studio_submit XBlock.handler is a common practice, but it looks tedious to reimplement it for every single XBlock. Are there any shortcuts?


library_container.save_settings()

self.assertIn(expected_text, library_container.header_text)
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 don't like the way how assertion is done here. It's better tested if assertion against XBlock extracted from modulestore is done. But this would couple acceptance tests to modulestore, which is not the case now (or at least it looks like acceptance tests are abstracted from modulestore concept).

So, if it's ok to couple tests to modulestore and it's possible to use modulestore from tests level - this test can (and should) be rewritten to assert against XBlock instance, rather than displayed text.

Copy link

Choose a reason for hiding this comment

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

I don't think acceptance tests should be coupled to the modulestore. The point is to test the whole workflow "as a user". I would expect testing of xblock internal state to occur at the unit test level.

Yes, the test will change if the error text changes. But it should-- the point is to test what the user is seeing.

@e-kolpakov e-kolpakov force-pushed the content_libraries/3-library-course-block branch from bac6ee5 to e508ae4 Compare December 9, 2014 06:02
@antoviaque antoviaque changed the title (WIP) LibraryContent - Display content from a library in a course (SOL-5, SOL-6) (WIP) LibraryContent - Display content from a library in a course (SOL-5, SOL-6, SOL-8) Dec 9, 2014
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
%>
<div class="xblock-header-secondary">
Copy link
Contributor

Choose a reason for hiding this comment

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

I can check in with @andy-armstrong in person, but my understanding was that there already is an existing .xblock-header / .xblock-message area we could reuse for this message? Just in case we do I wanted to add a comment while skimming through this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I just checked the sandbox to see where this is located. There may be another pull request to resolve this, but our tentative plan was to move in the "up to date" and "updates" messages into the editor modal ( reference: http://invis.io/9X1PRVSGV) and validation messages to use the latest Studio patterns (reference: http://invis.io/BK1RLKQAX).

If there is another pull request feel free to ignore this comment! Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, we have another PR coming soon that will address those changes (I think it's based on our internal PR 19).

@bradenmacdonald
Copy link
Contributor

This is rebased and is ready for a review. Please note the "Author Concerns" in the description before reviewing.

All tests/quality should be passing, but something is wrong with Jenkins at the moment, and it is showing everything failing due to FATAL: Unable to load resource META-INF/services/org.apache.commons.logging.LogFactory. I'm not sure how to fix that, as I tried pushing a new build but it shows the same error.

@cpennington Can you review the XBlock?

@explorerleslie @cahrens Can you review the Studio editing portion of the XBlock?

CC @antoviaque

@bradenmacdonald bradenmacdonald changed the title (WIP) LibraryContent - Display content from a library in a course (SOL-5, SOL-6, SOL-8) LibraryContent - Display content from a library in a course (SOL-5, SOL-6, SOL-8) Dec 10, 2014
@antoviaque
Copy link
Contributor

Sandbox updated with the latest code from the branch: http://content-libraries.sandbox.opencraft.com:18010/

@cahrens
Copy link

cahrens commented Dec 10, 2014

Need to define a user-friendly display name on the library block (not library_content). Can just a default value for the display_name property.

image

Note also that the messages you are showing (not configured, out of date, etc.) are not consistent with how our validation messages are shown. Use the existing validation framework (I linked to an example below).

@cahrens
Copy link

cahrens commented Dec 10, 2014

Side documentation talks about content experiments and reordering. Something needs to be done about the very long number at the top.

image

from django.core.urlresolvers import reverse
%>
<div class="xblock-header-secondary">
% if library_status == LibraryStatus.OK:
Copy link

Choose a reason for hiding this comment

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

Use the existing validation framework. All you need to do is extend "validate" and return messages. The rendering will be done for you in a way that is consistent with other xblocks.

For an example, see https://github.com/edx/edx-platform/blob/master/common/lib/xmodule/xmodule/split_test_module.py#L523

I would prefer you not check in this HTML and then remove it. So if you have a separate PR that does the validation (I just finally saw the comments above...), go ahead and combine it with this PR. That is, combine the notification part of the PR only. Note that even the "This component is out of date" message can be replaced by a notification message-- you can register actions.

@cahrens
Copy link

cahrens commented Dec 10, 2014

When you first specify the library, you get the message "This component is out of date". Why? It should sync up immediately with what is in the library, and I would expect to only get that message later if the library subsequently changes.

@cahrens
Copy link

cahrens commented Dec 10, 2014

Have you verified that Preview of draft content works properly? I don't think your sandbox is properly configured for Preview.

@cahrens
Copy link

cahrens commented Dec 10, 2014

Have you verified (or do you have a story for it) that grading works properly? That is, that the student is only graded on the problems he/she sees?

@@ -32,6 +32,10 @@ class StudentModule(models.Model):
MODULE_TYPES = (('problem', 'problem'),
('video', 'video'),
('html', 'html'),
('course', 'course'),
Copy link

Choose a reason for hiding this comment

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

Why adding course, chapter, and sequential? Is there any performance hit?

Copy link
Contributor

Choose a reason for hiding this comment

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

I added those types because I saw that in practice, they were already present in StudentModule anyways (to store the position field). This has no performance impact and only fixes the UI in the Django admin app.

BTW, the LMS team may want to just remove this enum completely, as it seems that almost any type of module is now stored in StudentModule and this enum is perhaps vestigial code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we should just remove this list.

@bradenmacdonald
Copy link
Contributor

Thanks @cptvitamin. BTW for now we are just merging to a feature branch and I believe we will have another chance to review everything when the feature branch gets merged to master.

@marcotuts
Copy link
Contributor

@bradenmacdonald - Looked great to me, thanks for all the updates! Very glad we added in the library location ID section to the sidebar as well! (cc'ed @catong)

👍 from me.

@frrrances
Copy link
Contributor

@bradenmacdonald Nice work! Thanks for switching over to use the existing warning patterns and adding in the Library ID block in the sidebar. I had a few UX level questions, which may be out of the scope of this work, but I think it would be good to make these changes in the near future if possible:

  1. Can we add some context at the top of the Library pages to provide some way finding? Either add the word “Library” on to the Library name in the header or maybe a breadcrumb for the short term. (i pencilled in the two options in the screenshot below - one or the other but not both):

screen shot 2014-12-23 at 9 23 35 am

  1. Can we have an "add component" button at the top of a content library page? It can be a scroll-to that imitates the green header “add” buttons elsewhere in Studio, like this:

screen shot 2014-12-23 at 9 44 43 am

  1. It would be nice to be able to toggle the previews on the Content Library page - and it might help the initial page to load faster if its starts with “Hide Previews” (and the user can select “Show all Previews” or just select “Show Preview” on any one component).

screen shot 2014-12-23 at 9 24 34 am

None of these are blockers, but I think if we can do any of these, it will help the users. 👍

@@ -334,6 +342,45 @@ def children(self):
return [descendant for descendant in descendants if descendant.locator not in grand_locators]

@property
def has_validation_message(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi all. Just a heads up that we are borrowing these excellent page methods in #6227. Here's the diff. Whichever PR lands later will need to rebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the heads up!

@bradenmacdonald
Copy link
Contributor

@frrrances Thanks for the feedback. The third thing has already been implemented and we will be opening a PR and merging it soon. The first two things are outside the scope of this PR, but I will add them to our list - they are both easy changes.

@bradenmacdonald bradenmacdonald force-pushed the content_libraries/3-library-course-block branch from 82b7bb8 to 0cc3b33 Compare December 23, 2014 19:31
bradenmacdonald added a commit that referenced this pull request Dec 23, 2014
…course-block

LibraryContent - Display content from a library in a course (SOL-5, SOL-6, SOL-7, SOL-8, SOL-117)
@bradenmacdonald bradenmacdonald merged commit 16809dd into openedx:content-libraries Dec 23, 2014
@bradenmacdonald
Copy link
Contributor

Rebased and merged. Thanks to everyone who helped review and improve this PR!

@marcotuts
Copy link
Contributor

@frrrances - Just as a follow up, the first item in your list is currently scheduled for inclusion in https://openedx.atlassian.net/browse/SOL-80, which should be merged in the coming week or more. The second "+ Add Component" scroll to is something I can create a backlog story for now (https://openedx.atlassian.net/browse/SOL-195), though I'm hopeful in the short term that the pagination and expand/collapse functionality lessens the scrolling issue. Thanks for your review and feedback on this! (Also thanks to @bradenmacdonald and @e-kolpakov!)

@bradenmacdonald bradenmacdonald deleted the content_libraries/3-library-course-block branch January 3, 2015 00:26
bradenmacdonald added a commit that referenced this pull request Jan 3, 2015
…course-block

LibraryContent - Display content from a library in a course (SOL-5, SOL-6, SOL-7, SOL-8, SOL-117)
@bradenmacdonald bradenmacdonald mentioned this pull request Jan 6, 2015
10 tasks
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.