Skip to content

Commit

Permalink
Handle custom mount points
Browse files Browse the repository at this point in the history
  • Loading branch information
paresharma committed Mar 26, 2015
1 parent 1998635 commit 0c4543c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 39 deletions.
47 changes: 10 additions & 37 deletions app/assets/javascripts/scorm_rte/rte.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ function LMSAPI(){
this.cache = {};
// Defined in the LMS, must unique for each instance
this.SCOInstanceID = '';
this.fetchUrl = '/scorm_rte/fetch';
this.createUrl = '/scorm_rte';

// 1.2
this.LMSInitialize=LMSInitialize;
Expand All @@ -18,7 +20,7 @@ function LMSAPI(){
this.GetValue=LMSGetValue;
this.SetValue=LMSSetValue;
this.Commit=LMSCommit;
this.Treminate=LMSFinish;
this.Terminate=LMSFinish;
this.GetLastError=LMSGetLastError;
this.GetDiagnostic=LMSGetDiagnostic;
this.GetErrorString=LMSGetErrorString;
Expand All @@ -36,11 +38,7 @@ function LMSAPI(){
// SCORM RTE Functions - Initialization
// ------------------------------------------
function LMSInitialize(dummyString) {
console.log('***');
console.log('initialized');
console.log(this.cache);

var url = '/scorm_rte/stores/fetch?sco_instance_id='+this.SCOInstanceID;
var url = this.fetchUrl+'?sco_instance_id='+this.SCOInstanceID;
var tempCache = {};

$.ajax({
Expand All @@ -51,11 +49,6 @@ function LMSAPI(){
}).done(function( data ) {
tempCache = data;
});

// this.cache = JSON.parse(localStorage.getItem('k')) || {}
this.cache = tempCache;
console.log(this.cache);
console.log('***');
return "true";
}

Expand Down Expand Up @@ -86,7 +79,7 @@ function LMSAPI(){
});

// submit to the server for processing
var url = "/scorm_rte/stores"
var url = this.createUrl;
$.ajax({
type: "POST",
headers: {
Expand All @@ -99,16 +92,6 @@ function LMSAPI(){
data: params
});

// process returned data - error condition
// if (req.status != 200) {
// alert('Problem with AJAX Request in LMSCommit()');
// return "false";
// }

// process returned data - OK
// else {
// return "true";
// }
return "true";
}

Expand All @@ -123,21 +106,12 @@ function LMSAPI(){
}

// commit cached values to the database
console.log('!! finish')

// console.log('***')
// console.log(localStorage.getItem('k'))
// localStorage.setItem('k', JSON.stringify(this.cache))
console.log(this.cache)
// console.log(JSON.parse(localStorage.getItem('k')))
// console.log('###')

LMSCommit('');
console.log('!! finish !!')
/*

/*
// set up request parameters - uses GET method
req.open('GET','finish.php?SCOInstanceID=<?php print $SCOInstanceID; ?>&code='+d.getTime(),false);
req.open('GET','finish?SCOInstanceID='+this.SCOInstanceID+'&code='+d.getTime(),false);
// submit to the server for processing
req.send(null);
Expand All @@ -148,7 +122,7 @@ function LMSAPI(){
return "";
}
*/
*/
// set finish flag
flagFinished = true;
// return to calling program
Expand Down Expand Up @@ -269,5 +243,4 @@ function LMSAPI(){

}

window.API = new LMSAPI();
window.API_1484_11 = new LMSAPI();
window.API = window.API_1484_11 = new LMSAPI();
5 changes: 3 additions & 2 deletions lib/scorm_rte/lms/controllers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def assign_sco_instance_id(sco_instance_id = nil)
def update_response
return unless @_sco
txt = "<script type='text/javascript'>" \
"window.API.SCOInstanceID='#{@_sco.sco_instance_id}';" \
"window.API_1484_11.SCOInstanceID='#{@_sco.sco_instance_id}';" \
"window.API.SCOInstanceID='#{@_sco.sco_instance_id}';" \
"window.API.fetchUrl='#{scorm_rte.fetch_stores_url}';" \
"window.API.createUrl='#{scorm_rte.stores_url}';" \
'</script>'
response.body += txt
end
Expand Down

0 comments on commit 0c4543c

Please sign in to comment.