scorm_rte 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bb780785b97d90c0408d11de967506672e3d597
4
- data.tar.gz: 15bbec31e4226cb4ab20e61b02df147f11d39184
3
+ metadata.gz: 65d704e82b98e684e3cf31d79aec8c84722171d9
4
+ data.tar.gz: 9b562fd53dc6bbe44fc08867d837014b9b7d5b5c
5
5
  SHA512:
6
- metadata.gz: 3f515d3ed598d347a69554e6b21e7ed0bf19d999b373a111527971dc4dc40f3aba092d4d3b6cdd4b89a8cd4504490a418d95217ef306d193acff0aef31cd7b0c
7
- data.tar.gz: 14db5fc9ef4ab97841c1bc3b74e068b324e0da81a151e153cc45186411956763ee1ff18396d3262def71f57ade3994c32f4f419d1a1edfa16a317763d75d2d91
6
+ metadata.gz: 4cac62a1e7e019a7886c5052ec674fe0f11ba9856e1951a7f2a94c6b0f0cbd14f8eb0d6eb7cc62ce5dfb13f6576af72992671e72d9b5e23cc10c5d3d231276c1
7
+ data.tar.gz: d3fe5f4fcfbef196749be7cae7a391f29f042ce376cee0f8e1a0b6e8aefa3f4d1c37c2ef4028b2ec345b47abe514e96af4964da39fef02d5211ef2deac3ffc03
@@ -1,6 +1,7 @@
1
1
  function LMSAPI(){
2
2
  this.cache = {};
3
- this.SCOInstanceID = 123456789;
3
+ // Defined in the LMS, must unique for each instance
4
+ this.SCOInstanceID = '';
4
5
 
5
6
  // 1.2
6
7
  this.LMSInitialize=LMSInitialize;
@@ -39,12 +40,13 @@ function LMSAPI(){
39
40
  console.log('initialized');
40
41
  console.log(this.cache);
41
42
 
42
- var url = 'http://localhost:3000/scorm_rte/stores/fetch?sco_instance_id='+this.SCOInstanceID;
43
+ var url = '/scorm_rte/stores/fetch?sco_instance_id='+this.SCOInstanceID;
43
44
  var tempCache = {};
44
45
 
45
46
  $.ajax({
46
47
  url: url,
47
48
  dataType: 'json',
49
+ cache: false,
48
50
  async: false
49
51
  }).done(function( data ) {
50
52
  tempCache = data;
@@ -61,7 +63,6 @@ function LMSAPI(){
61
63
  // SCORM RTE Functions - Getting and Setting Values
62
64
  // ------------------------------------------
63
65
  function LMSGetValue(varname) {
64
- //alert(this.cache[varname]);
65
66
  var v = this.cache[varname];
66
67
  if(v == undefined){
67
68
  v = ""
@@ -78,22 +79,14 @@ function LMSAPI(){
78
79
  // SCORM RTE Functions - Saving the Cache to the Database
79
80
  // ------------------------------------------
80
81
  function LMSCommit(dummyString) {
81
- // code to prevent caching
82
- var d = new Date();
83
-
84
-
85
82
  // create a POST-formatted list of cached data elements
86
- // include only SCO-writeable data elements
87
- var params = 'scorm_rte_store[sco_instance_id]='+this.SCOInstanceID+'&code='+d.getTime();
88
- params += "&scorm_rte_store[data][cmi.core.lesson_location]="+urlencode(this.cache['cmi.core.lesson_location']);
89
- params += "&scorm_rte_store[data][cmi.core.lesson_status]="+urlencode(this.cache['cmi.core.lesson_status']);
90
- params += "&scorm_rte_store[data][cmi.core.exit]="+urlencode(this.cache['cmi.core.exit']);
91
- params += "&scorm_rte_store[data][cmi.core.session_time]="+urlencode(this.cache['cmi.core.session_time']);
92
- params += "&scorm_rte_store[data][cmi.core.score.raw]="+urlencode(this.cache['cmi.core.score.raw']);
93
- params += "&scorm_rte_store[data][cmi.suspend_data]="+urlencode(this.cache['cmi.suspend_data']);
83
+ var params = 'scorm_rte_store[sco_instance_id]='+this.SCOInstanceID;
84
+ $.each( this.cache, function( key, value ) {
85
+ params += '&scorm_rte_store[data]['+key+']='+urlencode(value);
86
+ });
94
87
 
95
88
  // submit to the server for processing
96
- var url = "http://localhost:3000/scorm_rte/stores"
89
+ var url = "/scorm_rte/stores"
97
90
  $.ajax({
98
91
  type: "POST",
99
92
  headers: {
@@ -102,6 +95,7 @@ function LMSAPI(){
102
95
  'Connection' : 'close'
103
96
  },
104
97
  url: url,
98
+ cache: false,
105
99
  data: params
106
100
  });
107
101
 
@@ -129,23 +123,18 @@ function LMSAPI(){
129
123
  }
130
124
 
131
125
  // commit cached values to the database
132
- console.log('!! finish')
126
+ console.log('!! finish')
133
127
 
134
- // console.log('***')
135
- // console.log(localStorage.getItem('k'))
136
- // localStorage.setItem('k', JSON.stringify(this.cache))
137
- console.log(this.cache)
138
- // console.log(JSON.parse(localStorage.getItem('k')))
139
- // console.log('###')
128
+ // console.log('***')
129
+ // console.log(localStorage.getItem('k'))
130
+ // localStorage.setItem('k', JSON.stringify(this.cache))
131
+ console.log(this.cache)
132
+ // console.log(JSON.parse(localStorage.getItem('k')))
133
+ // console.log('###')
140
134
 
141
- LMSCommit('');
142
- console.log('!! finish !!')
135
+ LMSCommit('');
136
+ console.log('!! finish !!')
143
137
  /*
144
- // create request object
145
- var req = createRequest();
146
-
147
- // code to prevent caching
148
- var d = new Date();
149
138
 
150
139
  // set up request parameters - uses GET method
151
140
  req.open('GET','finish.php?SCOInstanceID=<?php print $SCOInstanceID; ?>&code='+d.getTime(),false);
@@ -164,7 +153,6 @@ function LMSAPI(){
164
153
  flagFinished = true;
165
154
  // return to calling program
166
155
  return "true";
167
-
168
156
  }
169
157
 
170
158
  // ------------------------------------------
@@ -265,7 +253,7 @@ function LMSAPI(){
265
253
  histogram['\u017E'] = '%9E';
266
254
  histogram['\u0178'] = '%9F';
267
255
 
268
- // Begin with encodeURIComponent, which most resembles PHP's encoding functions
256
+ // Begin with encodeURIComponent
269
257
  ret = encodeURIComponent(ret);
270
258
 
271
259
  for (unicodeStr in histogram) {
@@ -273,7 +261,7 @@ function LMSAPI(){
273
261
  ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
274
262
  }
275
263
 
276
- // Uppercase for full PHP compatibility
264
+ // Uppercase
277
265
  return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
278
266
  return "%"+m2.toUpperCase();
279
267
  });
@@ -1,3 +1,3 @@
1
1
  module ScormRte
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scorm_rte
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - paresharma
@@ -48,7 +48,7 @@ files:
48
48
  - MIT-LICENSE
49
49
  - Rakefile
50
50
  - app/assets/javascripts/scorm_rte/application.js
51
- - app/assets/javascripts/scorm_rte/rte.js
51
+ - app/assets/javascripts/scorm_rte/rte.js.erb
52
52
  - app/assets/stylesheets/scorm_rte/application.css
53
53
  - app/controllers/scorm_rte/application_controller.rb
54
54
  - app/controllers/scorm_rte/stores_controller.rb