| 66 | | if(pId in this._annotMap) return vApi.GetValue("cmi.comments_from_learner."+this._annotMap[pId]+".comment"); |
| 67 | | return null; |
| 68 | | }; |
| 69 | | this.setAnnot = function(pId, pAnnot){ |
| 70 | | var vApi = scServices.scorm2k4.getScorm2k4API(); |
| 71 | | if(pId in this._annotMap) { |
| 72 | | vApi.SetValue("cmi.comments_from_learner."+this._annotMap[pId]+".comment", pAnnot); |
| 73 | | vApi.Commit(""); |
| 74 | | } else { |
| 75 | | var vIdx = vApi.GetValue("cmi.comments_from_learner._count"); |
| 76 | | vApi.SetValue("cmi.comments_from_learner."+vIdx+".location", pId); |
| 77 | | vApi.SetValue("cmi.comments_from_learner."+vIdx+".comment", pAnnot); |
| 78 | | this._annotMap[pId] = vIdx; |
| 79 | | vApi.Commit(""); |
| 80 | | } |
| 81 | | }; |
| 82 | | } else if(scServices.storage && scServices.storage.isStorageActive()) { |
| 83 | | this._isActive = true; |
| 84 | | this.getAnnot = function(pId){ |
| 85 | | var vItem = scServices.storage.getStorage().getItem(scServices.storage.getRootKey()+"annot/"+pId); |
| 86 | | return vItem ? vItem.value : null; |
| 87 | | }; |
| 88 | | this.setAnnot = function(pId, pAnnot){ |
| 89 | | scServices.storage.getStorage().setItem(scServices.storage.getRootKey()+"annot/"+pId, pAnnot); |
| 90 | | }; |
| 91 | | } else { |
| 92 | | //Pour tests : mettre this._isActive = true; |
| 93 | | this._isActive = false; |
| 94 | | this._annot = {}; |
| 95 | | this.getAnnot = function(pId){return this._annot[pId] || "";}; |
| 96 | | this.setAnnot = function(pId, pAnnot){this._annot[pId] = pAnnot;}; |
| 97 | | } |
| 98 | | }, |
| 99 | | loadSortKey: "2annotSvc" |
| | 62 | var vCount = vApi.GetValue("cmi.comments_from_learner._count"); |
| | 63 | this._annotMap = {}; |
| | 64 | for(var i = 0; i < vCount; i++) this._annotMap[vApi.GetValue("cmi.comments_from_learner."+i+".location")] = i; |
| | 65 | this.getAnnot = function(pId){ |
| | 66 | var vApi = scServices.scorm2k4.getScorm2k4API(); |
| | 67 | if(pId in this._annotMap) return vApi.GetValue("cmi.comments_from_learner."+this._annotMap[pId]+".comment"); |
| | 68 | return null; |
| | 69 | }; |
| | 70 | this.setAnnot = function(pId, pAnnot){ |
| | 71 | var vApi = scServices.scorm2k4.getScorm2k4API(); |
| | 72 | if(pId in this._annotMap) { |
| | 73 | vApi.SetValue("cmi.comments_from_learner."+this._annotMap[pId]+".comment", pAnnot); |
| | 74 | vApi.Commit(""); |
| | 75 | } else { |
| | 76 | var vIdx = vApi.GetValue("cmi.comments_from_learner._count"); |
| | 77 | vApi.SetValue("cmi.comments_from_learner."+vIdx+".location", pId); |
| | 78 | vApi.SetValue("cmi.comments_from_learner."+vIdx+".comment", pAnnot); |
| | 79 | this._annotMap[pId] = vIdx; |
| | 80 | vApi.Commit(""); |
| | 81 | } |
| | 82 | }; |
| | 83 | this.hasAnnot = function(pId){if (pId in this._annotMap) return true;return false;}; |
| | 84 | } else if(scServices.scorm12 && scServices.scorm12.isScorm12Active()) { |
| | 85 | this._isActive = true; |
| | 86 | var vApi = scServices.scorm12.getScorm12API(); |
| | 87 | try { |
| | 88 | var vComments = vApi.LMSGetValue("cmi.comments"); |
| | 89 | this._annot = scServices.dataUtil.deserialiseObjJs(vApi.LMSGetValue("cmi.comments")); |
| | 90 | } catch(e){alert("WARNING : an error occured while retreiving student annotations.")} |
| | 91 | if (!this._annot) this._annot = {}; |
| | 92 | this.getAnnot = function(pId){return this._annot[pId] || "";}; |
| | 93 | this.setAnnot = function(pId, pAnnot){ |
| | 94 | var vApi = scServices.scorm12.getScorm12API(); |
| | 95 | this._annot[pId] = pAnnot; |
| | 96 | vApi.LMSSetValue("cmi.comments", scServices.dataUtil.serialiseObjJs(this._annot)); |
| | 97 | vApi.LMSCommit(""); |
| | 98 | }; |
| | 99 | this.hasAnnot = function(pId){if (pId in this._annot) return true;return false;}; |
| | 100 | this.getAnnotLength = function(){return scServices.dataUtil.serialiseObjJs(this._annot).length;}; |
| | 101 | } else if(scServices.storage && scServices.storage.isStorageActive()) { |
| | 102 | this._isActive = true; |
| | 103 | this.getAnnot = function(pId){ |
| | 104 | var vItem = scServices.storage.getStorage().getItem(scServices.storage.getRootKey()+"annot/"+pId); |
| | 105 | return vItem ? vItem : null; |
| | 106 | }; |
| | 107 | this.setAnnot = function(pId, pAnnot){ |
| | 108 | scServices.storage.getStorage().setItem(scServices.storage.getRootKey()+"annot/"+pId, pAnnot); |
| | 109 | }; |
| | 110 | this.hasAnnot = function(pId){if (pId in this._annot) return true;return false;}; |
| | 111 | } else { |
| | 112 | //Pour tests : mettre this._isActive = true; |
| | 113 | this._isActive = false; |
| | 114 | this._annot = {}; |
| | 115 | this.getAnnot = function(pId){return this._annot[pId] || null;}; |
| | 116 | this.setAnnot = function(pId, pAnnot){this._annot[pId] = pAnnot;}; |
| | 117 | this.hasAnnot = function(pId){if (pId in this._annot) return true;return false;}; |
| | 118 | } |
| | 119 | }, |
| | 120 | loadSortKey: "2annotSvc" |