-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_submission.php
46 lines (40 loc) · 1.27 KB
/
create_submission.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require_once 'submission_functions.php';
require_once '../header.html';
session_start();
$errors = array();
if (isset($_POST['coursework']) && isset($_POST['student'])
&& isset($_POST['mark']) && isset($_POST['hand_in_date'])) {
$coursework_id = $_POST['coursework'];
$student_id = $_POST['student'];
if ($_POST['mark']) {
$mark = $_POST['mark'];
} else {
$mark = null;
}
$hand_in_date = $_POST['hand_in_date'];
if (isset($_POST['second_submission'])) {
$second_submission = true;
} else {
$second_submission = false;
}
if (empty($coursework_id)) {
array_push($errors, "Coursework ID is required");
}
if (empty($student_id)) {
array_push($errors, "Student ID is required");
}
if (empty($hand_in_date)) {
array_push($errors, "Hand in date is required");
}
if (count($errors) == 0) {
createSubmission($coursework_id, $student_id, $mark, $hand_in_date, $second_submission);
$_SESSION['success'] = true;
header('location: all_submissions.php');
} else {
foreach ($errors as $error) {
echo '<p>' . $error . '</p>';
}
echo "<p><a href='create_submission_form.php'>Please try again</a></p>";
}
}