<?php

if (isset($_POST["box_grades"])) {
    foreach ($_POST["box_grades"] as $f_gscaleid) {
        deleteGrade((int) $f_gscaleid);
    }
} else {
    $f_gscaleid = (int) readGetVar('gscaleid');
    deleteGrade($f_gscaleid);
}
gotoLocation('grades.php' . getURLAddon('', array('action', 'confirmed', 'gscaleid')));
function deleteGrade($i_gscaleid)
{
    global $g_db, $srv_settings;
    if ($i_gscaleid > SYSTEM_GRADES_MAX_INDEX) {
        if ($g_db->Execute("UPDATE " . $srv_settings['table_prefix'] . "tests SET gscaleid=1 WHERE gscaleid=" . $i_gscaleid) === false) {
            showDBError(__FILE__, 1);
        }
        if ($g_db->Execute("DELETE FROM " . $srv_settings['table_prefix'] . "gscales_grades WHERE gscaleid={$i_gscaleid}") === false) {
            showDBError(__FILE__, 2);
        }
        if ($g_db->Execute("DELETE FROM " . $srv_settings['table_prefix'] . "gscales WHERE gscaleid={$i_gscaleid}") === false) {
            showDBError(__FILE__, 3);
        }
    }
}
예제 #2
0
    } else {
        if ($wasdate < $middate) {
            $query = mysql_query("UPDATE registrations SET q1currpoints=(q1currpoints - {$_POST['wasgrade']}), q2currpoints=(q2currpoints + {$_POST['points']}), currentpoints=(currentpoints + {$_POST['points']} - {$_POST['wasgrade']}) WHERE courseid = {$_POST['selectclass']} AND studentid = {$_POST['student']}");
        } else {
            $query = mysql_query("UPDATE registrations SET q2currpoints=(q2currpoints + {$_POST['points']} - {$_POST['wasgrade']}), currentpoints=(currentpoints + {$_POST['points']} - {$_POST['wasgrade']}) WHERE courseid = {$_POST['selectclass']} AND studentid = {$_POST['student']}");
        }
    }
}
// Delete the selected grades //
if ($_POST["deletegrade"] == 1) {
    require_once "DeleteFunctions.php";
    $delete = $_POST["delete"];
    for ($i = 0; $i < sizeof($delete); $i++) {
        $query = mysql_query("SELECT gradeid, points, submitdate, studentid FROM grades WHERE studentid = {$delete[$i]} AND assignmentid = {$_POST['assignment']}");
        $id = mysql_fetch_row($query);
        deleteGrade($id[0]);
        // Subtract the amount off from the current and possible points //
        $query = mysql_query("SELECT midtermdate FROM semesters WHERE startdate < CURDATE() AND CURDATE() < enddate");
        $dates = mysql_fetch_row($query);
        $middate = strtotime($dates[0]);
        $submitdate = strtotime($id[2]);
        if ($submitdate < $middate) {
            $query = mysql_query("UPDATE registrations SET q1currpoints=(q1currpoints - {$id['1']}), currentpoints=(currentpoints - {$id['1']}) WHERE studentid = {$id['3']} AND courseid = {$_POST['selectclass']}");
        } else {
            $query = mysql_query("UPDATE registrations SET q2currpoints=(q2currpoints - {$id['1']}), currentpoints=(currentpoints - {$id['1']}) WHERE studentid = {$id['3']} AND courseid = {$_POST['selectclass']}");
        }
    }
}
print "<script language='JavaScript'>\n\n  // Function to make sure the student wants to delete the grade(s) //\n  function validate()\n  {\n   if( document.grades.selectgrade.value > 0 )\n   {\n\tvar confirmed = confirm(\"Are you sure you want to delete this grade?\");\n\n\tif( confirmed == true )\n\t{\n\t document.grades.submit();\n\t}\n   }\n   else\n   {\n\talert('You must select a grade to delete.');\n   }\n  }\n\n\n  // Function to make sure only one checkbox has been selected //\n  function checkboxes()\n  {\n   if( document.grades.selectgrade.value == 1 )\n   {\n\tdocument.grades.submit();\n   }\n   else\n   {\n\tif( document.grades.selectgrade.value > 1 )\n\t{\n\t alert('You can only edit one grade at a time.');\n\t}\n\telse\n\t{\n\t alert('You must select a grade to edit.');\n\t}\n   }\n  }\n\n\n  // Function to keep track of how many checkboxes are checked //\n  function updateboxes(row)\n  {\n   row = row;\n   if(document.grades.elements[row].checked)\n   {\n\tdocument.grades.selectgrade.value = Math.round(document.grades.selectgrade.value) + 1;\n   }\n   else\n   {\n\tdocument.grades.selectgrade.value = Math.round(document.grades.selectgrade.value) - 1;\n   }\n  }\n </script>\n <h1>Grades</h1>\n <br>\n <table align='center' width='595' cellspacing='0' cellpadding='0' border='0'>\n <tr>\n <td>\n <form name='grades' action='./index.php' method='POST'>\n <b>Assignment:</b>\n <select name='assignment' onChange='document.grades.addgrade.value=0;document.grades.deletegrade.value=0;document.grades.submit();'>";
$query = mysql_query("SELECT * FROM assignments WHERE courseid = '{$_POST['selectclass']}'");
// Stop displaying information if the query returned a null set //