?? interactionclass.js
字號:
// Copyright 1998,1999 Macromedia, Inc. All rights reserved.
// Localization strings
var TRACK_system_not_found = "Tracking system not found.";
//Constructs an Interaction
function MM_interaction(theSelf,
theJudgeOnSel, theAllowMultiSel, theAllThatApply, theUnknownIsCorrect,
theDisabled, theTriesLimit, theTimeLimit,
theTrackIntId, theTrackObjectiveId,
theTrackQType,theTrackWeight, theKTrack) {
// properties
this.judgeOnSel = theJudgeOnSel;
this.allowMultiSel = theAllowMultiSel;
this.allThatApply = theAllThatApply;
this.unknownIsCorrect = theUnknownIsCorrect;
this.disabled = theDisabled;
this.tries = 0;
this.triesLimit = (theTriesLimit)?theTriesLimit:0;
this.triesAtLimit = false;
this.time = 0;
this.timeLeft = 0;
this.timeLimit = (theTimeLimit)?theTimeLimit:0;
this.timeAtLimit = false;
this.trackIntId = theTrackIntId;
this.trackObjectiveId = theTrackObjectiveId;
this.trackQType = theTrackQType;
this.trackWeight = theTrackWeight;
this.knowledgeTrack = theKTrack;
this.totalElems = 0;
this.possCorrect = 0;
this.possIncorrect = 0;
this.knownResponse = false;
this.totalCorrect = 0;
this.totalIncorrect = 0;
this.correct = false;
this.score = 0;
this._self = theSelf;
this._timeStart = 0;
this._timerID = 0;
this.browserIsNS = (navigator.appName.indexOf('Netscape') != -1);
this.browserIsIE = (navigator.appName.indexOf('Microsoft') != -1);
this.osIsWindows = (navigator.appVersion.indexOf('Win') != -1);
this.osIsMac = (navigator.appVersion.indexOf('Mac') != -1); // ????
this.browserVersion = parseFloat(navigator.appVersion);
this.e = new Array();
this.b = new Array();
// methods
this.init = MM_intInit;
this.reset = MM_intReset;
this.resetElems = MM_intResetElems;
this.enable = MM_intEnable;
this.disable = MM_intDisable;
this.setDisabled = MM_intSetDisabled;
this.update = MM_intUpdate;
this.add = MM_intAdd;
this.setTries = MM_intSetTries;
this.setTriesLimit = MM_intSetTriesLimit;
this.setTime = MM_intSetTime;
this.setTimeLimit = MM_intSetTimeLimit;
this.track = MM_intTrack
this.getTime = MM_intGetTime;
this.am = MM_intAm;
this.judge = MM_intJudge;
this.resetActionMgr = MM_intResetActionMgr;
this.setSegmNode = MM_intSetSegmNode;
this.getSegmNode = MM_intGetSegmNode;
this.setSegmDisabled = MM_intSetSegmDisabled;
this.getSegmDisabled = MM_intGetSegmDisabled;
}
//Calls the element init funtions if they exist, and then does a reset
function MM_intInit() {
var i,j,localPC;
with (this) {
// init elems, and set totalElems, possCorrect, possIncorrect;
totalElems = 0;
possCorrect = 0;
possIncorrect = 0;
for (i in e) if (i != 'length') {
if (e[i].init != null) e[i].init();
totalElems++;
localPC = 0;
for (j in e[i].c) if (j != 'length' && e[i].c[j].isCorrect != null)
(e[i].c[j].isCorrect) ? localPC++ : possIncorrect++;
if (e[i]._singleChoice != null && localPC > 1)
localPC = 1;
possCorrect += localPC;
}
reset();
if (knowledgeTrack) {
var frm = findcmiframe(null);
if (frm == null) {
installcmi(window); //layers in NS
if (!CMIIsPresent()) {
var cmi = cmiinit(window);
if (cmi) CMIInitialize();
else if (!window.trackwarning) {
alert(TRACK_system_not_found);
window.trackwarning = true;
} } }
else {
if (window.CMIInitialize == null) frm.installcmi(window);
if (window.CMIInitialize != null) CMIInitialize();
if (!CMIIsPresent() && !window.trackwarnings) {
alert(TRACK_system_not_found);
window.trackwarning = true;
} } } }
window["'"+this._self+"'"] = this._self; //redeclare global on window in case inserted in layer
}
//Called to reset the interaction
function MM_intReset() {
with (this) {
tries = 0;
triesAtLimit = false;
_timeStart = Math.floor((new Date()).getTime()/1000);
if (_timerID) clearTimeout(_timerID);
if (!disabled && timeLimit) _timerID = setTimeout(_self+".judge()",(timeLimit+1)*1000);
time = 0;
timeLeft = timeLimit;
timeAtLimit = false;
resetActionMgr();
resetElems();
update(true);
}
}
//Calls the reset for the individual elements
function MM_intResetElems() {
with (this) {
for (var i in e) if (i != 'length')
if (e[i].reset != null) e[i].reset();
update(true);
}
}
//Enables the interaction
function MM_intEnable() {
if (this.disabled) with (this) {
_timeStart = Math.floor((new Date()).getTime()/1000) - time;
if (timeLimit)
_timerID = setTimeout(_self+".judge()",Math.max(0,(timeLimit-time)+1)*1000);
disabled = false;
update(true);
for (var i in e) if (i != 'length')
if (e[i].enable != null) e[i].enable();
}
}
//Disables the interaction
function MM_intDisable() {
if (!this.disabled) with (this) {
update(true); // update 'time'
if (_timerID) clearTimeout(_timerID); // clear the timer
disabled = true;
for (var i in e) if (i != 'length')
if (e[i].disable != null) e[i].disable();
}
}
//Calls the approppriate disable or enable function
function MM_intSetDisabled(theDisabled) {
if (theDisabled) this.disable();
else this.enable();
}
//Update the interaction state
// Note: tries will be updated by the judge method, and time will
// be updated by both this method and the judge method.
function MM_intUpdate(noJudge) {
if (!this.disabled) with (this) {
knownResponse = false;
totalCorrect = 0;
totalIncorrect = 0;
correct = false;
score = 0;
for (var i in e) if (i != 'length') {
for (var j in e[i].c) if (j != 'length') {
if (e[i].c[j].selected) {
knownResponse = true;
score += e[i].c[j].score;
if (e[i].c[j].isCorrect != null)
(e[i].c[j].isCorrect) ? totalCorrect++ : totalIncorrect++;
} } }
if (!knownResponse) correct = unknownIsCorrect;
else if (totalIncorrect != 0) correct = false;
else if (totalCorrect == 0) correct = null; // not judged
else correct = (!allThatApply || totalCorrect >= possCorrect);
time = Math.floor((new Date()).getTime()/1000) - _timeStart;
if (timeLimit && !timeAtLimit) {
timeLeft = Math.max(0, timeLimit - time);
timeAtLimit = (time > timeLimit);
}
if (judgeOnSel && !noJudge) judge();
}
}
function MM_intSetTries(theTries) {
with (this) {
tries = theTries;
triesAtLimit = (triesLimit) ? (tries >= triesLimit) : false;
}
}
function MM_intSetTriesLimit(theTriesLimit) {
with (this) {
triesLimit = theTriesLimit;
triesAtLimit = (triesLimit) ? (tries >= triesLimit) : false;
}
}
function MM_intSetTime(theTime) {
with (this) {
time = Math.max(0, theTime);
_timeStart = Math.floor((new Date()).getTime()/1000) - time;
timeLeft = (timeLimit) ? Math.max(0, timeLimit - time) : timeLimit;
timeAtLimit = (timeLimit) ? (time > timeLimit) : false;
if (_timerID) clearTimeout(_timerID); // clear the timer
if (!disabled && timeLimit)
_timerID = setTimeout(_self+".judge()",Math.max(0,(timeLimit-time)+1)*1000);
}
}
function MM_intSetTimeLimit(theTimeLimit) {
with (this) {
if (!disabled)
time = Math.floor((new Date()).getTime()/1000) - _timeStart;
timeLimit = theTimeLimit;
timeLeft = (timeLimit) ? Math.max(0, timeLimit - time) : timeLimit;
timeAtLimit = (timeLimit) ? (time > timeLimit) : false;
if (_timerID) clearTimeout(_timerID); // clear the timer
if (!disabled && timeLimit)
_timerID = setTimeout(_self+".judge()",Math.max(0,(timeLimit-time)+1)*1000);
}
}
function MM_intAdd(theType, A, B, C, D, E, F, G, H, I, J, K, L, M) {
var theObj = eval("new MM_" + theType + "(" + this._self + ", A, B, C, D, E, F, G, H, I, J, K, L, M)");
if (theObj._isChoice != null)
this.e[A].c[B] = theObj;
else
this.e[A] = theObj;
}
function MM_intTrack() {
var aDt= new Date();
var curHr=aDt.getHours()+'', curMin=aDt.getMinutes()+'', curSec=aDt.getSeconds()+'';
var curDay=aDt.getDate()+'', curMonth=aDt.getMonth()+1+'', curYear=aDt.getYear(), dmy;
var lat = Math.floor(aDt.getTime()/1000) - this._timeStart;
var x=3600;
var y=60;
var hrs=Math.round(lat/x - lat%x/x)+'';
var min=Math.round((lat-hrs*x)/y-(lat-hrs*x)%y/y)+'';
var sec=Math.round(lat-hrs*x-min*y)+'';
var sRes,cRes,res,aName,bName,isC,isNC,isSel,iType;
if (curYear < 1900) curYear += 1900;
if (curDay.toString().length==1) curDay = '0'+curDay;
if (curMonth.toString().length==1) curMonth = '0'+curMonth;
dmy = curDay+"/"+curMonth+"/"+curYear;
sRes=cRes=res=aName=bName=""
with (this) {
if (trackQType.length==0) return;
iType=trackQType.charAt(0).toLowerCase();
if (allThatApply&&possCorrect>1) sRes=cRes='{';
for (var i in e) if (i != 'length') {
for (var j in e[i].c) if (j != 'length') {
isC=e[i].c[j].isCorrect;
isSel=e[i].c[j].selected;
if (iType=='m') {
aName=e[i].c[j]._elem._name;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -