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

Add nighttime paragraph in allocation/claim emails

Alan Lam 8 лет назад
Родитель
Сommit
63317c9832
2 измененных файлов с 25 добавлено и 0 удалено
  1. 12 0
      engine/project.php
  2. 13 0
      engine/test.php

+ 12 - 0
engine/project.php

@@ -78,6 +78,18 @@ class Project extends Model {
 		}
 	}
 
+	public function isAnytime() {
+		return $this->time_of_day == "A";
+	}
+
+	public function isDaytime() {
+		return $this->time_of_day == "D";
+	}
+
+	public function isNighttime() {
+		return $this->time_of_day == "N";
+	}
+
 	public function isPastDeadline() {
 		$deadline_unix = Util::getUnixTimeFromUTC($this->dts_deadline);
 		return time() > $deadline_unix;

+ 13 - 0
engine/test.php

@@ -46,6 +46,7 @@ class Test extends Model {
 
 		$tester = $this->getTester();
 		$location = $this->getLocation();
+		$project = $this->getProject();
 
 		// Content
 		$name = htmlspecialchars($tester->first_name);
@@ -60,9 +61,15 @@ class Test extends Model {
 		$builder = new EmailBuilder;
 		$builder->addParagraph("<b>Hi $name,</b>");
 		$builder->addLeadParagraph("Congrats, you have been allocated a test!");
+
+		if($project->isNighttime()) {
+			$builder->addParagraph("<b><font color=\"red\">Evening Test to be done between 7PM and midnight.</font></b>");
+		}
+
 		if($message) {
 			$builder->addParagraph($message);
 		}
+
 		$builder->addParagraph("We need you to confirm if you are able to do the test. Please check the details below and then confirm by pressing the <b>Accept</b> or <b>Decline</b> buttons and once you tap <b>Accept</b>, the test will be allocated to you.");
 		$builder->addAcceptDeclineButtons($base_url);
 		$builder->addParagraph("The site address is: <b>$address</b>");
@@ -86,6 +93,7 @@ class Test extends Model {
 
 		$tester = $this->getTester();
 		$location = $this->getLocation();
+		$project = $this->getProject();
 
 		// Content
 		$name = htmlspecialchars($tester->first_name);
@@ -96,6 +104,11 @@ class Test extends Model {
 		$builder = new EmailBuilder;
 		$builder->addParagraph("<b>Hi $name,</b>");
 		$builder->addLeadParagraph("Congrats, you have claimed a test!");
+
+		if($project->isNighttime()) {
+			$builder->addParagraph("<b><font color=\"red\">Evening Test to be done between 7PM and midnight.</font></b>");
+		}
+
 		$builder->addParagraph("The site address is: <b>$address</b>");
 		$builder->addParagraph("The date that need to complete and submit the results by is: <font color=\"red\"><b>$date_due</b></font>");
 		$builder->addParagraph("For methodology and further notes please check the <b>Useful Documents</b> section on the <b>Account</b> page.");