diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..4bee559 --- /dev/null +++ b/admin.php @@ -0,0 +1,75 @@ +username = $_POST['username']; + $user->firstname = $_POST['first']; + $user->surname = $_POST['sur']; + $user->password = md5($_POST['pass']); + $user->rank = $_POST['rank']; + $user->year = $_POST['year']; + $user->group = $_POST['group']; + $user->save(); + header("location: admin.php"); + die(""); +} + +if ($_GET['id']=="increase"){ + if ($_GET['con']==1){ + $all_users = User::all(); + foreach ($all_users as $user){ + if (is_numeric($user->year)){ + $user->year = $user->year + 1; + $user->save(); + } + } + header("location: admin.php"); + die(""); + }else{ + showHeader("Are you sure?");?> +
+ This will increase all pupils years by 1. +
+ + Increase all years Cancel + +Please be careful in this section!
+ + + + \ No newline at end of file diff --git a/common/common.php b/common/common.php index 41542b6..261712d 100644 --- a/common/common.php +++ b/common/common.php @@ -64,7 +64,7 @@ function getAuthLabel($level){ return "pupil"; else if ($level == AUTH_STAFF) return "staff"; - else if ($level == AUTH_STAFF) + else if ($level == AUTH_ADMIN) return "admin"; else return "lvl($level)"; diff --git a/common/database/user.php b/common/database/user.php index 6442c85..e3a99a9 100644 --- a/common/database/user.php +++ b/common/database/user.php @@ -42,6 +42,26 @@ class User { return "{$res}"; } + // Update existing record + private function update($id, $col, $value, $int=false){ + // Update a field in an existing record + global $handle; + $res = ""; + if ($int){ + // Update integer field + if (!is_numeric($value)){ + echo "inputed value is not numeric! ($id, $col, $value, $int)
"; + return; + } + $res = "UPDATE user SET $col = $value WHERE userID = $id"; + }else{ + // Update string field + $res = "UPDATE user SET $col = '$value' WHERE userID = $id"; + } + // Run update query + $handle->query($res) or die("inputed value is not numeric! ($id, $col, $value, $int)
"; - return; - } - $res = "UPDATE user SET $col = $value WHERE userID = $id"; - }else{ - // Update string field - $res = "UPDATE user SET $col = '$value' WHERE userID = $id"; - } - - // Run update query - $handle->query($res) or die("".$a->test()->title." | "; + // Show correct button - retake or take. if (!$res || count($res)==0) echo "test()->id)."\">Take"; else @@ -32,6 +43,7 @@ if ($current_user->isPupil()){ echo " |
Score | Incorrect words |
---|---|
{$s->score} | "; + + // Get the words they got wrong, and print them. $ww = $s->wrongWords(); if ($ww){ echo ""; @@ -61,7 +72,7 @@ if ($current_user->rank == 1 || $_GET['user']){ if ($comma) echo ", "; - echo $w->word; + echo "'".$w->word."'"; $comma = true; } echo ""; @@ -72,28 +83,33 @@ if ($current_user->rank == 1 || $_GET['user']){ } echo " |
id}\" class=\"button\">Back"; else echo "
id}\" class=\"button\">Retake test"; - echo "View Report
"; } }else if($current_user->rank > 1){ + // Get users that this test applies to $users = $test->users(); if (!$users || count($users)<1){ + // Display message echo "No pupils are to take this testUser | Score | Attempts | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
{$u->surname} {$u->firstname} | "; + // Declare score here, so it is in the correct scope $score = -1; // Load score submissions $scr = Score::_search("WHERE userID = {$u->id} AND testID = {$test->id}"); - if ($scr){ foreach ($scr as $s){ if ($s->score > $score || $score == -1){ @@ -102,6 +118,7 @@ if ($current_user->rank == 1 || $_GET['user']){ } } + // Display score and attempts if (!$scr || count($scr)<1){ echo "Test not taken yet! | "; }else{ diff --git a/users.php b/users.php index feadde9..f5f8bf0 100644 --- a/users.php +++ b/users.php @@ -12,16 +12,18 @@ $rank = $_GET['rank']; if (($year!=null && !is_numeric($year)) || ($rank!=null && !is_numeric($rank))) msgscrn("Query blocked","Your search terms are invalid.","",""); -$q = ""; +$query = ""; +// Add surname filter to query if ($surname) - $q .= "surname LIKE '$surname'"; + $query .= "surname LIKE '$surname'"; +// Add rank filter to query if ($rank) - $q .= (($q!="")?" AND ":"") . "rank = $rank"; // The ? here adds ' AND ' if there was a previous condition + $query .= (($query!="")?" AND ":"") . "rank = $rank"; // The ? here adds ' AND ' if there was a previous condition // Get tests -$users = User::_search( ($q!="")? "WHERE $q" : "" ); // The ? here adds 'WHERE' if there is a query +$users = User::_search( ($query!="")? "WHERE $query" : "" ); // The ? here adds 'WHERE' if there is a query // Show test player page showHeader("User Search"); @@ -40,8 +42,10 @@ echo "
Name | Year | Group | Controls |
---|---|---|---|
{$u->surname}, {$u->firstname} | {$u->year} | {$u->group} | id}\" class=\"button\">Profile |