Add a New Class

Use the form below to add a new class. Fill out the form completely and click "Save Class" to continue.

eof; $newaction="insertclass"; include("forms/classForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////// //insertclass //////////////////////////////////////////////////////////////////////////////////////////////////// case"insertclass": $errors =0; $msg=""; if ($post->className==""){ $errors++; $msg.="You must fill in a class name to continue
"; } if ($post->classDesc==""){ $errors++; $msg.="You must fill in a class description to continue
"; } if ($post->teacher_id==""){ $errors++; $msg.="You must select a teacher to continue
"; } if ($errors>0){ print<<Error

The following errors occured processing your form. Please make your corrections.

$msg

Use the form below to add a new class. Fill out the form completely and click "Save Class" to continue.

eof; $row = $post; $newaction="insertclass"; include("forms/classForm.php"); } $startDate = "$post->startYear-$post->startMonth-$post->startDay"; $endDate = "$post->endYear-$post->endMonth-$post->endDay"; $r =$db->query("SELECT firstname,lastname, suffix FROM teachers WHERE teacher_id='$post->teacher_id'"); $r->fetchInto($t); $teacherName = "$t->firstname $t->lastname $t->suffix"; $db->query("INSERT INTO classes (class_id,className,classDesc,teacher_id,teacherName,startDate,endDate,schoolLocation,created,modified) VALUES (null,'$post->className','$post->classDesc','$post->teacher_id','$teacherName','$startDate','$endDate','$post->schoolLocation',NOW(),NOW())"); $class_id = $db->getOne("SELECT class_id FROM classes ORDER BY class_id DESC limit 1"); print<<Success

Your class has been added.

Click here to add students to this class.

Click here to add another class.

Click here to return to the class index.

eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////// //editclass //////////////////////////////////////////////////////////////////////////////////////////////////// case"editclass": // if the class ID doesn't match the teacher ID...we must exit. if ($db->getOne("SELECT COUNT(class_id) FROM classes WHERE class_id='$get->class_id' AND teacher_id='$s->steacher_id'")==0){ print<<Error

You cannot edit this class because it does not belong to you.

Go Back

eof; include("inc/foot.php"); exit; } print<<Edit Class

Use the form below to edit this class. Fill out the form completely and click "Save Class" to continue.

eof; // if the class ID doesn't match the teacher ID...we must exit. $result=$db->query("SELECT * FROM classes WHERE class_id='$get->class_id'"); $result->fetchInto($row); $newaction="updateclass"; include("forms/classForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////// //updateclass //////////////////////////////////////////////////////////////////////////////////////////////////// case"updateclass": $errors =0; $msg=""; if ($post->className==""){ $errors++; $msg.="You must fill in a class name to continue
"; } if ($post->classDesc==""){ $errors++; $msg.="You must fill in a class description to continue
"; } if ($post->teacher_id==""){ $errors++; $msg.="You must select a teacher to continue
"; } if ($errors>0){ print<<Error

The following errors occured processing your form. Please make your corrections.

$msg

Use the form below to add a new class. Fill out the form completely and click "Save Class" to continue.

eof; $row = $post; $newaction="updateclass"; include("forms/classForm.php"); } $r =$db->query("SELECT firstname,lastname, suffix FROM teachers WHERE teacher_id='$post->teacher_id'"); $r->fetchInto($t); $teacherName = "$t->firstname $t->lastname $t->suffix"; $startDate = "$post->startYear-$post->startMonth-$post->startDay"; $endDate = "$post->endYear-$post->endMonth-$post->endDay"; $db->query("UPDATE classes SET className='$post->className',classDesc='$post->classDesc',startDate='$startDate',endDate='$endDate',modified=NOW(), teacher_id='$post->teacher_id', teacherName='$teacherName',schoolLocation='$post->schoolLocation' WHERE class_id='$post->class_id'"); print<<Success

Your class has been updated.

Click here to add students to this class.

Click here to return to the class index.

eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////// //deleteclass //////////////////////////////////////////////////////////////////////////////////////////////////// case"deleteclass": // if the class ID doesn't match the teacher ID...we must exit. if ($db->getOne("SELECT COUNT(class_id) FROM classes WHERE class_id='$get->class_id' AND teacher_id='$s->steacher_id'")==0){ print<<Error

You cannot edit this class because it does not belong to you.

Class Index

eof; include("inc/foot.php"); exit; } if ($get->really=="y"){ // delete it... $db->query("DELETE FROM classes WHERE class_id='$get->class_id'"); $db->query("DELETE FROM grades WHERE class_id='$get->class_id'"); $db->query("DELETE FROM students WHERE class_id='$get->class_id'"); print<<Success

Your class has been deleted.

Click here to return to the classes index page.

eof; }else{ print<<Deletion Warning

You are about to delete this class. That will delete the class information, the grades, the students and everything associated with this class.

Are you sure you want to delete all this data?

Yes. Delete this class.

Go Back

eof; } break; //////////////////////////////////////////////////////////////////////////////////////////////////// //editstudents //////////////////////////////////////////////////////////////////////////////////////////////////// case"editstudents": // if the class ID doesn't match the teacher ID...we must exit. if ($db->getOne("SELECT COUNT(class_id) FROM classes WHERE class_id='$get->class_id' AND teacher_id='$s->steacher_id'")==0){ print<<Error

You cannot edit this class because it does not belong to you.

Go Back

eof; include("inc/foot.php"); exit; } print<<Edit Students

Use the form below to edit students enrolled in this class. The left box is the available students and the right box is the students in this class. To add students, click their name in the left box and click the ">>" button. To remove students, click their name in the right box and click the "<<" button. Click "Save Students" to continue.

eof; $newaction="updatestudents"; include("forms/studentsForm.php"); break; //////////////////////////////////////////////////////////////////////////////////////////////////// //default //////////////////////////////////////////////////////////////////////////////////////////////////// case"updatestudents": $students = $post->list2; // first remove... $res = $db->query("SELECT * FROM students WHERE class_id='$post->class_id'"); while($res->fetchInto($row)){ if (!in_array($row->user_id,$students)){ $db->query("DELETE FROM students WHERE user_id='$row->user_id'"); } } $res->free(); foreach($students as $key=>$user_id){ if ($db->getOne("SELECT COUNT(student_id) FROM students WHERE user_id='$user_id' AND class_id='$post->class_id'")==0){ // insert... $db->query("INSERT INTO students (student_id,class_id,user_id,created, modified) VALUES(null,'$post->class_id','$user_id', NOW(),NOW())"); }else{ // do nothing... } } print<<Success

Your class has been saved and is now filled with the following students

    eof; $res = $db->query("SELECT * FROM students WHERE class_id='$post->class_id'"); while($res->fetchInto($row)){ $r = $db->query("SELECT firstname, lastname FROM users WHERE user_id='$row->user_id'"); $r->fetchInto($s); $studentName = "$s->firstname $s->lastname"; print"
  • $studentName
  • "; } $res->free(); print<<

    Click here to edit these students.

    Click here to return to the classes index.

    eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////// //editgrades //////////////////////////////////////////////////////////////////////////////////////////////////// case"editgrades": print<<Edit Grades

    Use the form below to edit the grades for this class. Make sure to fill in each grade and click "Save Grades" to continue.

    eof; $res = $db->query("SELECT students.student_id,students.user_id, classes.* FROM students LEFT JOIN classes USING(class_id) WHERE students.class_id='$get->class_id' ORDER BY student_id ASC"); while($res->fetchInto($row)){ $attendanceSelect=""; if ($printed%2!=0){$class="list1";}else{$class="list2";} $firstname = $db->getOne("SELECT firstname from users WHERE user_id='$row->user_id'"); $lastname = $db->getOne("SELECT lastname from users WHERE user_id='$row->user_id'"); $studentName = "$firstname $lastname"; $result = $db->query("SELECT * FROM grades WHERE user_id='$row->user_id' AND class_id='$row->class_id'"); $result->fetchInto($r); $result->free(); if ($r->paid=="y"){ $paidChecked="CHECKED"; $unPaidChecked=""; }else{ $paidChecked = ""; $unPaidChecked="CHECKED"; } if ($r->externship=="y"){ $externChecked="CHECKED"; $externNoChecked=""; }else{ $externChecked = ""; $externNoChecked="CHECKED"; } if ($r->pass=="y"){ $passChecked="CHECKED"; $failChecked=""; }else{ $passChecked=""; $failChecked="CHECKED"; } $oneSelected = ""; $twoSelected = ""; $threeSelected = ""; $fourSelected = ""; $fiveSelected = ""; $sixSelected = ""; $noSelected = ""; switch($r->attendance){ case"96": $oneSelected = "SELECTED"; break; case"92": $twoSelected = "SELECTED"; break; case"88": $threeSelected = "SELECTED"; break; case"83": $fourSelected = "SELECTED"; break; case"79": $fiveSelected = "SELECTED"; break; case"75": $sixSelected = "SELECTED"; break; default: $noSelected = "SELECTED"; break; } $attendanceSelect.=<< eof; print<< eof; $printed++; } print<<
    Student Class Lab Grade Quiz Grade Mid Grade Attendance Externship Final Exam Grade Final Grade Pass/Fail Paid
    $studentName   $row->className $attendanceSelect Yes
    No
    $r->finalGrade Pass
    Fail
    Paid
    Un-Paid
    eof; break; //////////////////////////////////////////////////////////////////////////////////////////////////// //updateGrades //////////////////////////////////////////////////////////////////////////////////////////////////// case"updategrades": $labGrade = $_POST["labGrade"]; $quizGrade = $_POST["quizGrade"]; $midGrade = $_POST["midGrade"]; $finalGrade=$_POST["finalGrade"]; $finalExamGrade=$_POST["finalExamGrade"]; $attendance = $_POST["attendance"]; $pass = $_POST["pass"]; $paid=$_POST["paid"]; $externship=$_POST["externship"]; $msg=""; if (is_array($labGrade)){ foreach($labGrade AS $user_id=>$labGradeValue){ $student_id =$db->getOne("SELECT student_id FROM students WHERE class_id='$post->class_id' AND user_id='$user_id'"); // insert or update... /* lab = 35% quiz = 15% midterm = 25% final = 25% */ $extern = $externship[$user_id]; $gradeAggregate = ($labGrade[$user_id]*7)+($quizGrade[$user_id]*3)+($midGrade[$user_id]*5)+($finalExamGrade[$user_id]*5); $finalGrade = $gradeAggregate/20; if (($finalGrade>79.5)||($pass[$user_id]=="y")){ $pass="y"; }else{ $pass="n"; } if ( $db->getOne("SELECT COUNT(grade_id) FROM grades WHERE class_id='{$_POST[class_id]}' AND user_id='$user_id'")==0){ $sql = "INSERT INTO grades(grade_id,student_id,class_id,user_id,quizGrade,labGrade,midGrade,finalExamGrade,finalGrade,attendance,paid,pass,created,modified) VALUES(null,'$student_id','$post->class_id','$user_id','{$quizGrade[$user_id]}','{$labGrade[$user_id]}','{$midGrade[$user_id]}','{$finalExamGrade[$user_id]}','$finalGrade','{$attendance[$user_id]}','{$paid[$user_id]}','$pass',NOW(),NOW())"; //print"

    $sql

    "; $db->query($sql); }else{ $sql = "UPDATE grades set externship='$extern',labGrade='{$labGrade[$user_id]}',quizGrade='{$quizGrade[$user_id]}',midGrade='{$midGrade[$user_id]}',finalExamGrade='{$finalExamGrade[$user_id]}',finalGrade='$finalGrade',attendance='{$attendance[$user_id]}',pass='$pass',paid='{$paid[$user_id]}',modified=NOW() WHERE user_id='$user_id' AND class_id='$post->class_id'"; //print"

    $sql

    "; $db->query($sql); } } }else{ print<<Error

    An unknown error occured while processing your request.

    Go Back

    eof; include("inc/foot.php"); exit; } print<<Success

    Your grades have been saved.

    Click here to edit these grades.

    Click here to return to the classes index page.

    eof; //var_dump($post); //echo "

    ".print_r($_POST); break; //////////////////////////////////////////////////////////////////////////////////////////////////// //default //////////////////////////////////////////////////////////////////////////////////////////////////// default: print<<Classes

    Below is a list of all of your classes. Click the student count to edit the students in each class, click "Edit" to edit class details, and click "Delete" to delete each class.

    Click here to add a new class

    eof; $printed=0; $time = new timeConversion; $result = $db->query("SELECT * FROM classes WHERE teacher_id='$s->steacher_id' ORDER BY startDate ASC, className ASC"); while($result->fetchInto($row)){ if ($printed%2!=0){$class="list1";}else{$class="list2";} $time->dbdate=$row->startDate; $startDate = $time->datetime2short(); $time->dbdate = $row->endDate; $endDate = $time->datetime2short(); $studentCount = $db->getOne("SELECT COUNT(student_id) FROM students WHERE class_id='$row->class_id'"); print<< eof; if($studentCount>0){ print<<Print Certs eof; }else{ print<<No Certs eof; } if($studentCount>0){ print<<Print XScripts eof; }else{ print<<No XScripts eof; } print<<Edit eof; $printed++; } print<< eof; break; } include("inc/foot.php"); ?>
    Class Name Duration Edit Students Edit Grades Print Certs Print XScripts Edit Delete
    $row->className $startDate - $endDate Edit Students ($studentCount) Edit GradesDelete