Changeset - 7cac9a0cbf3a
[Not reviewed]
default
0 3 0
ethanzonca - 15 years ago 2010-09-23 22:09:33

Custom course numbering system implemented, formatting changes
3 files changed with 29 insertions and 14 deletions:
0 comments (0 inline, 0 general)
input.php
Show inline comments
 
@@ -11,51 +11,52 @@ include_once 'inc/class.page.php';
 
$inputPage->showSavedScheds($_SESSION);
 

	
 
?>
 

	
 
<form method="post" action="process.php" id="scheduleForm">
 
<table id="jsrows">
 
	<tr>
 
		<td colspan="11" style="padding-bottom:2em;"><input id="scheduleName" class="defText" type="text" class="required" title="Schedule Name" name="postData[name]" />
 
			<em>(For example: Fall <?php echo Date("Y"); ?>)</em>
 
		</td>
 
	</tr>
 
	<tr>
 
		<td colspan="11" style="padding-bottom: 2em;">Sections at my school are <select id="isNumeric" type="text" class="required" name="isnumbered" ><option value="numbered">Numbered</option><option value="lettered">Lettered</option><option value="numerous">Incredibly numerous</option></select>
 
		<td colspan="11" style="padding-bottom: 2em;">Section Numbering Style: <select id="isNumeric" type="text" class="required" name="isnumbered" ><option value="numerous">Custom</option><option value="numbered">Numbered</option><option value="lettered">Lettered</option></select>
 

	
 
	<!-- Header -->
 
	<tr>
 
		<td>Class</td>
 
		<td class="center" id="letterNumber">Number</td>
 
		<td class="center" id="letterNumber">Section</td>
 
		<td class="center">Start Time</td>
 
		<td class="center">End Time</td>
 
		<td class="center">M</td>
 
		<td class="center">Tu</td>
 
		<td class="center">W</td>
 
		<td class="center">Th</td>
 
		<td class="center">F</td>
 
		<td class="center">Add</td>
 
		<td class="center">Delete</td>
 
		<td class="center"></td>
 
		<td class="center"></td>
 
	</tr>
 
</table>
 

	
 
<div class="paddingtop" id="classage"><input type="button" value="Add class" /></div>
 
<div class="paddingtop"><input style="float:left;" type="submit" value="Submit" /></div>
 

	
 
</form>
 

	
 
<p>&nbsp;<br /></p>
 

	
 
<h3>TODO:</h3>
 

	
 
<ul>
 
	<li>Add print stylesheet and button to output page</li>
 
	<li>After selecting a start time, set the end time to one hour after the start time</li>
 
        <li><strong>Append</strong> sections</li>
 
        <li>Move the add class button to somewhere nicer, maybe a gray row at the bottom. Make the submit button more obvious.</li>
 
	<li><strong>Switch from dropdown for section identifier to entry field</strong></li>
 
	<li>Form validation to ensure endtime is after starttime, at least one day is checked.</li>
 
	<li>Auto-populate form based on saved schedule?</li>
 
        <li>Grab data from school sites such as <a href="http://www.cedarville.edu/courses/schedule/2010fa_be_bebl.htm" target="_blank">this?</a></li>
 
</ul>
 

	
 
<?php
 
$inputPage->foot();
scripts/scheduleInput.js
Show inline comments
 
@@ -62,38 +62,43 @@
 
                                <select name="'+name+'"><option value="-">-</option><option value="1">1</option><option value="2">2</option>\
 
                                <option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option>\
 
                                <option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option></select></td>\
 
                                </select></td>';
 
        }
 
	function letteredIds(name){
 
		return '<td class="sectionIdentifier">\
 
                                <select name="'+name+'"><option value="-">-</option><option value="A">A</option><option value="B">B</option>\
 
                                <option value="C">C</option><option value="D">D</option><option value="E">E</option><option value="F">F</option><option value="G">G</option>\
 
                                <option value="H">H</option><option value="I">I</option><option value="J">J</option><option value="K">K</option></select></td>\
 
                                </select></td>';
 
	}
 

	
 
	function customIds(name){
 
		return '<td class="sectionIdentifier"><input type="text" size="1" class="required" title="Schedule Name" name="' + name + '" /></td>';
 
	}
 

	
 
	//--------------------------------------------------
 
	// Returns the common inputs for each new section.
 
	//--------------------------------------------------
 
	function getCommonInputs(cnum) {
 
		var snum = sectionsOfClass[cnum];
 

	
 
		var result = '';
 
		if(jQuery('#isNumeric').val() == "lettered"){
 
			result = result + letteredIds('postData[' + cnum + '][' + snum + '][letter]');
 
		}
 
		else if(jQuery('#isNumeric').val() == "numbered") {
 
                        result = result + numberedIds('postData[' + cnum + '][' + snum + '][letter]');
 
		}
 
		else {
 
                        result = result + numberedIds('postData[' + cnum + '][' + snum + '][letter]');
 
                        result = result + customIds('postData[' + cnum + '][' + snum + '][letter]');
 
		}
 

	
 
		result = result + '<td><select class="selectRequired" name="postData[' + cnum + '][' + snum + '][start]"><option value="none"></option>\
 
				<option value="700">7:00 am</option><option value="730">7:30 am</option>\
 
				<option value="800">8:00 am</option><option value="830">8:30 am</option>\
 
				<option value="900">9:00 am</option><option value="930">9:30 am</option>\
 
				<option value="1000">10:00 am</option><option value="1030">10:30 am</option>\
 
				<option value="1100">11:00 am</option><option value="1130">11:30 am</option>\
 
				<option value="1200">12:00 pm</option><option value="1230">12:30 pm</option>\
 
				<option value="1300">1:00 pm</option><option value="1330">1:30 pm</option>\
 
				<option value="1400">2:00 pm</option><option value="1430">2:30 pm</option>\
 
				<option value="1500">3:00 pm</option><option value="1530">3:30 pm</option>\
 
@@ -124,59 +129,60 @@
 
			<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][2]" value="1" /></td>\
 
			<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][3]" value="1" /></td>\
 
			<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" /></td>';
 
	
 
		return result;
 
	}
 

	
 
	//--------------------------------------------------
 
	// Adds a new class to the input.
 
	//--------------------------------------------------
 
	function addRow(){
 
		sectionsOfClass[classNum] = 0; // This is class 0, initialize at 0
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + '"><td><input type="text" class="required defText" title="Class Name" name="postData[' + classNum + '][name]" /></td><td colspan="8"></td><td><div class="addSection"><input type="button" value="Add section" /></div></td><td><div class="deleteClass"><input type="button" value="Delete" /></div></td></tr>');
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + '"><td><input type="text" class="required defText" title="Class Name" name="postData[' + classNum + '][name]" /></td><td colspan="8"></td><td class="tdInput"><div class="addSection"><input type="button" value="Add section" /></div></td><td class="tdInput"><div class="deleteClass"><input type="button" value="Remove" /></div></td></tr>');
 
		classNum++;
 
	};
 
	
 
	addRow(); // Add initial row
 

	
 
	//--------------------------------------------------
 
	// Adds a new class when the add class button is 
 
	// clicked.
 
	//--------------------------------------------------
 
	jQuery('#classage').click(function() {
 
		addRow();
 
	});
 

	
 
	//--------------------------------------------------
 
	// Deletes the selected class from input.
 
	//--------------------------------------------------
 
	jQuery('.deleteClass').live('click', function() {
 
		alert('Delete class and all sections of this class?');
 
		jQuery('.class'+ jQuery(this).parent().parent().attr("title")).remove();
 
	});
 

	
 
	//--------------------------------------------------
 
	// Deletes the selected section from the input.
 
	//--------------------------------------------------
 
	jQuery('.deleteSection').live('click', function() {
 
		sectionsOfClass[jQuery(this).parent().parent().attr("title")]--; // TODO: this only decreases the number of classes, so php should loop until this number of classes is found in the array
 
		jQuery(this).parent().parent().remove();
 
	});
 

	
 
	//--------------------------------------------------
 
	// Adds a section to the selected class.
 
	//--------------------------------------------------
 
	jQuery('.addSection').live('click', function() {
 
		sectionsOfClass[jQuery(this).parent().parent().attr("title")]++; // Increases sectionsOfClass[classNum]
 
		jQuery(this).parent().parent().after('<tr class="section class' + jQuery(this).parent().parent().attr("title") + '"><td class="none"></td>' + getCommonInputs(jQuery(this).parent().parent().attr("title")) + '<td></td><td><div class="deleteSection"><input type="button" value="Delete" /></div></td></tr>');
 
		jQuery(this).parent().parent().after('<tr class="section class' + jQuery(this).parent().parent().attr("title") + '"><td class="none"></td>' + getCommonInputs(jQuery(this).parent().parent().attr("title")) + '<td></td><td><div class="deleteSection"><input type="button" value="X" /></div></td></tr>');
 
	});
 

	
 
	//--------------------------------------------------
 
	// Resets the form
 
	//--------------------------------------------------
 
	jQuery('#reset').click(function() {
 
		jQuery('#scheduleForm').resetForm();
 
    });
 

	
 
	//--------------------------------------------------
 
	// Default text stuff
 
	//--------------------------------------------------
 
@@ -200,31 +206,37 @@
 

	
 

	
 
    //--------------------------------------------------
 
    // Change between numbered and lettered on event
 
    //--------------------------------------------------
 
    jQuery("#isNumeric").live('change', function() {
 
      if(this.value == "lettered"){
 
         /* Replace with lettered */
 
         jQuery(".sectionIdentifier").each( function(index) {
 
           var name = jQuery("select", this).attr("name");
 
           jQuery(this).empty();
 
           jQuery(this).append(letteredIds(name));
 
           jQuery("#letterNumber").empty();
 
           jQuery("#letterNumber").append("Letter");
 
         });
 
      }
 
      else {
 
      else if(this.value == "numbered"){
 
         /* Replace with numbered */
 
         jQuery(".sectionIdentifier").each( function(index) {
 
           var name = jQuery("select", this).attr("name");
 
           jQuery(this).empty();
 
           jQuery(this).append(numberedIds(name));
 
           jQuery("#letterNumber").empty();
 
           jQuery("#letterNumber").append("Number");
 
         });
 
      }
 
      else {
 
         /* Replace with custom */
 
         jQuery(".sectionIdentifier").each( function(index) {
 
           var name = jQuery("select", this).attr("name");
 
           jQuery(this).empty();
 
           jQuery(this).append(customIds(name));
 
         });
 

	
 
      }
 

	
 
    });
 
    
 

	
 
});
 

	
styles/general.css
Show inline comments
 
@@ -45,13 +45,15 @@
 
		background: #fff;
 
	}
 
	.class {
 
		background: #99FF99;
 
	}
 
	#classage {
 
		float:left;
 
	}
 
	.paddingtop {
 
		padding: .5em;
 
		padding-top: .8em;
 
	}
 

	
 
.tdInput {
 
  background: #fff;
 
}
0 comments (0 inline, 0 general)