foreach ($exercises as $exercise) { $submitted[$exercise] = array(); } foreach ($submissions as $submission) { $submitted[$submission->getExerciseId()][] = $submission->getLeaderId(); } $noSubmission = array(); foreach ($exercises as $exercise) { $noSubmission[$exercise] = array_diff($users[$exercise], $submitted[$exercise]); } unset($submitted); unset($users); $failure = false; foreach ($noSubmission as $exercise => $exerciseUsers) { foreach ($exerciseUsers as $user) { if (createSubmission($user, $exercise) === null) { $failure = true; break; } } if ($failure) { break; } } if (!$failure) { $assignMakeNotifications[] = MakeNotification("success", Language::Get('main', 'successMake', $langTemplate)); } else { $assignMakeNotifications[] = MakeNotification("error", Language::Get('main', 'errorMake', $langTemplate)); } } else { $assignMakeNotifications[] = MakeNotification("error", Language::Get('main', 'errorMake', $langTemplate));
/** * Stores a marking in the database. * * @param $points The points of the marking * @param $tutorComment The tutor's comment * @param $status The status of the marking * @param $submissionID The id of the submission, if set, -1 otherwise * @param $markingID The id of the marking, if set, -1 otherwise * @param $leaderID The id of the group leader * @param $tutorID The id of the tutor who creates the marking * @param $eID The id of the exercisesheet * * @return bool Returns true on success, false otherwise */ function saveMarking($points, $tutorComment, $status, $submissionID, $markingID, $leaderID, $tutorID, $eID) { global $databaseURI; // submission and marking already exist and don't // need to be created before adding the marking data if ($submissionID != -1 && $markingID != -1) { $newMarking = Marking::createMarking($markingID, $tutorID, null, null, $tutorComment, null, $status, $points, time()); $newMarking = Marking::encodeMarking($newMarking); $URI = $databaseURI . "/marking/{$markingID}"; http_put_data($URI, $newMarking, true, $message); if ($message != 201) { return false; } else { return true; } } elseif ($submissionID != -1 && $markingID == -1) { // only the submission exists, the marking still // needs to be created before adding the marking data // creates the marking in the database $marking = createMarking($points, $tutorComment, $status, $submissionID, $tutorID); if (empty($marking)) { return false; } else { return true; } } elseif ($submissionID == -1 && $markingID == -1) { // neither the submission nor the marking exist - they both // need to be created before adding the marking data // creates the submission in the database $submission = createSubmission($leaderID, $eID); if (!empty($submission)) { // creates the marking in the database $submissionID = $submission['id']; $marking = createMarking($points, $tutorComment, $status, $submissionID, $tutorID); if (!empty($marking)) { return true; } else { return false; } } else { return false; } } }