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