Commit 4df122a9 by Calen Pennington

Update annotations modules to use the course_id from the runtime, rather than…

Update annotations modules to use the course_id from the runtime, rather than extracting it from the page
parent 2ce67191
......@@ -81,6 +81,7 @@ class TextAnnotationModule(AnnotatableFields, XModule):
def get_html(self):
""" Renders parameters to template. """
context = {
'course_id': self.runtime.course_id,
'display_name': self.display_name_with_default,
'tag': self.tags,
'source': self.source,
......
......@@ -149,6 +149,7 @@ class VideoAnnotationModule(AnnotatableFields, XModule):
extension = self._get_extension(self.sourceurl)
context = {
'course_id': self.runtime.course_id,
'display_name': self.display_name_with_default,
'instructions_html': self.instructions,
'sourceUrl': self.sourceurl,
......
......@@ -43,17 +43,14 @@
$(this).parents('.annotatable-section:first').find('.annotatable-instructions')[slideMethod]();
}
$('.annotatable-toggle-instructions').on('click', onClickHideInstructions);
//Grab uri of the course
var parts = window.location.href.split("/"),
var parts = window.location.href.split("/"),
uri = '',
courseid;
for (var index = 0; index <= 9; index += 1) uri += parts[index]+"/"; //Get the unit url
courseid = parts[4] + "/" + parts[5] + "/" + parts[6];
//Change uri in cms
var lms_location = $('.sidebar .preview-button').attr('href');
if (typeof lms_location!='undefined'){
courseid = parts[4].split(".").join("/");
uri = window.location.protocol;
for (var index = 0; index <= 9; index += 1) uri += lms_location.split("/")[index]+"/"; //Get the unit url
}
......@@ -63,16 +60,16 @@
optionsAnnotator: {
permissions:{
user: {
id:"${user.email}",
id:"${user.email}",
name:"${user.username}"
},
userString: function (user) {
if (user && user.name)
if (user && user.name)
return user.name;
return user;
},
userId: function (user) {
if (user && user.id)
if (user && user.id)
return user.id;
return user;
},
......@@ -96,7 +93,7 @@
}
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
if (this.userId(user) === token) {
return true;
......@@ -115,7 +112,7 @@
},
},
auth: {
tokenUrl: location.protocol+'//'+location.host+"/token?course_id="+courseid
tokenUrl: location.protocol+'//'+location.host+"/token?course_id=${course_id.to_deprecated_string()}"
},
store: {
// The endpoint of the store on your server.
......@@ -161,11 +158,11 @@
}
},
};
var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/";
tinyMCE.baseURL = "${settings.STATIC_URL}" + "js/vendor/ova";
//remove old instances
if (Annotator._instances.length !== 0) {
$('#textHolder').annotator("destroy");
......@@ -173,8 +170,8 @@
delete ova;
//Load the plugin Video/Text Annotation
var ova = new OpenVideoAnnotation.Annotator($('#textHolder'),options);
//Catch
var annotator = ova.annotator,
catchOptions = {
......
......@@ -23,14 +23,14 @@
<video id="vid1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264" poster="${poster}">
<source src="${sourceUrl}" type='${typeSource}' />
</video>
</div>
</div>
<div id="catchDIV">
<div class="annotationListContainer">${_('You do not have any notes.')}</div>
</div>
</div>
</div>
</div>
<script>
function onClickHideInstructions(){
......@@ -46,37 +46,34 @@
$(this).parents('.annotatable-section:first').find('.annotatable-instructions')[slideMethod]();
}
$('.annotatable-toggle-instructions').on('click', onClickHideInstructions);
//Grab uri of the course
var parts = window.location.href.split("/"),
var parts = window.location.href.split("/"),
uri = '',
courseid;
for (var index = 0; index <= 9; index += 1) uri += parts[index]+"/"; //Get the unit url
courseid = parts[4] + "/" + parts[5] + "/" + parts[6];
//Change uri in cms
var lms_location = $('.sidebar .preview-button').attr('href');
if (typeof lms_location!='undefined'){
courseid = parts[4].split(".").join("/");
uri = window.location.protocol;
for (var index = 0; index <= 9; index += 1) uri += lms_location.split("/")[index]+"/"; //Get the unit url
}
var pagination = 100,
is_staff = !('${user.is_staff}'=='False'),
options = {
optionsAnnotator: {
permissions:{
user: {
id:"${user.email}",
id:"${user.email}",
name:"${user.username}"
},
userString: function (user) {
if (user && user.name)
if (user && user.name)
return user.name;
return user;
},
userId: function (user) {
if (user && user.id)
if (user && user.id)
return user.id;
return user;
},
......@@ -100,7 +97,7 @@
}
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
if (this.userId(user) === token) {
return true;
......@@ -119,7 +116,7 @@
},
},
auth: {
tokenUrl: location.protocol+'//'+location.host+"/token?course_id="+courseid
tokenUrl: location.protocol+'//'+location.host+"/token?course_id=${course_id.to_deprecated_string()}"
},
store: {
// The endpoint of the store on your server.
......@@ -162,10 +159,10 @@
}
},
};
var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/";
tinyMCE.baseURL = "${settings.STATIC_URL}" + "js/vendor/ova";
//remove old instances
if (Annotator._instances.length !== 0) {
$('#videoHolder').annotator("destroy");
......@@ -173,11 +170,11 @@
delete ova;
//Load the plugin Video/Text Annotation
var ova = new OpenVideoAnnotation.Annotator($('#videoHolder'),options);
ova.annotator.addPlugin('Tags');
//Catch
var annotator = ova.annotator,
catchOptions = {
......
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