Get Sco-title (or scold or course id or ...) with javascript or php

Get Sco-title (or scold or course id or ...) with javascript or php

by Dagwin Roelants -
Number of replies: 2

Hello everybody,

I have over 150 almost identical Sco's who are only different in one variable.

If I manage to get the name  of the Sco or the name of the course in Javascript, I can take the variable from the name of the Sco and have only one Sco for all 150 exercises.

Something similar as:

courseID = doLMSGetValue("cmi.core.student_name");  (works fine and gives me the student name)

except student_name should be course_name or scold or something else that is specific for that sco or course as there is only one Sco for every course.

Someone who knows how to do this can make me very happy.

kind regards 

Dagwin


Average of ratings: -
In reply to Dagwin Roelants

Re: Get Sco-title (or scold or course id or ...) with javascript or php

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

you could try using JS to get the url of the parent frame which might in some cases include the SCOID - but probably not reliably as often the page will open from a POST request rather than a simple GET.

I'd be tempted to look at "Selecting an imsmanifest.xml from an unzipped SCORM in a file system repository." on: http://danmarsden.com/blog/2013/09/24/managing-scorm-content-in-moodle-2-6/

Then you just create an imsmanfiest file for each scorm but re-use the same content for each manifest file.

In reply to Dan Marsden

Re: Get Sco-title (or scold or course id or ...) with javascript or php

by Dagwin Roelants -

Hi Dan, 

Thanks for responding.

I did exactly what you proposed.

  1. set the dataFromLms element in the IMSManifest.xml
  2. add: var variable_from_other_JS = doLMSGetValue("cmi.launch_data") as parameter to be passed to the php database Query to the SCO
  3. add external scorm manifest
  4. Update scorm
Works as expected. => GREAT

I also looked in to get the scold from the url but as the courses are on several moodle sites, it is just a matter of time before the scoid's are not identical anymore in all these sites. (sco Title will be 100% controllable)

However, it is kind of frustrating that the perfect search key can be on the page itself.

If in ADMINISTRATION/SCORM package administration/Edit settings/Appearance the "Display Activity Name" is checked, this value is in the scormplayer in the upper left corner. (see attachment or follow link: Manifest on Test Site 8)

I keep on dreaming to get this value in to my SCO. It will reduce my work with a factor 150.

BTW 

Do you have any idea where the LaunchData is stored in the DB.

Maybe it is possible to make a little script to manipulate the DB and copy the Activity Name to the launchdata field.

Attachment Schermafbeelding 2018-02-18 om 16.18.27.png