示例#1
0
function getNotesForStaff($staffId)
{
    try {
        $query = "SELECT R.ID, S.`Preferred Name`, U.`First Name`, U.`Surname`, G.`Name`, R.`Note`, R.`Date`, DATE_FORMAT(R.`Date`, '%b %D %Y %k:%i') date_format FROM `TREPORTNOTES` R\n            LEFT JOIN TUSERS U ON U.`User ID` = R.`StudentID`\n            LEFT JOIN TSTUDENTS S ON S.`User ID` = R.`StudentID`\n            LEFT JOIN TGROUPS G ON G.`Group ID` = R.GroupID\n            WHERE StaffID = {$staffId} ";
        $query .= "ORDER BY G.Name, U.Surname, R.Date DESC;";
        succeedRequest(db_select_exception($query));
    } catch (Exception $ex) {
        failRequest($ex->getMessage());
    }
}
示例#2
0
function modifyTag($tagid, $name)
{
    $ucname = ucwords($name);
    $query = "UPDATE TTAGS SET `Name` = '{$ucname}' WHERE `Tag ID` = {$tagid};";
    try {
        db_query_exception($query);
        succeedRequest("Tag succesfully updated", []);
    } catch (Exception $ex) {
        failRequest("There was a problem modifying the tag." . $ex->getMessage());
    }
}
示例#3
0
function removeFromGroup($studentid, $groupid)
{
    $query = "UPDATE `TUSERGROUPS` SET `Archived`= 1 WHERE `User ID` = {$studentid} AND `Group ID` = {$groupid};";
    try {
        db_begin_transaction();
        db_query_exception($query);
        db_commit_transaction();
    } catch (Exception $ex) {
        db_rollback_transaction();
        failRequest($ex->getMessage());
    }
    succeedRequest();
}
function generateQuestionsForStudent()
{
    global $studentId, $tagList;
    $tagList = setUpTagList();
    // Create question list for student
    $questions = createQuestionsForStudent($studentId);
    //Compare that to their own tag list
    $scoredQuestions = scoreQuestions($questions);
    if (count($scoredQuestions) > 0) {
        succeedRequest(getWorksheetInformationFor(getFirstSectionOfArray($scoredQuestions, 100, "score")));
    } else {
        succeedRequest(null);
    }
}
示例#5
0
function getSetTagReport($staffId, $setId, $tags)
{
    // Split tags
    $tag_array = convertTagNamesToArray(explode(",", $tags));
    // Get students
    $query = "SELECT * FROM TUSERGROUPS UG " . "JOIN TUSERS U ON UG.`User ID` = U.`User ID` " . "JOIN TSTUDENTS S ON S.`User ID` = U.`User ID` " . "WHERE UG.`Group ID` = {$setId} AND U.`Role` = 'STUDENT';";
    try {
        $students = db_select_exception($query);
    } catch (Exception $ex) {
        failRequestWithException("Error getting students", $ex);
    }
    $stu_string = "AND (";
    foreach ($students as $student) {
        $id = $student["User ID"];
        $stu_string .= "`Student ID` = {$id} OR ";
    }
    if (strlen($stu_string) > 5) {
        $stu_string = substr($stu_string, 0, -4);
        $stu_string .= ")";
    } else {
        $stu_string = "";
    }
    $tag_string = "AND QT.`Tag ID` IN (";
    foreach ($tag_array as $tag) {
        $id = $tag["ID"];
        $tag_string .= "{$id}, ";
    }
    if (strlen($tag_string) > 20) {
        $tag_string = substr($tag_string, 0, -2);
        $tag_string .= ")";
    } else {
        $tag_string = "";
    }
    // Get all completed questions for each student
    $query2 = "SELECT CQ.`Completed Question ID` CQID, CQ.`Mark` Mark, SQ.`Marks` Marks, CQ.`Student ID` StuID, QT.`Tag ID` TagID FROM TCOMPLETEDQUESTIONS CQ \n                JOIN TGROUPWORKSHEETS GW ON CQ.`Group Worksheet ID` = GW.`Group Worksheet ID`\n                JOIN TSTOREDQUESTIONS SQ ON CQ.`Stored Question ID` = SQ.`Stored Question ID`\n                JOIN TQUESTIONTAGS QT ON SQ.`Stored Question ID` = QT.`Stored Question ID`\n                WHERE CQ.`Deleted` <> 1\n                AND GW.`Deleted` <> 1\n                AND GW.`Primary Staff ID` = {$staffId}\n                AND GW.`Group ID` = {$setId} {$stu_string} {$tag_string}";
    try {
        $results = db_select_exception($query2);
    } catch (Exception $ex) {
        failRequestWithException("Error getting results", $ex);
    }
    $final_table = convertResultsToTable($results, $students, $tag_array);
    succeedRequest($final_table);
}
function succeedSummaryRequest($list, $userAvg, $setAvg)
{
    $result = array("summary" => $list, "stuAvg" => $userAvg, "setAvg" => $setAvg);
    succeedRequest($result);
}