Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum fix to make it work with php8.2 #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions admin/assets/vendor/SpreadsheetReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ private static function Load($Type)
* Rewind the Iterator to the first element.
* Similar to the reset() function for arrays in PHP
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this -> Index = 0;
Expand All @@ -245,7 +246,7 @@ public function rewind()
*
* @return mixed current element from the collection
*/
public function current()
public function current(): mixed
{
if ($this -> Handle)
{
Expand All @@ -258,6 +259,7 @@ public function current()
* Move forward to next element.
* Similar to the next() function for arrays in PHP
*/
#[\ReturnTypeWillChange]
public function next()
{
if ($this -> Handle)
Expand All @@ -266,7 +268,7 @@ public function next()

return $this -> Handle -> next();
}
return null;
return;
}

/**
Expand All @@ -275,6 +277,7 @@ public function next()
*
* @return mixed either an integer or a string
*/
#[\ReturnTypeWillChange]
public function key()
{
if ($this -> Handle)
Expand All @@ -290,7 +293,7 @@ public function key()
*
* @return boolean FALSE if there's nothing more to iterate over
*/
public function valid()
public function valid(): bool
{
if ($this -> Handle)
{
Expand All @@ -300,7 +303,7 @@ public function valid()
}

// !Countable interface method
public function count()
public function count(): int
{
if ($this -> Handle)
{
Expand All @@ -315,7 +318,7 @@ public function count()
*
* @param int Position in file
*/
public function seek($Position)
public function seek(int $Position): void
{
if (!$this -> Handle)
{
Expand All @@ -342,7 +345,6 @@ public function seek($Position)
}
}

return null;
return;
}
}
?>
2 changes: 1 addition & 1 deletion admin/assets/vendor/excel_reader2.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ function fontRecord($row,$col,$sheet=0) {
}
return null;
}
function fontProperty($row,$col,$sheet=0,$prop) {
function fontProperty($row,$col,$sheet,$prop) {
$font = $this->fontRecord($row,$col,$sheet);
if ($font!=null) {
return $font[$prop];
Expand Down
8 changes: 6 additions & 2 deletions admin/files/statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
<?php
include '../../database/config.php';
$user_id = $_SESSION["user_id"];
$sql = "select * from tests where teacher_id = $user_id and status_id = 3";
$sql = "select tests.* , status.name as status from tests JOIN status ON tests.status_id = status.id where teacher_id = $user_id and status_id IN (2, 3)";

$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
Expand All @@ -86,7 +87,10 @@
<div class="col-md-8">
<p>Subject - <?= $row["subject"];?></p>
</div>
<div class="col-md-4">
<div class="col-md-2">
<p style="text-align:right;">Status - <?= $row["status"];?></p>
</div>
<div class="col-md-2">
<p style="text-align:right;">Date - <?= $row["date"];?></p>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions admin/files/test_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$test_date = $_POST['test_date'];
$total_questions = $_POST['total_questions'];
$test_status = $_POST['test_status'];
$test_class = $_POST['test_class'];
// $test_class = $_POST['test_class'];
$status_id = $class_id = -1;
$general_settings = false;

Expand Down Expand Up @@ -45,10 +45,12 @@ function generateRandomString($length = 8) {
return $randomString;
}

$other_settings = false;
$complete = false;
$delete = false;
if(isset($_POST['other_settings'])) {
$test_id = $_POST['test_id'];
$student_roll_no = $_POST['student_roll_no'];
$other_settings = false;

$temp = 8 - strlen($test_id);
$random = generateRandomString($temp);
Expand All @@ -73,7 +75,6 @@ function generateRandomString($length = 8) {
if(isset($_POST['completed'])) {
$test_id = $_POST['test_id'];
$complete_id = -1;
$complete = false;
$sql1= "select id from status where name LIKE 'completed'";
$result1 = mysqli_query($conn,$sql1);
$row1 = mysqli_fetch_assoc($result1);
Expand All @@ -87,7 +88,6 @@ function generateRandomString($length = 8) {

if(isset($_POST['deleted'])) {
$test_id = $_POST['test_id'];
$delete = false;
$sql1= "DELETE from question_test_mapping WHERE test_id = $test_id";
$result1 = mysqli_query($conn,$sql1);

Expand Down
7 changes: 7 additions & 0 deletions database/config_sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
//database configurations
define("DB_HOST","localhost");
define("DB_UNAME","YOUR_DATABASE_USER_NAME");
define("DB_PASS","YOUR_DATABASE_PASSWORD");
define("DB_DNAME","YOUR_DATABASE_NAME");
$conn=mysqli_connect(DB_HOST,DB_UNAME,DB_PASS,DB_DNAME);
78 changes: 43 additions & 35 deletions files/check_answer.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
<?php
session_start();
session_start();

include '../database/config.php';
$selected_option = $_POST['selected_option'];
$question_id = $_POST['question_id'];
$score_earned = $_POST['score'];
$student_details = json_decode($_SESSION['student_details']);
$student_id;
include '../database/config.php';
$selected_option = $_POST['selected_option'];
$question_id = $_POST['question_id'];
$score_earned = $_POST['score'];
$student_details = json_decode($_SESSION['student_details']);
$student_id;

foreach($student_details as $obj){
$student_id = $obj->id;
$test_id = $obj->test_id;
}

if (!$conn)
die("Connection failed: " . mysqli_connect_error());
else{
$result = mysqli_query($conn, "SELECT id FROM Questions WHERE id = '".$question_id."' AND correctAns = '".$selected_option."' LIMIT 1 ");
if (mysqli_num_rows($result) > 0){
//increase question corerct count
$sql = "UPDATE score set correct_count = correct_count + 1 where question_id = '$question_id'";
mysqli_query($conn,$sql);
if(mysqli_query($conn, "UPDATE students set score = score + '".$score_earned."' where id = '".$student_id."' ")){
echo "SCORE_UPDATED_SUCCESSFULLY";
}else{
echo "SCORE_UPDATE_FAILURE";
}
}
else {
//increase question wrong count
$sql = "UPDATE score set wrong_count = wrong_count + 1 where question_id = '$question_id'";
mysqli_query($conn,$sql);
echo "WRONG_ANSWER";
}
}
foreach ($student_details as $obj)
{
$student_id = $obj->id;
$test_id = $obj->test_id;
}

mysqli_close($conn);
?>
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
else
{
$result = mysqli_query($conn, "SELECT id FROM Questions WHERE id = '" . $question_id . "' AND correctAns = '" . $selected_option . "' LIMIT 1 ");
if (mysqli_num_rows($result) > 0)
{
//increase question corerct count
$sql = "UPDATE score set correct_count = correct_count + 1 where question_id = '$question_id'";
mysqli_query($conn, $sql);
if (mysqli_query($conn, "UPDATE students set score = score + '" . $score_earned . "' where id = '" . $student_id . "' "))
{
echo "SCORE_UPDATED_SUCCESSFULLY";
}
else
{
echo "SCORE_UPDATE_FAILURE";
}
}
else
{
//increase question wrong count
$sql = "UPDATE score set wrong_count = wrong_count + 1 where question_id = '$question_id'";
mysqli_query($conn, $sql);
echo "WRONG_ANSWER";
}
}

mysqli_close($conn);
Loading