default="water",
scope=Scope.content
)
+ recid = String(
+ help="Record to display",
+ default="content: title modern water resources engineering",
+ scope=Scope.content
+ )
display_name = String(
default="MKWS bibliographic details",
scope=Scope.settings
def student_view(self, context=None):
"""The primary view of the MKWS XBlock, shown to students when viewing courses."""
html = self.resource_string("static/html/student.html")
- frag = Fragment(html.format(query=self.query, team=random.randint(0, 100000)))
+ frag = Fragment(html.format(query=self.query, recid=self.recid, team=random.randint(0, 100000)))
# student.js uses require.js as it cannot guarantee mkws-complete.js has loaded
# in studio without it. We'll need to add it if we're in the LMS:
- frag.add_javascript_url("/static/js/vendor/require.js");
+ #frag.add_javascript_url("/static/js/vendor/require.js");
+ frag.add_javascript_url("//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.14/require.min.js");
# frag.add_resource_url("//mkws.indexdata.com/mkws-complete", "text/javascript", "head");
# frag.add_resource('<script src="//mkws.indexdata.com/mkws-complete.js"></script>', "text/html", "head");
+ frag.add_css(self.resource_string("static/css/mkwsbiblio.css"))
frag.add_javascript(self.resource_string("static/js/src/student.js"))
frag.initialize_js('MKWSBiblio')
return frag;
# This should closely mirror the student_view. Here all we do is not include
# require.js as it's already in Studio and the lms path won't work.
html = self.resource_string("static/html/student.html")
- frag = Fragment(html.format(query=self.query, team=random.randint(0, 100000)))
+ frag = Fragment(html.format(query=self.query, recid=self.recid, team=random.randint(0, 100000)))
+ frag.add_css(self.resource_string("static/css/mkwsbiblio.css"))
frag.add_javascript(self.resource_string("static/js/src/student.js"))
frag.initialize_js('MKWSBiblio')
return frag;
def studio_view(self, context=None):
"""Studio configuration view."""
html = self.resource_string("static/html/settings.html")
- frag = Fragment(html.format(query=self.query))
+ frag = Fragment(html.format(query=self.query, recid=self.recid))
frag.add_javascript(self.resource_string("static/js/settings.js"))
frag.initialize_js('MKWSBiblioSettings')
return frag
def update_settings(self, data, suffix=''):
"""Studio configuration callback."""
self.query = data['query']
+ self.recid = data['recid']
return {"result": "success"}
@staticmethod
--- /dev/null
+.mkwsDetails th {
+ text-align: right;
+ vertical-align: top;
+ padding-right: 0.6em;
+}
+.mkwsDetails th:after {
+ content: ":";
+}
<ul class="list-input settings-list">
<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting" id="mkwsCurrentRecordContainer">
- <h3>Current selection:</h3>
- <div class="mkwsRecords mkwsTeam_UNIQUE" id="mkwsCurrentRecord" autosearch="{query}" perpage="1">Loading record...</div>
+ <div class="mkwsDetails mkwsTeam_ConfiguredRecord" id="mkwsCurrentRecord" autosearch="{query}" data-mkws-recid="{recid}" data-mkws-config='{{ "template": "EdxChosen" }}'>Loading record...</div>
</div>
</li>
<li class="field comp-setting-entry is-set">
<h3>Choose a record:</h3>
<div class="mkwsSearch mkwsTeam_BlockConfig"></div>
<!-- NB: double braces needed to escape edx templateing -->
- <div class="mkwsRecords mkwsTeam_BlockConfig" data-mkws-config='{{ "template": "EdxChooser", "perpage": 5 }}'></div>
+ <div class="mkwsRecords mkwsTeam_BlockConfig" perpage="5" data-mkws-config='{{ "template": "EdxChooser" }}'></div>
</div>
</li>
</ul>
<div class="mkwsbiblio_block">
- <div class="mkwsRecords mkwsTeam_{team}" autosearch="{query}" perpage="1">Loading record...</div>
+ <div class="mkwsDetails mkwsTeam_{team}" autosearch="{query}" data-mkws-recid="{recid}">Loading record...</div>
</div>
if (helper = helpers.detailLinkId) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0.detailLinkId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
- + "\" onclick=\"$('#mkwsCurrentRecord').attr('autosearch', '";
- if (helper = helpers['md-title']) { stack1 = helper.call(depth0, {hash:{},data:data}); }
- else { helper = (depth0 && depth0['md-title']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
- buffer += escapeExpression(stack1)
- + "'); mkws.init('Click select', $('#mkwsCurrentRecordContainer'));\">\n <b>";
+ + "\" onclick=\" $('#mkwsCurrentRecord').attr('data-mkws-recid', '"
+ + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.recid)),stack1 == null || stack1 === false ? stack1 : stack1[0])),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + "'); $('#mkwsCurrentRecord').attr('autosearch', mkws.teams['BlockConfig'].query()); delete mkws.teams.ConfiguredRecord; mkws.init('Click select', '#mkwsCurrentRecordContainer'); return false;\">\n <b>";
if (helper = helpers['md-title']) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0['md-title']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
return buffer;
});
})();
+(function() {
+ var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
+templates['EdxChosen'] = template(function (Handlebars,depth0,helpers,partials,data) {
+ this.compilerInfo = [4,'>= 1.0.0'];
+helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
+ var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression;
+
+
+ buffer += "<span>Current selection: ";
+ if (helper = helpers['md-title']) { stack1 = helper.call(depth0, {hash:{},data:data}); }
+ else { helper = (depth0 && depth0['md-title']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
+ buffer += escapeExpression(stack1)
+ + "</span>\n";
+ return buffer;
+ });
+})();
function MKWSBiblioSettings(runtime, element) {
mkws.init("XBlock settings pane", "#settings-tab");
$(element).find('.save-button').bind('click', function() {
var handlerUrl = runtime.handlerUrl(element, 'update_settings');
var data = {
- query: $(element).find('#mkwsCurrentRecord').attr('autosearch')
+ query: mkws.teams["BlockConfig"].query(),
+ recid: $(element).find('#mkwsCurrentRecord').attr('data-mkws-recid')
};
$.post(handlerUrl, JSON.stringify(data)).done(function(response) {
window.location.reload(false);
+ return false;
});
});
$(element).find('.cancel-button').bind('click', function() {
runtime.notify('cancel', {});
+ return false;
});
-};
+}
}}
{{#each hits}}
<div class="{{containerClass}}">
- <a href="#" id="{{detailLinkId}}" onclick="$('#mkwsCurrentRecord').attr('autosearch', '{{md-title}}'); mkws.init('Click select', $('#mkwsCurrentRecordContainer'));">
+ <a href="#" id="{{detailLinkId}}" onclick=" $('#mkwsCurrentRecord').attr('data-mkws-recid', '{{recid.[0]}}'); $('#mkwsCurrentRecord').attr('autosearch', mkws.teams['BlockConfig'].query()); delete mkws.teams.ConfiguredRecord; mkws.init('Click select', '#mkwsCurrentRecordContainer'); return false;">
<b>{{md-title}}</b>
</a>
{{#if md-title-remainder}}
--- /dev/null
+<span>Current selection: {{md-title}}</span>
$(element).find('.save-button').bind('click', function() {
var handlerUrl = runtime.handlerUrl(element, 'update_settings');
var data = {
- query: $(element).find('#mkwsCurrentRecord').attr('autosearch')
+ query: mkws.teams["BlockConfig"].query(),
+ recid: $(element).find('#mkwsCurrentRecord').attr('data-mkws-recid')
};
$.post(handlerUrl, JSON.stringify(data)).done(function(response) {
window.location.reload(false);
+ return false;
});
});
$(element).find('.cancel-button').bind('click', function() {
runtime.notify('cancel', {});
+ return false;
});
-};
+}
window.mkws_noready = true;
require.config({
paths: {
- mkws: "//mkws.local/mkws-complete",
+ //mkws: "//mkws.local/mkws-complete",
+ mkws: "//mkws.indexdata.com/mkws-compl-tmpl",
},
shim: {
mkws: {