Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

My Schools additional tasks

<?php

//Students class average <70%:
//Dear Alena Holligan,
//We look forward to seeing you at summer school, beginning July 1st!

//Student class average >=70% and current grade 9
//Dear Alena Holligan,
//Congratulations on completing your freshman year in High School! We’ll see you on 
September 1st for the start of your sophomore year!

//Student class average >=70% and current grade 10
//Dear Alena Holligan,
//Congratulations on completing your sophomore year in High School! We’ll see you on 
September 1st for the start of your junior year!

//Student class average >=70% and current grade 11
//Dear Alena Holligan,
//Congratulations on completing your junior year in High School! We’ll see you on 
September 1st for the start of your senior year!

//Student class average >= 70% and current grade 12
//Dear Alena Holligan,
//Congratulations! You’ve graduated High School! Don’t forget to come back and visit.

$currentGrade = 16;
$finalAverage = .78;
$messageBody = '';

$message = [
   9  => 'Third form',
  10 => 'Fourth form',
  11 => 'Fifth form',
  12 => 'Lower Sixth form',
  13 => 'Upper Sixth form',
  14 => 'University year 1',
  15 => 'University year 2',
  16 => 'University year 3',
];

$teachers = [
  9  => 'Alan Bennett',
  10 => 'Belinda Carrick',
  11 => 'Carol Dear',
  12 => 'Daryl Walker',
  13 => 'Karl Shoot',
  14 => 'Maggie Rowe',
  15 => 'Gale,Fring',
  16 => 'Walter White',
];

$students = [
  'Paul Adams',
  'Charlotte Rixon',
  'Roman Cage',
  'Kevin Emsden',
  'Ruby White',
  'Claire Dyer',
  'Sean Daily',
  'Sean Warne',
];

$student = $students[rand(0,count($students)-1)];

echo "<h1>";
foreach($students as $student){
    echo "Welcome $student<br/>\n";
}
echo "</h1>";

if (!$student) {
   echo 'Please enter a student name';
} elseif ($currentGrade < 9 || $currentGrade > 16){
      echo 'This is only for high school students. Please enter a grade between 9 & 12';
} else {
    if ($finalAverage < .70) {
        $messageBody = 'We look forward to seeing you at summer school, beginning July 1st!';
    } else {

        switch ($currentGrade) {
        case 9 :
          $messageBody = "Congratulations on completing your $message[9] in High School! We’ll see you on September 1st for the start of your $message[10]!  - $teachers[9]";
      break;

    case 10 :
      $messageBody = "Congratulations on completing your $message[10] in High School! We’ll see you on September 1st for the start of your $message[11]!  - $teachers[10]";
      break;

    case 11 :
      $messageBody = "Congratulations on completing your $message[11] in High School! We’ll see you on September 1st for the start of your $message[12]!  - $teachers[11]";
      break;

    case 12 :
      $messageBody = "Congratulations! You’ve graduated $message[12]! Don’t forget to come back for $message[13].  - $teachers[12]";
      break;

    case 13 :
      $messageBody = "Congratulations! You’ve graduated $message[13]! Best of luck for $message[14].  - $teachers[13]";
      break;

    case 14 :
      $messageBody = "Congratulations! You’ve graduated $message[14]! Best of luck for $message[15].  - $teachers[14]";
      break;

    case 15 :
      $messageBody = "Congratulations! You’ve graduated $message[15]! Best of luck for $message[16].  - $teachers[15]";
      break;

    case 16 :
      $messageBody = "Congratulations! You’ve graduated $message[16]! Best of luck and dont forget to visit!  - $teachers[16]";
      break;

    default :
    $messageBody = 'Error: Grade level not between 9 and 16';
    break;
  }
}
echo "Dear $student\n";
echo $messageBody;
}
?>