source: hotpotatoes/trunk/fuentes/javahotpot/source/fjmatch6.js_ @ 201

Last change on this file since 201 was 201, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 3.0 KB
Line 
1
2[inclScorm1.2]
3//JMATCH-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
4
5function SetScormBrowseTime(){
6if (API != null){
7                API.LMSSetValue('cmi.core.session_time', MillisecondsToTime((new Date()).getTime() - ScormStartTime));
8                API.LMSCommit('');
9        }
10}
11[/inclScorm1.2]
12
13//JMATCH-SPECIFIC CORE JAVASCRIPT CODE
14
15var CurrItem = null;
16var Stage = 2;
17var QList = new Array();
18var ShuffleQs = [boolShuffleQs];
19       
20function SetUpItems(){
21
22        var i;
23        var Row = null;
24
25//Remove all the table rows and put them in an array for processing
26        var Qs = document.getElementById('Questions');
27
28//Remove the table rows to an array
29        while (Qs.getElementsByTagName('tr').length > 0){
30                Row = Qs.getElementsByTagName('tr')[0];
31                Row.getElementsByTagName('td')[0].className = 'Hidden';
32                Row.getElementsByTagName('td')[1].className = 'Hidden';
33                QList.push(Qs.removeChild(Row));
34        }
35       
36//Shuffle the rows
37        if (ShuffleQs == true){
38                QList = Shuffle(QList);
39        }
40
41//Write the rows back to the table body
42        for (i=0; i<QList.length; i++){
43                Qs.appendChild(QList[i]);
44        }
45}
46
47function StartUp(){
48
49        SetUpItems();
50       
51[inclScorm1.2]
52        initAPI(window);
53        if (API != null){
54                API.LMSInitialize('');
55                API.LMSSetValue('cmi.core.lesson_status', 'browsed');
56                API.LMSSetValue('cmi.comments', 'This exercise has no checking or scoring features.');
57                API.LMSCommit('');
58        }
59[/inclScorm1.2]
60
61
62[inclPreloadImages]
63        PreloadImages([PreloadImageList]);
64[/inclPreloadImages]
65
66[inclPreloadImages]
67        RefreshImages();
68[/inclPreloadImages]
69}
70
71var Started = false;
72
73function DeleteItem(){
74        if ((CurrItem == null)||(document.getElementById('Questions').getElementsByTagName('tr').length < 1)){return;}
75       
76//Delete the current item
77        var DelItem = CurrItem;
78        Stage = 2;
79        ShowItem();
80        document.getElementById('Questions').removeChild(DelItem);
81}
82
83function ShowItem(){
84        var Qs = document.getElementById('Questions');
85
86        var Len = Qs.getElementsByTagName('tr').length;
87
88//Bail if no more items
89        if (Len < 1){
90                return;
91        }
92       
93//if no current item, get the last item so we roll forward
94        if (CurrItem == null){
95                CurrItem = Qs.getElementsByTagName('tr')[Len-1];
96                if (CurrItem == null){
97                        return;
98                }
99        }
100       
101//if CurrItem has been fully shown, move to the next one
102        if (Stage == 2){
103                CurrItem.getElementsByTagName('td')[0].className = 'Hidden';
104                CurrItem.getElementsByTagName('td')[1].className = 'Hidden';
105                if (CurrItem.nextSibling != null){
106                        CurrItem = CurrItem.nextSibling;
107                }
108                else{
109                        CurrItem = Qs.getElementsByTagName('tr')[0];
110                }
111        }
112       
113//Show the appropriate bits
114        if (Stage == 2){
115//Show the first item and hide the second
116                CurrItem.getElementsByTagName('td')[0].className = 'Showing';
117                CurrItem.getElementsByTagName('td')[1].className = 'Hidden';
118                Stage = 1;
119        }
120        else{
121//Show both items
122                CurrItem.getElementsByTagName('td')[0].className = 'Showing';
123                CurrItem.getElementsByTagName('td')[1].className = 'Showing';
124                Stage = 2;             
125        }
126       
127[inclPreloadImages]
128        RefreshImages();
129[/inclPreloadImages]
130}
131
Note: See TracBrowser for help on using the repository browser.