/** * Returns ALL custom scores available for a teacher for a year. * This includes the system wide scores.... * * @param int $tid * @param int $year * @return resource {MySQL result set} */ function get_custom_scores($tid, $year) { global $db; $scores = array(); /** * Define some system wide scores for everybody here */ $scores['dr'] = array("longName" => "*Dropped", "grade" => "", "score_id" => "-1"); $scores['mi'] = array("longName" => "*Missing", "grade" => "0", "score_id" => "-2"); $result = get_teacher_custom_scores($tid, $year); while ($row = $result->fetch_assoc()) { if (!array_key_exists($row['code'], $scores)) { $scores[$row['code']] = array("longName" => $row['long_name'], "grade" => $row['grade'], "score_id" => $row['score_id']); } } return $scores; }
<?php global $order_by; $currentDate = date("F j, Y", time() - 18000); /** Get the list of categories for this class **/ $cat_names_array = array(); /** holds the names of the categories for this class **/ $info = array(); /** used to hold grade info like category weight and grade **/ $cat_weight_sum = 0; /** holds category weight sum **/ $my_cat_avg_sum = 0; /** holds my category avg's sum **/ $customScores = array(); $result = get_teacher_custom_scores($teacher_id, $_SESSION[$_CONF['sess_name'] . '_current_school_year']); while ($row = mysql_fetch_assoc($result)) { $customScores[$row['code']] = array("longName" => $row['long_name'], "grade" => $row['grade']); } $sql = "SELECT * from category where class_id=" . $cid; $result = mysql_query($sql); if ($result) { while ($row = mysql_fetch_assoc($result)) { ${$row['category_name']} = array(); array_push($cat_names_array, $row['category_name']); $MAX = $row['category_name'] . "_max_points"; $info[$MAX] = 0; $USER = $row['category_name'] . "_user_points"; $info[$USER] = 0; $WEIGHT = $row['category_name'] . "_weight"; $info[$WEIGHT] = $row['category_weight']; $COUNT = $row['category_name'] . "_count";
$schoolYears = get_school_years_list(); $schoolYearList = make_selection_list($schoolYears, $fromYear, "from_school_year", "customScores", "School Year", $change = "off"); $addScores = "\n <script type=\"text/javascript\">\n \$(document).ready(function() {\n \$('#addScoresForm').validationEngine({inlineValidation: true});\n });\n </script>\n\t\t<form id=addScoresForm action=\"\" method=POST>\n\t\t\t<span style=white-space:nowrap>I would like to add \n\t\t\t<input type=text class=validate[required,custom[integer]] size=2 id=numScores name=numScores /> custom scores to this class.\n\t\t\t<input type=submit class=submit id=addScores name=addScores value=Go /></span>\n\t\t</form>\n\t\t<br /> OR <br />\n\t\t<form id=copyScoresForm action=\"\" method=POST>\n\t\t\t<span style=white-space:nowrap>Copy from " . $schoolYearList . " \n\t\t\t<input type=submit class=submit id=copyScores name=copyScores value=Go /></span>\n\t\t</form>"; $newDialog = "\n\t\t<div id=\"newDialog\">\n\t\t<form id=\"newScoresForm\" name=\"newScoresForm\" action=\"\" method=POST>\n\t\t\t<div id=newScoresDiv></div>\n\t\t\t<center>\n\t\t\t<input type=submit id=\"insertNewScores\" name=insertNewScores value=\"Insert\" />\n\t\t\t<input type=reset id=\"cancelNewScores\" name=cancelNewScores value=\"Cancel\" />\n\t\t\t</center>\n\t\t</form>\n\t\t</div>"; $t = "New Scores"; $main .= "<div id=\"newScoresDialog\">" . make_box($t, $newDialog, 'blue') . "</div>"; $editDialog = "\n\t<div id=editDialog>\n\t<form id=editScoresForm name=editScoresForm action=\"\" method=POST>\n\t\t<div id=editScoresDiv></div>\n\t\t<center>\n\t\t<input type=submit id=\"updateScores\" name=\"updateScores\" value=\"Update\" />\n\t\t<input type=reset id=\"cancelUpdateScores\" name=\"cancelUpdateScores\" value=\"Cancel\" />\n\t\t</center>\n\t</form>\n\t</div>"; $t = "Update Scores"; $main .= "<div id=\"editScoresDialog\">" . make_box($t, $editDialog, 'blue') . "</div>"; if (isset($_POST['copyScores'])) { /** * DONT use get_custom_scores as it includes system wide scores also, ONLY * want the teachers scores here!!!! * score_id teacher_id school_year_id code long_name grade */ $result = get_teacher_custom_scores($_SESSION[$_CONF['sess_name'] . '_myUID'], $_POST['from_school_year']); while ($row = $result->fetch_assoc()) { if (empty($row['grade']) && $row['grade'] != '0') { $grade = "NULL"; } else { $grade = $row['grade']; } $sql2 = "INSERT into custom_scores(teacher_id, school_year_id, code, long_name, grade)\n\t\t\tVALUES(" . $_SESSION[$_CONF['sess_name'] . '_myUID'] . ", " . $_SESSION[$_CONF['sess_name'] . '_current_school_year'] . ", '" . $row['code'] . "','" . $row['long_name'] . "'," . $grade . ")"; $result2 = $db->query($sql2); } } /** * list the custom scores for the selected teacher, inlcuding the system wide scores */ $result = get_custom_scores($_SESSION[$_CONF['sess_name'] . '_myUID'], $_SESSION[$_CONF['sess_name'] . '_current_school_year']); $num = 0;
$teacherName = $row2['first_name'] . " " . $row2['last_name']; $web .= "Working on Teacher {" . $teacherName . "}<br />\n"; $result3 = get_user_info($tid); $row3 = $result3->fetch_assoc(); $teacherEmail = $row3['email']; $currentDate = date("F j, Y", time() - 18000); $year = date("y", time() - 18000); if (count($los) > 1) { $pageTitle = $year . "_" . $className . "_" . $termName . "_Progress_Reports.pdf"; } else { list($f, $l) = preg_split("/ /", $sname); $pageTitle = $year . "_" . $className . "_" . $termName . "_" . $l . "," . $f . "_Progress_Report.pdf"; } $classInfo = $className . "Ln()" . "~" . $teacherName . "-" . $termName . "~" . $currentDate; $custom_scores = array(); $result = get_teacher_custom_scores($tid, $currentSchoolYr); while ($row = $result->fetch_assoc()) { $custom_scores[$row['code']] = array("longName" => $row['long_name'], "grade" => $row['grade']); } $sql3 = "SELECT * from categories where class_id=" . $cid; $result3 = $db->query($sql3); $numCats = $result3->num_rows; /** NOW FOR THE PDF STUFF **/ $sh = $ah = 0.2; /** height for assignments & students**/ $sw = 2.25; /** student column width **/ $aw = 3.0; /** settings for the assignment rows **/ $datew = $catw = $scorew = $weightw = $avgw = 1.0; $assignw = 2.5;
} $editScores .= "\n\t</table>\n\t</center>\n\t</form>"; $ret = array('error' => $error, 'message' => $msg, 'editScores' => $editScores); echo json_encode($ret); } if (isset($_POST['deleteScores'])) { $ids = array(); foreach ($_POST as $k => $v) { if (substr($k, 0, 2) == "s_") { array_push($ids, $v); } } $msg = "<h2>Deleting Scores</h2>"; $error = false; $deleteScores = array(); $resCodes = get_teacher_custom_scores($_SESSION[$_CONF['sess_name'] . '_myUID'], $_SESSION[$_CONF['sess_name'] . '_current_school_year']); $score_codes = make_assoc_array_from_sql($resCodes, 'score_id', array('code'), ''); $resCodes->data_seek(0); $score_names = make_assoc_array_from_sql($resCodes, 'score_id', array('long_name'), ''); $count = 0; foreach ($ids as $id) { $msg .= "<h3>Deleting " . $score_names[$id]['long_name'] . " - " . $score_codes[$id]['code'] . ".<br />"; $sql1 = "SELECT count(*) as count\n\t\t\t\tFROM grades\n\t\t\t\tJOIN assignments USING (assignment_id)\n\t\t\t\tJOIN categories USING (category_id)\n\t\t\t\tJOIN classes USING (class_id)\n\t\t\t\tJOIN courses USING (course_id)\n\t\t\t\tJOIN users ON courses.teacher_id = users.user_id\n\t\t\t\tWHERE users.user_id=" . $_SESSION[$_CONF['sess_name'] . '_myUID'] . "\n\t\t\t\tAND courses.school_year_id=" . $_SESSION[$_CONF['sess_name'] . '_current_school_year'] . "\n\t\t\t\tAND grades.raw_score='" . $score_codes[$id]['code'] . "'"; $result1 = $db->query($sql1); $row1 = $result1->fetch_assoc(); $grades = $row1['count']; if ($grades) { $msg .= "<h2>You cannot delete custom score {" . $score_names[$id] . "}, It is used in your gradebook this year.</h2>"; } else { $sql = "DELETE from custom_scores where score_id=" . $id; $result = $db->query($sql);