-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment.php
144 lines (116 loc) · 3.76 KB
/
Assignment.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include_once 'functions.php';
/**
* Used to give assignments to students. It's the main platform through which
* lecturer can provide assignments to his/her students
*
* @author Alhassan Kamil
*/
class Assignment {
private $question, $course, $given_date, $submit_date, $submit_time;
private $lecturer, $submission_method, $submission_format, $other;
private $table = "assignments";
public function __construct() {
}
function get_assignments(){
$query = "select id, question, course, submit_date,lecturer from $this->table"
. " order by submit_date";
$stmt = $this->db_connect->query($query);
return $stmt;
}
function get_assignment($id){
if(is_okay($id)){
$id = clean_data($id);
$query = "select * from $this->table where id = $id";
$stmt = $this->db_connect->query($query);
return $stmt;
}
}
public function get_given_date() {
return $this->given_date;
}
public function get_lecturer() {
return $this->lecturer;
}
public function get_submission_method() {
return $this->submission_method;
}
public function get_submission_format() {
return $this->submission_format;
}
public function get_other() {
return $this->other;
}
public function set_given_date($given_date) {
$this->given_date = $given_date;
return $this;
}
public function set_lecturer($lecturer) {
$this->lecturer = $lecturer;
return $this;
}
public function set_submission_method($submission_method) {
$this->submission_method = $submission_method;
return $this;
}
public function set_submission_format($submission_format) {
$this->submission_format = $submission_format;
return $this;
}
public function set_other($other) {
$this->other = $other;
return $this;
}
public function get_question(){
return $this->question;
}
public function get_course(){
return $this->course;
}
public function get_submit_date(){
return $this->submit_date;
}
public function get_sumit_time(){
return $this->submit_time;
}
public function set_question($question){
$this->question = $question;
}
function set_course($course){
$this->course = $course;
}
function set_submit_date($date_){
$this->submit_date = $date_;
}
function set_submit_time($time_){
$this->submit_time = $time_;
}
function insert(){
$conn = get_connection_handle();
$stmt = $conn->prepare("INSERT INTO assignments(question, course, given_date,
submit_date,submit_time,lecturer,submission_method,submission_format,added_on)
VALUES(?,?,?,?,?,?,?,?,?)");
$dat = new DateTime();
$date = $dat->format("Y-m-d H:i:sa");
$given_date = $dat->format("Y-m-d");
$stmt->bind_param('sssssssss',$this->question,$this->course,$given_date,
$this->submit_date, $this->submit_time,$this->lecturer, $this->submission_method,
$this->submission_format, $date);
$stmt->execute();
if($stmt->affected_rows == 0){
return true;
}
return false;
}
function finish_create($time=NULL,$method=NULL, $format=NULL, $other=NULL){
$stmt = $this->db_connect->prepare("UPDATE assignments SET submit_time = ?,"
. "submission_method = ?,submission_format = ?, other = ?)");
$stmt->bind_params('ssss',$time,$method,$format,$other);
$stmt->execute();
$rows = show_affected_rows($stmt);
if($rows > 0){
return $rows;
}
return FALSE;
}
}