Changeset 1702

Show
Ignore:
Timestamp:
03/19/10 19:32:38 (6 months ago)
Author:
sam
Message:

Fin refonte annotSvc.uiservice - correction #416

Location:
trunk/model/sources/academic/gen/_scorm
Files:
1 added
1 removed
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/model/sources/academic/gen/_scorm/svc/annotSvc.doss/annotSvc.js

    r1701 r1702  
    2222 * Contributor(s): 
    2323 * samuel.monsarrat@kelis.fr 
     24 * 
    2425 * 
    2526 * Alternatively, the contents of this file may be used under the terms of 
     
    4748getAnnot(pId) 
    4849 
     50hasAnnot(pId) 
     51 
    4952*/ 
    5053 
    5154//Instanciation du service 
    5255scServices.annotSvc = scOnLoads[scOnLoads.length] = { 
    53  
    54 isActive : function(){return this._isActive}, 
    55  
    56 _isActive : false, 
    57 onLoad: function(){ 
    58         if(scServices.scorm2k4 && scServices.scorm2k4.isScorm2k4Active()) { 
    59                 this._isActive = true; 
    60                 var vApi = scServices.scorm2k4.getScorm2k4API(); 
    61                 var vCount = vApi.GetValue("cmi.comments_from_learner._count"); 
    62                 this._annotMap = {}; 
    63                 for(var i = 0; i < vCount; i++) this._annotMap[vApi.GetValue("cmi.comments_from_learner."+i+".location")] = i; 
    64                 this.getAnnot = function(pId){ 
     56        _isActive : false, 
     57        isActive : function(){return this._isActive}, 
     58        onLoad: function(){ 
     59                if(scServices.scorm2k4 && scServices.scorm2k4.isScorm2k4Active()) { 
     60                        this._isActive = true; 
    6561                        var vApi = scServices.scorm2k4.getScorm2k4API(); 
    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" 
    100121}; 
  • trunk/model/sources/academic/gen/_scorm/widg/annotBtn.uiwidget

    r1701 r1702  
    88                &lt;xsl:value-of select="execute(java:ensureIdOnCurrentResultElt($vDialog))"/&gt; 
    99        &lt;/xsl:overlay&gt;</sm:postXslFragment> 
    10                 <sm:linkScript path="annot.js" pathFrom="localPublishFiles" sortKey="annot"/> 
     10                <sm:linkScript path="annotMgr.js" pathFrom="localPublishFiles" sortKey="annot"/> 
    1111        </sm:fillTemplateBuffers> 
    1212        <sm:content> 
    1313                <span xmlns="http://www.w3.org/1999/xhtml" id="annotBtn"> 
    14                         <a href="#" onclick="annot.toggleEditMode(this); return false;"> 
     14                        <a href="#" onclick="annotMgr.toggleEditMode(this); return false;"> 
    1515                                <span>;Annotations</span> 
    1616                        </a>