alert("No workspace was returned from LAMS server! You may try refreshing sequence list.\nIf you still get the same problem, probably you have to cancel this activity.");
alert("No sequence was returned from LAMS server! You may try refreshing sequence list.\nIf you still get the same problem, probably you have to cancel this activity.");
"<p>Select an existing sequence or create a new sequence.</p>";
}else if(req.status == 504){//gateway timeout. probabaly LAMS server is not available.
document.getElementById("message").innerHTML =
'<tablealign="center"width="57%"class="noticebox"border="0"cellpadding="15"cellspacing="0"><tr><tdbgcolor="#FFAAAA"class="noticeboxcontent"><h4class="main">It seems the LAMS server is not available!<BR> Please contact your administrator.</h4></td></tr></table>';
}else if(req.status == 401){//AuthenticationException thrown by LAMS server.
document.getElementById("message").innerHTML =
'<tablealign="center"width="57%"class="noticebox"border="0"cellpadding="15"cellspacing="0"><tr><tdbgcolor="#FFAAAA"class="noticeboxcontent"><h4class="main">This moodle server is not authenticated by LAMS!<BR> Please contact your administrator.</h4></td></tr></table>';
}else if(req.status == 502){//Unknow exception thrown by LAMS server
document.getElementById("message").innerHTML =
'<tablealign="center"width="57%"class="noticebox"border="0"cellpadding="15"cellspacing="0"><tr><tdbgcolor="#FFAAAA"class="noticeboxcontent"><h4class="main">An unexpected error returned from LAMS server:'+req.responseText+'! Please contact your administrator.</h4></td></tr></table>';
}else if(req.status == 417){//ServerNotFound exception thrown by LAMS server
document.getElementById("message").innerHTML =
'<tablealign="center"width="57%"class="noticebox"border="0"cellpadding="15"cellspacing="0"><tr><tdbgcolor="#FFAAAA"class="noticeboxcontent"><h4class="main">This moodle server has not registered in LAMS!<BR> Please contact your administrator.</h4></td></tr></table>';
}else if(req.status == 402){//All LAMS module settings have not not been set up
document.getElementById("message").innerHTML =
'<tablealign="center"width="57%"class="noticebox"border="0"cellpadding="15"cellspacing="0"><tr><tdbgcolor="#FFAAAA"class="noticeboxcontent"><h4class="main">All the LAMS module settings have not been set up!<BR> Please contact your administrator.</h4></td></tr></table>';
}else{//this error should come from moodle server itself
document.getElementById("message").innerHTML =
'<tablealign="center"width="57%"class="noticebox"border="0"cellpadding="15"cellspacing="0"><tr><tdbgcolor="#FFAAAA"class="noticeboxcontent"><h4class="main">It should be a moodle server error:'+req.status + ' ' + req.statusText+'! Please contact your administrator.</h4></td></tr></table>';
}
}
}
var dynamicOptionListCount=0;
var dynamicOptionListObjects = new Array();
// Init call to setup lists after page load. One call to this function sets up all lists.
function initDynamicOptionLists() {
// init each DynamicOptionList object
for (var i=0; i<dynamicOptionListObjects.length;i++){
var dol = dynamicOptionListObjects[i];
// Find the form associated with this list
if (dol.formName!=null) {
dol.form = document.forms[dol.formName];
}
else if (dol.formIndex!=null) {
dol.form = document.forms[dol.formIndex];
}
else {
// Form wasn't set manually, so go find it!
// Search for the first form element name in the lists
var name = dol.fieldNames[0][0];
for (var f=0; f<document.forms.length;f++){
if (typeof(document.forms[f][name])!="undefined") {
dol.form = document.forms[f];
break;
}
}
if (dol.form==null) {
alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted"); return;
}
}
// Form is found, now set the onchange attributes of each dependent select box
for (var j=0; j<dol.fieldNames.length;j++){
// For each set of field names...
for (var k=0; k<dol.fieldNames[j].length-1;k++){
// For each field in the set...
var selObj = dol.form[dol.fieldNames[j][k]];
if (typeof(selObj)=="undefined") { alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted"); return; }
// Map the HTML options in the first select into the options we created
if (k==0) {
if (selObj.options!=null) {
for (l=0; l<selObj.options.length;l++){
var sopt = selObj.options[l];
var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);
if (m!=null) {
var reselectForNN6 = sopt.selected;
var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);
m2.selected = sopt.selected; // For some reason I need to do this to make NN4 happy
m2.defaultSelected = sopt.defaultSelected;
m2.DOLOption = m;
selObj.options[l] = m2;
selObj.options[l].selected = reselectForNN6; // Reselect this option for NN6 to be happy. Yuck.
}
}
}
}
if (selObj.onchange==null) {
// We only modify the onChange attribute if it's empty! Otherwise do it yourself in your source!
selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");
}
}
}
}
// Set the preselectd options on page load
resetDynamicOptionLists();
}
// This function populates lists with the preselected values.
// It's pulled out into a separate function so it can be hooked into a 'reset' button on a form
// Optionally passed a form object which should be the only form reset
function resetDynamicOptionLists(theform) {
// reset each DynamicOptionList object
for (var i=0; i<dynamicOptionListObjects.length;i++){
var dol = dynamicOptionListObjects[i];
if (typeof(theform)=="undefined" || theform==null || theform==dol.form) {
for (var j=0; j<dol.fieldNames.length;j++){
dol.change(dol.form[dol.fieldNames[j][0]],true); // Second argument says to use preselected values rather than default values
}
}
}
}
// An object to represent an Option() but just for data-holding
function DOLOption(text,value,defaultSelected,selected) {
this.text = text;
this.value = value;
this.defaultSelected = defaultSelected;
this.selected = selected;
this.options = new Array(); // To hold sub-options
return this;
}
// DynamicOptionList CONSTRUCTOR
function DynamicOptionList() {
this.form = null;// The form this list belongs to
this.options = new Array();// Holds the options of dependent lists
this.longestString = new Array();// Longest string that is currently a potential option (for Netscape)
this.numberOfOptions = new Array();// The total number of options that might be displayed, to build dummy options (for Netscape)
this.currentNode = null;// The current node that has been selected with forValue() or forText()
this.currentField = null;// The current field that is selected to be used for setValue()
this.currentNodeDepth = 0;// How far down the tree the currentNode is
this.fieldNames = new Array();// Lists of dependent fields which use this object
this.formIndex = null;// The index of the form to associate with this list
this.formName = null;// The name of the form to associate with this list
this.fieldListIndexes = new Object();// Hold the field lists index where fields exist
this.fieldIndexes = new Object();// Hold the index within the list where fields exist
this.selectFirstOption = true;// Whether or not to select the first option by default if no options are default or preselected, otherwise set the selectedIndex = -1
this.numberOfOptions = new Array();// Store the max number of options for a given option list
this.longestString = new Array();// Store the longest possible string
this.values = new Object(); // Will hold the preselected values for fields, by field name