function newWorksheetForGroup($staff, $setid, $worksheetid, $duedate, $level, $type) { global $userid, $userval; $postData = array("type" => "NEW", "userid" => $userid, "userval" => $userval); if (isset($staff[0])) { $postData["staff"] = $staff[0]; } if (isset($staff[1])) { $postData["addstaff1"] = $staff[1]; } if (isset($staff[2])) { $postData["addstaff2"] = $staff[2]; } if (isset($setid)) { $postData["set"] = $setid; } if (isset($worksheetid)) { $postData["worksheet"] = $worksheetid; } if (isset($duedate)) { $postData["datedue"] = $duedate; } $response = sendCURLRequest("/requests/setGroupWorksheet.php", $postData); $respArray = json_decode($response[1], TRUE); if ($respArray["result"]) { $gwid = $respArray["gwid"]; // Go to page to enter the results header("Location: ../editSetResults.php?gwid={$gwid}"); exit; } else { // Failure errorLog("Adding the new worksheet failed with error: " . $response[1]); returnToPageError("Something went wrong creating the new set of results.", $level, $type, $setid, $staff[0]); } }
header($resultArray[1]); exit; } if (!authoriseUserRoles($userRole, ["SUPER_USER", "STAFF"])) { header("Location: unauthorisedAccess.php"); exit; } $gwid = filter_input(INPUT_GET, 'gwid', FILTER_SANITIZE_NUMBER_INT); $query1 = "SELECT S.`User ID`, S.`Initials` FROM TSTAFF S \r\n JOIN TUSERS U ON S.`User ID` = U.`User ID`\r\n ORDER BY U.`Surname`;"; try { $staff = db_select_exception($query1); } catch (Exception $ex) { $staff = array(); } $postData = array("gwid" => $gwid, "type" => "WORKSHEETFORGWID", "userid" => $userid, "userval" => $userval); $resp = sendCURLRequest("/requests/getWorksheet.php", $postData); $respArray = json_decode($resp[1], TRUE); $success = $respArray["success"]; if ($success) { $details = $respArray["details"]; $worksheet = $respArray["worksheet"]; $results = $respArray["results"]; $completedWorksheets = $respArray["completedWorksheets"]; $notes = $respArray["notes"]; $students = $respArray["students"]; } else { $message = new Message("ERROR", "Something went wrong loading the results, please try again"); } function getArrayValueForKey($array, $key) { return array_key_exists($key, $array) ? $array[$key] : null;
} $message = filter_input(INPUT_GET, 'msg', FILTER_SANITIZE_STRING); $type = filter_input(INPUT_GET, 'err', FILTER_SANITIZE_STRING); } catch (Exception $ex) { errorLog($ex->getMessage()); $success = FALSE; $message = "There was an error loading the markbook."; $type = "ERROR"; } try { $set = db_select_single_exception("SELECT Name FROM TGROUPS WHERE `Group ID` = {$setId};", "Name"); } catch (Exception $ex) { $set = ""; } $postData = array("set" => $setId, "staff" => $staffId, "type" => "MARKBOOKFORSETANDTEACHER", "userid" => $userid, "userval" => $userval); $resp = sendCURLRequest("/requests/getMarkbook.php", $postData); $respArray = json_decode($resp[1], TRUE); if ($respArray["success"]) { $success = isset($success) ? $success : TRUE; $students = $respArray["students"]; $worksheets = $respArray["worksheets"]; $results = $respArray["results"]; $blankCols = max([10 - count($results), 0]); $noStudents = count($students) == 0; } else { $success = FALSE; $message = "There was an error loading the markbook."; $type = "ERROR"; } ?>
$worksheetColumns = array("gwid", "dateDueMain", "staff1", "staff2", "staff3", "studentNotes", "staffNotes", "hidden"); $worksheetDetails = array(); foreach ($worksheetColumns as $variable) { $worksheetDetails[$variable] = $_POST[$variable]; } $gwid = $worksheetDetails["gwid"]; //Set up completed worksheets $notes = $_POST["notes"]; $daysLate = $_POST["dates"]; $cwid = $_POST["ids"]; $completionStatus = $_POST["completion"]; $completedWorksheets = array("notes" => $notes, "dates" => $daysLate, "completion" => $completionStatus, "cwid" => $cwid); try { $postData = array("details" => $worksheetDetails, "newResults" => $newResults, "compWorksheets" => $completedWorksheets, "type" => "UPDATE", "userid" => $userid, "userval" => $userval); $data = array("data" => json_encode($postData)); $resp = sendCURLRequest("/requests/setWorksheetResult.php", $data); $respArray = json_decode($resp[1], TRUE); if (!$respArray["result"]) { //Failure failWithMessage($gwid, $respArray["message"]); } } catch (Exception $ex) { $message = "There was an error saving the results, please try again."; failWithMessageAndException($gwid, $message, $ex); } $message = 'Results succesfully updated.'; completeWithMessage($gwid, $message); function failWithMessage($gwid, $message) { $type = 'ERROR'; $_SESSION['message'] = new Message($type, $message);