Commit eddf44d8 by Braden MacDonald Committed by E. Kolpakov

Library Content XModule

parent 074e4cfa
......@@ -766,6 +766,7 @@ ADVANCED_COMPONENT_TYPES = [
'word_cloud',
'graphical_slider_tool',
'lti',
'library_content',
# XBlocks from pmitros repos are prototypes. They should not be used
# except for edX Learning Sciences experiments on edge.edx.org without
# further work to make them robust, maintainable, finalize data formats,
......
......@@ -11,6 +11,7 @@ XMODULES = [
"discuss = xmodule.backcompat_module:TranslateCustomTagDescriptor",
"html = xmodule.html_module:HtmlDescriptor",
"image = xmodule.backcompat_module:TranslateCustomTagDescriptor",
"library_content = xmodule.library_content_module:LibraryContentDescriptor",
"error = xmodule.error_module:ErrorDescriptor",
"peergrading = xmodule.peer_grading_module:PeerGradingDescriptor",
"poll_question = xmodule.poll_module:PollDescriptor",
......
/* JavaScript for editing operations that can be done on LibraryContentXBlock */
window.LibraryContentAuthorView = function (runtime, element) {
$(element).find('.library-update-btn').on('click', function(e) {
e.preventDefault();
// Update the XBlock with the latest matching content from the library:
runtime.notify('save', {
state: 'start',
element: element,
message: gettext('Updating with latest library content')
});
$.post(runtime.handlerUrl(element, 'refresh_children')).done(function() {
runtime.notify('save', {
state: 'end',
element: element
});
// runtime.refreshXBlock(element);
// The above does not work, because this XBlock's runtime has no reference
// to the page (XBlockContainerPage). Only the Vertical XBlock's runtime has
// a reference to the page, and we have no way of getting a reference to it.
// So instead we:
location.reload();
});
});
};
......@@ -32,6 +32,10 @@ class StudentModule(models.Model):
MODULE_TYPES = (('problem', 'problem'),
('video', 'video'),
('html', 'html'),
('course', 'course'),
('chapter', 'Section'),
('sequential', 'Subsection'),
('library_content', 'Library Content'),
)
## These three are the key for the object
module_type = models.CharField(max_length=32, choices=MODULE_TYPES, default='problem', db_index=True)
......
<%!
from django.utils.translation import ugettext as _
%>
<div class="xblock-header-secondary">
% if library_status == LibraryStatus.OK:
<p>${_('This component will be replaced by {mode} {max_count} components from the {num_children} matching components from {lib_names}.').format(mode=mode, max_count=max_count, num_children=num_children, lib_names=', '.join(library_names))}</p>
% if update_status == UpdateStatus.NEEDED:
<p><strong>${_('This component is out of date.')}</strong> <a href="#" class="library-update-btn">↻ ${_('Update now with latest components from the library')}</a></p>
% elif update_status == UpdateStatus.UP_TO_DATE:
<p>${_(u'✓ Up to date.')}</p>
% endif
% elif library_status == LibraryStatus.NONE:
<p>${_('No library or filters configured. Press "Edit" to configure.')}</p>
% else:
<p>${_('Library is invalid, corrupt, or has been deleted.')}</p>
% endif
</div>
......@@ -4,7 +4,7 @@
## The JS for this is defined in xqa_interface.html
${block_content}
%if location.category in ['problem','video','html','combinedopenended','graphical_slider_tool']:
%if location.category in ['problem','video','html','combinedopenended','graphical_slider_tool', 'library_content']:
% if edit_link:
<div>
<a href="${edit_link}">Edit</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment