Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

getting the score via javascript

New Here ,
Nov 16, 2017 Nov 16, 2017

I did some testing and it seems that if I add this to module 1

window.cpAPIInterface.setVariableValue( SCORM_CallLMSSetValue('cmi.comments', "yes"));

then in module 2

mycom= SCORM_CallLMSGetValue('cmi.comments')

No value is returned.

It does work for module 2 if i do this

window.cpAPIInterface.setVariableValue( SCORM_CallLMSSetValue('cmi.comments', "yes"));

mycom= SCORM_CallLMSGetValue('cmi.comments') Returns "yes"

The question is how can i get data from other modules, cmi.core.score.raw does the same returns no value unless is generated from the same module

I thought this data would be available to all modules once it was added to the moodle database

 

Thanks

 

MM

428
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Nov 16, 2017 Nov 16, 2017

HI Mike,

You would have to store the value in local storage first, then retrieve it from local storage in the second SCO using JavaScript.  The whole idea behind SCORM and SCOs is that they are self-contained shareable objects... meaning they can be reused in multiple courses if you wanted.  The downside to their being self-contained, is that they don't share data.  You would need to persist the data either through local storage or by making a call to the database in order to retrieve it.  JavaSc

...
Translate
Advisor ,
Nov 16, 2017 Nov 16, 2017

HI Mike,

You would have to store the value in local storage first, then retrieve it from local storage in the second SCO using JavaScript.  The whole idea behind SCORM and SCOs is that they are self-contained shareable objects... meaning they can be reused in multiple courses if you wanted.  The downside to their being self-contained, is that they don't share data.  You would need to persist the data either through local storage or by making a call to the database in order to retrieve it.  JavaScript's local storage would be the perfect solution for this.  Just know that there are limitations: Web storage is per origin (per domain and protocol). All pages, from one origin, can store and access the same data..  If the user resumes the course using a different browser than when they started, the storage won't be there.

Best,

Jim Leichliter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2017 Nov 16, 2017

Thanks Jim,

I was able to grab student ID cmi.core.student_id from the moodle database fro any module in the course so i guess some of the info is not just local to the SCO.  I hoped to be able to grab the course data in the moodle gradebook, but it looks like that's not possible

 

thanks

 

MM

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Nov 16, 2017 Nov 16, 2017
LATEST

Hi Mike,

That's not impossible.  You can make an JavaScript Ajax call to the database to pull the data.  You would need to supply some info to the database in order to query the correct data.  It would be more complex, but possible.  You would most likely need to hire a developer for this.

Best,

Jim Leichliter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources