Ejemplo n.º 1
0
 public function setScores($score_arr)
 {
     $conn = Connection::getInstance("write");
     $class = new SchoolClass($this->class_id);
     $subjects = $class->getSubjectsID();
     $i = 0;
     $sub_command = null;
     foreach ($subjects as $id) {
         $score = $score_arr[$i];
         $sub_command .= "({$this->id}, {$id}, {$score}, {$this->student_id}, '{$this->year}', {$this->term_id})";
         if ($i < count($subjects) - 1) {
             $sub_command .= ",";
         }
         $i++;
     }
     $command = "REPLACE INTO scores (ass_id, subject_id, score, student_id, year, term_id)\n\t\t\t\t\tVALUES {$sub_command}";
     return $conn->execInsert($command);
 }
Ejemplo n.º 2
0
<?php

include "../../includes/functions.inc";
if (Tools::valuePost("action") == "set") {
    $scores = Tools::valuePost("scores");
    $scores = explode(",", $scores);
    //print_r($raw_scores);
    $assID = 'NULL';
    if (Tools::valuePost("assID")) {
        //THIS IS TO UPDATE EXISTING ASSESSMENTS
        $assessment = new Assessment(Tools::valuePost("assID"));
        //$assessment->getClassID();
        $ass_class = new SchoolClass($assessment->getClassID());
        $subjects = $ass_class->getSubjectsID();
        $assessment->setScores($scores);
    } else {
        //THIS IS TO INSERT NEW ASSESSMENTS
        $student = new Student(Tools::valuePost("student"));
        if ($ass_id = $student->addAssessment($user->getID(), Tools::valuePost("year"), Tools::valuePost("term"))) {
            $assessment = new Assessment($ass_id);
            $assessment->setScores($scores);
            echo $ass_id;
        }
    }
}
if (Tools::valuePost("action") == "delete") {
    $assessment = new Assessment(Tools::valuePost("id"));
    $assessment->delete();
}
Ejemplo n.º 3
0
<?php

require_once "../../includes/functions.inc";
print_r($_POST);
if (Tools::valuePost("action") == "edit") {
    foreach ($_POST['id'] as $key) {
        $level = Tools::cleanString($_POST['class'][$key]);
        $arm = Tools::cleanString($_POST['arm'][$key]);
        $sort = Tools::cleanString($_POST['sort'][$key]);
        if ($level and $arm and $sort) {
            $class = new SchoolClass(Tools::cleanString($key));
            $class->update($level, $arm, $sort);
        } else {
            Tools::redirect("../../classes.php?status=1");
        }
    }
    Tools::redirect("../../classes.php");
} elseif (Tools::valuePost("action") == "new") {
    foreach ($_POST['id'] as $key => $value) {
        print_r($_POST);
        $level = Tools::cleanString($_POST['class'][$key]);
        $arm = Tools::cleanString($_POST['arm'][$key]);
        if ($level and $arm) {
            if ($school->addClass($level, $arm)) {
                Tools::redirect("../../classes.php?status=2");
            }
        } else {
            Tools::redirect("../../classes.php?status=3");
        }
    }
    Tools::redirect("../../classes.php");