Просмотр исходного кода

Add tests remaining alert on Account page

Alan Lam 8 лет назад
Родитель
Сommit
f9961285a2
2 измененных файлов с 19 добавлено и 3 удалено
  1. 6 1
      controllers/account.php
  2. 13 2
      views/account.php

+ 6 - 1
controllers/account.php

@@ -6,6 +6,7 @@ Core::addBreadcrumb("/account", $page_title);
 
 $users_pending_verification = 0;
 $tests_pending_verification = 0;
+$tests_remaining = 0;
 
 $links = [];
 
@@ -30,6 +31,10 @@ if(Core::$user->level >= User::LEVEL_CUSTOMER) {
 if(Core::$user->level >= User::LEVEL_TESTER) {
 	$links["/account/tests"] = "Tests";
 	$links["/account/practice"] = "Practice";
+
+	$tests = Core::$user->getPendingTests();
+	$tests_remaining = count($tests);
+
 }
 
 if(Core::$user->level == User::LEVEL_TESTER) {
@@ -62,7 +67,7 @@ $actions["/account/delete"] = "Delete Account...";
 $referrals = Core::$user->getReferrals();
 
 View::includeOnce("header", compact("page_title"));
-View::include("account", compact("links", "actions", "referrals", "users_pending_verification", "tests_pending_verification"));
+View::include("account", compact("links", "actions", "referrals", "users_pending_verification", "tests_pending_verification", "tests_remaining"));
 View::includeOnce("footer");
 
 ?>

+ 13 - 2
views/account.php

@@ -59,9 +59,9 @@
 		<div class="col-lg mb-3 mb-lg-0">
 
 			<?php
-			$has_to_do = !empty($users_pending_verification) || !empty($tests_pending_verification);
+			$has_to_do = !empty($users_pending_verification) || !empty($tests_pending_verification) || !empty($tests_remaining);
 
-			if($has_to_do && Core::$user->level >= User::LEVEL_ADMIN) {
+			if($has_to_do) {
 				?>
 				<h3>To-Do</h3>
 
@@ -88,6 +88,17 @@
 					</div>
 					<?php
 				}
+				if($tests_remaining) {
+					$s = ($tests_remaining == 1) ? "" : "s";
+					?>
+					<div class="alert alert-info mb-3 d-flex flex-row justify-content-between">
+						<div class="align-self-center">
+							<i class="fal fa-fw fa-info-circle"></i> <?=number_format($tests_remaining)?> test<?=$s?> remaining.
+						</div>
+						<a class="btn btn-primary" href="/account/tests">View</a>
+					</div>
+					<?php
+				}
 			}
 
 			if(Core::$user->level != User::LEVEL_DEACTIVATED && !Core::$user->terms_accepted) {