BSET Auto-Advisor

This is a little automatic advising tool to help BSET students see the pre-requisite relationships

by Ebony McCoy

HTML

<h1>
BSET Quick Advisor
</h1>
Simply select what courses you have already taken and the system will automatically enable other courses you can take. This shows only required course and takes into account pre-requisites.
<br/>
<p>Students should complete MAC1105 prior to admission to the program. </p><br/>

<input type="checkbox" id="MAC1105" onclick="CC();" /> 
<label for='MAC1105'>MAC1105 College Algebra</label><br/>

<input type="checkbox" id="STA2023" onclick="CC();" /> 
<label for='STA2023'>STA2023 Statistics</label><br/>
<input type="checkbox" id="MAC1114" onclick="CC();" disabled />
<label for='MAC1114'>MAC1114 Trigonometry</label><br/>
<input type="checkbox" id="MAC1140" onclick="CC();" disabled /> 
<label for='MAC1140'>MAC1140 Pre-Calculus</label><br/>
<input type="checkbox" id="MAC2311" onclick="CC();" disabled> 
<label for='MAC2311'>MAC2311 Calculus (EGN2045 Equivalent)</label><br/>
<input type="checkbox" id="PHY2048" onclick="CC();" disabled>
<label for='PHY2048'>PHY2048 Physics with Calculus</label><br/>
<input type="checkbox" id="EET3085" onclick="CC();" disabled>
<label for='ET3085'>EET3085 Electricity and Electronics</label><br/>
<input type="checkbox" id="EGN3046" onclick="CC();" disabled>
<label for='EGN3046'>EGN3046 Technical Calculus II (or MAP2302)</label><br/>

<input type="checkbox" id="ETS3543" onclick="CC();" disabled> 
<label for='ETS3543'>ETS3543 Programmable Logic Applications</label><br/>
<input type="checkbox" id="ETI3116" onclick="CC();" disabled> 
<label for='ETI3116'>ETI3116 Engineering Quality Analysis</label><br/>
<input type="checkbox" id="ETI3421" onclick="CC();" disabled> <label for='ETI3421'>ETI3421 or ETC4241 Materials</label><br/>
<input type="checkbox" id="EGN3311" onclick="CC();" disabled> 
<label for='EGN3311'>EGN3311 Statics</label><br/>
<input type="checkbox" id="EGN3321" onclick="CC();" disabled> 
<label for='EGN3321'>EGN3321 Dynamics</label><br/>

<input type="checkbox" id="ETM4220" onclick="CC();" disabled> 
<label...

CSS

input:enabled + label { 
  margin: 20px auto;
  background:rgb(255,255,0);
}

input:disabled + label{
  opacity:0.5;
  background:rgb(255,0,0);
}
input[type="checkbox"]:checked + label {
  background:rgb(153,204,102);
  font-weight:bold;
}

JavaScript

// The first course is course to take, followed
// by an array of pre-requisites

// courses is an array of arrays
// each element of courses contains
// a string - the course in question
// an array - an array of the pre-requisites of the course
// Note that the Checkbox id in the html is also 
// the first element of each array element of courses

var courses = [
 ['MAC1140', ['MAC1105']],
 ['MAC1114', ['MAC1105']],
 ['MAC2311', ['MAC1140','MAC1114']],
 ['PHY2048', ['MAC2311']],
 ['EGN3046', ['MAC2311']],
 ['EET3085', ['MAC1114']],
 ['ETS3543', ['MAC1105']],
 ['ETI3116', ['STA2023']],
 ['ETI3421', ['MAC1114']],
 ['EGN3311', ['MAC2311', 'PHY2048']],
 ['EGN3321', ['EGN3311']],
 ['ETM4220', ['MAC2311']], 
 ['EGN3613', ['MAC2311']],
 ['ETS4502', ['EGN3311']],
 ['ETI4448', ['MAC2311', 'EGN3613']],
 ['ETG4950', ['ETI4448']]
]
  
function pr(item, index) {
   // item[0] is the course in question (string)
   var checked = true;
   
   // item[1]  is the array of pre-requisites (array of strings)
   var elementId = item[1][0];
   
   // Goes through the list of pre-requisites
   // to see if each one is met if any are not met
   // then pre-requisites are not met
   for (var i=0; i<item[1].length; i++){
     elementId = item[1][i];  
     if (!isChecked(elementId)) {
       checked=false;
     }
   }  
   // and if all are met - enables taking courses
   // checked is true/false Enable is a function call to Enable
   // item[0] is the first element of the array item - which is the 
   // course in question
   // item[0] - courses
   // item[1] - array of pre-requisite courses
   if (checked) Enable(item[0]) 
   else Disable(item[0]);
}

function CC()
{
  courses.forEach(pr);
}

function isChecked(item) {
  return (document.getElementById(item).checked == true);
}

// The function Enable sets the disabled property of the interface element
// to false. In effect making it enabled.
function Enable(selection){
 document.getElementById(selection).disabled =...