Skip to content

Commit

Permalink
Fix teachers name size, move about/rules buttons in bottom, fix selec…
Browse files Browse the repository at this point in the history
…t style
  • Loading branch information
AsteroidusTv committed May 18, 2024
2 parents ed819d2 + 1fd1ac7 commit 98bc9a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
24 changes: 20 additions & 4 deletions api/getTeachers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

$searchQuery = $db->escapeStrings($_GET["searchQuery"]);


if(isset($searchQuery)){
$teachers = $db->select("SELECT * FROM cescoleaks_teachers WHERE name LIKE '%$searchQuery%' ORDER BY name");
}else {
Expand All @@ -31,12 +32,27 @@
}

$teacher["votes_count"] = $votesCount;
$teacher["teaching_quality"] = ($votesCount > 0) ? round($teachingQualityTotal / $votesCount) : 0;
$teacher["kindness"] = ($votesCount > 0) ? round($kindnessTotal / $votesCount) : 0;
$teacher["authority"] = ($votesCount > 0) ? round($authorityTotal / $votesCount) : 0;
$teacher["humor"] = ($votesCount > 0) ? round($humorTotal / $votesCount) : 0;
$teacher["teaching_quality"] = ($votesCount > 0) ? $teachingQualityTotal / $votesCount : 0;
$teacher["kindness"] = ($votesCount > 0) ? $kindnessTotal / $votesCount : 0;
$teacher["authority"] = ($votesCount > 0) ? $authorityTotal / $votesCount : 0;
$teacher["humor"] = ($votesCount > 0) ? $humorTotal / $votesCount : 0;
}

usort($teachers, function ($a, $b) {
$db = new Database;
$sort = $db->escapeStrings($_GET["sort"]);

if($sort == "best_score"){
return $b["teaching_quality"] + $b["kindness"] + $b["authority"] + $b["humor"] - $a["teaching_quality"] - $a["kindness"] - $a["authority"] - $a["humor"];
}elseif($sort == "most_votes"){
return $b["votes_count"] - $a["votes_count"];
}elseif($sort == "less_votes"){
return $b["votes_count"] - $a["votes_count"];
}elseif($sort == "worst_score"){
return $a["teaching_quality"] - $a["kindness"] - $a["authority"] - $a["humor"] - $b["teaching_quality"] + $b["kindness"] + $b["authority"] + $b["humor"];
}
});

echo json_encode($teachers);

?>
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ <h1 class="main-header-title-text2">cl</h1>
</header>

<select name="sort-teachers" id="sortTeachers" class="standard-select">
<<<<<<< HEAD
<option value="best-rating">Le meilleur score</option>
<option value="worst-rating">Le pire score</option>
<option value="most-ratings">Le plus de votes</option>
<option value="least-ratings">Le moins de votes</option>
=======
<option value="alphabet">A..Z</option>
<option value="best_score">Le meilleur score</option>
<option value="worst_score">Le pire score</option>
<option value="most_votes">Le plus de votes</option>
<option value="least_votes">Le moins de votes</option>
>>>>>>> 1fd1ac7cc0563b444824039841b64c781b55694d
</select>

<main id="profCards">
Expand Down

0 comments on commit 98bc9a2

Please sign in to comment.