0

我正在创建一个等级系统,并且我已经完成了所有期望的系统。我在做整体成绩行时遇到了麻烦。它应该验证所有成绩行,如果它符合标准,则设置一个整体成绩。我已经为它创建了一个函数,但是 = 我似乎无法让它正常工作。这是代码。

function change_overall_grade($username, $y1g, $y2g) {
$user_id    = user_id_from_username($username);

$newOverallGrade = '';
$courses_sql    = "SELECT `unit_id` FROM `courses` WHERE `$y1g` = 1 OR `$y2g` = 1 LIMIT 18";
$courses_query  = mysql_query($courses_sql);
while($row = mysql_fetch_row($courses_query)) {
    $unit_id = $row[0];

    $unit_sql = "SELECT * FROM `unit_$unit_id` WHERE `student_id` = '$user_id'";
    $unit_query = mysql_query($unit_sql);
    $row = mysql_fetch_row($unit_query);
    $overall_grade = $row[3];
    $p1 = $row[5];$p2 = $row[6];$p3 = $row[7];$p4 = $row[8];$p5 = $row[9];$p6 = $row[10];$p7 = $row[11];$p8 = $row[12];$p9 = $row[13];
    $m1 = $row[14];$m2 = $row[15];$m3 = $row[16];$m4 = $row[17];
    $d1 = $row[18];$d2 = $row[19];$d3 = $row[20];

    if($p1 == "-" || $p1 == "S" || $p1 == "N1" || $p1 == "N2" || $p1 == "N3" || $p1 == "X1" || $p1 == "X2" || $p1 == "X3" || $p2 == "-" || $p2 == "S" || $p2 == "N1" || $p2 == "N2" || $p2 == "N3" || $p2 == "X1" || $p2 == "X2" || $p2 == "X3" || $p3 == "-" || $p3 == "S" || $p3 == "N1" || $p3 == "N2" || $p3 == "N3" || $p3 == "X1" || $p3 == "X2" || $p3 == "X3" || $p4 == "-" || $p4 == "S" || $p4 == "N1" || $p4 == "N2" || $p4 == "N3" || $p4 == "X1" || $p4 == "X2" || $p4 == "X3" || $p5 == "-" || $p5 == "S" || $p5 == "N1" || $p5 == "N2" || $p5 == "N3" || $p5 == "X1" || $p5 == "X2" || $p5 == "X3" || $p6 == "-" || $p6 == "S" || $p6 == "N1" || $p6 == "N2" || $p6 == "N3" || $p6 == "X1" || $p6 == "X2" || $p6 == "X3" || $p7 == "-" || $p7 == "S" || $p7 == "N1" || $p7 == "N2" || $p7 == "N3" || $p7 == "X1" || $p7 == "X2" || $p7 == "X3" || $p8 == "-" || $p8 == "S" || $p8 == "N1" || $p8 == "N2" || $p8 == "N3" || $p8 == "X1" || $p8 == "X2" || $p8 == "X3" || $p9 == "-" || $p9 == "S" || $p9 == "N1" || $p9 == "N2" || $p9 == "N3" || $p9 == "X1" || $p9 == "X2" || $p9 == "X3") {
        $newOverallGrade = "NO GRADE";
    } else {
        if($p1 == "A" || $p1 == "NA"  && $p2 == "A" || $p2 == "NA" && $p3 == "A" || $p3 == "NA" && $p4 == "A" || $p4 == "NA" && $p5 == "A" || $p5 == "NA" && $p6 == "A"  || $p6 == "NA" && $p7 == "A" || $p7 == "NA" && $p8 == "A" || $p8 == "NA" && $p9 == "A" || $p9 == "NA") {
            $newOverallGrade = "Pass";

            if( $p1 == "A" || $p1 == "NA"  && $p2 == "A" || $p2 == "NA" && $p3 == "A" || $p3 == "NA" && $p4 == "A" || $p4 == "NA" && $p5 == "A" || $p5 == "NA" && $p6 == "A"  || $p6 == "NA" && $p7 == "A" || $p7 == "NA" && $p8 == "A" || $p8 == "NA" && $p9 == "A" || $p9 == "NA" && $m1 == "A" || $m1 == "NA" && $m2 == "A" || $m2 == "NA" && $m3 == "A" || $m3 == "NA" && $m4 == "A" || $m4 == "NA") {
                $newOverallGrade = "Merit";

                if($p1 == "A" || $p1 == "NA"  && $p2 == "A" || $p2 == "NA" && $p3 == "A" || $p3 == "NA" && $p4 == "A" || $p4 == "NA" && $p5 == "A" || $p5 == "NA" && $p6 == "A"  || $p6 == "NA" && $p7 == "A" || $p7 == "NA" && $p8 == "A" || $p8 == "NA" && $p9 == "A" || $p9 == "NA" && $m1 == "A" || $m1 == "NA" && $m2 == "A" || $m2 == "NA" && $m3 == "A" || $m3 == "NA" && $m4 == "A" || $m4 == "NA" && $d1 == "A" || $d1 == "NA"  && $d2 == "A" || $d2 == "NA" && $d3 == "A" || $d3 == "NA") {
                    $newOverallGrade = "Distinction";
                } 
            }
        }
    }


    $sql = "UPDATE `unit_$unit_id` SET `overall_grade` = '$newOverallGrade' WHERE `student_id` = '$user_id'";
    $query = mysql_query($sql);
}

编辑 每个科目显示的总 成绩每个科目显示的总成绩

这是我认为可以做到的方式,但我错了。有谁知道我做错了什么并愿意提供帮助?

提前致谢

克里斯

4

0 回答 0