I need to save all the information entered by the user on the interface to the database
What interface? What database? Are you talking about the authoring tool? If so, what version?
The offlineStorage
API is there to allow a course to save data to the LMS (or LRS).
So, the purpose of the authoring tool is to allow a content author to create courses without having to know how to edit JSON or apply HTML formatting. You can also preview the course from the authoring tool so that you can check that it looks right before publishing and uploading it to wherever you normally host your elearning courses - typically a SCORM Learning Management System (LMS).
The authoring tool should not be used to allow learners to access and run the courses. You should always publish them and host them elsewhere.
The reason you are seeing the 'undefined' value is because the adapt authoring tool is NOT a SCORM Learning Management System. If you upload this course to an actual LMS that has support for cmi.interactions you will see a number instead of undefined
, like this:
However, the course only ever has 'write' access to these data fields, it will not be allowed to read data from them. Only the LMS itself can do that.
you can find out more about SCORM here https://scorm.com/scorm-explained/technical-scorm/
If the course is running on an LMS that has support for cmi.interactions
then you might be able to get that data from the LMS.
You can't fetch data from cmi.interactions
from the course because these SCORM data fields are 'write only' so the course can only write data to them, it can't read that data back in again.
If you can't do this on the LMS then I can't think of a way of doing it without some form of customisation, such as writing an extension that listens out for the learner answering this particular question then querying the component for the data.
Here's a very simple example of how you'd query the component for the data via the browser console, after answering the textInput component in the Adapt v5 demo.
Because I found that every time the authoring tool started, it will generate a random ID
Are you sure it's doing that? I really hope it's not as, if it is, that is potentially a very serious bug. What version of the authoring tool are you using?
The version of authoring tool I'm using now is 0.10.3, and adapt framework v5.3.0. And I'm not sure if there is some problem with my operation.
And every time I start adapt framework through the node server, it will generate a different id after repeating the above operations
It really shouldn't be doing that. Definitely not doing that on the many instances of the AAT we host here at Kineo. We would definitely notice something like that as it would break almost all courses every time we restarted the AAT servers.