Untitled
unknown
plain_text
3 years ago
3.3 kB
6
Indexable
<?php /// START - DO NOT MODIFY OR REMOVE THE CODES /// $modules_info = [ "Business Process Analysis and Solutioning" => [ ["Rafael J. BARROS", "KE Ping Fan", "Swapna GOTTIPATI", "A. M. Aditya"], ["LUM Eng Kit", "Fiona LEE", "CHUA Hong Ngoh", "CHUA Hong Ngoh"], 1 ], "Interaction Design & Prototyping" => [ ["Benjamin GAN", "Kotaro HARA", "Gabriyel WONG", "OUH Eng Lieh"], ["Coen CHUA", "Joseph SUNG", "LEE Kok Khing", "Wendy TAN"], 1 ], "Web Application Design II" => [ ["Kyong Jin SHIM", "SHAR Lwin Khin", "SUN Jun"], ["Yi Meng LAU", "THIANG Lay Foo", "THIANG Lay Foo"], 2 ], "Computational Thinking" => [ ["Akshat KUMAR", "ARUNESH", "MOK Heng Ngee", "Vivien SOON"], ["MOK Heng Ngee", "MOK Heng Ngee", "MOK Heng Ngee", "Fiona LEE"], 3 ], "Introductory Statistics" => [ ["WU Zhengxiao", "LIU Shew Fan", "Rosie CHING", "Raymond TEO", "GOH Jing Rong", "YEO Keng Leong"], [], 0.5 ], "Analytics Foundation" => [ ["Seema CHOKSHI", "Kar Way TAN"], [], 1 ] ]; $modules = ["bpas" => "Business Process Analysis and Solutioning", "idp" => "Interaction Design & Prototyping", "wad2" => "Web Application Design II", "ct" => "Computational Thinking", "stats" => "Introductory Statistics", "af" => "Analytics Foundation"]; /// END - DO NOT MODIFY OR REMOVE THE CODES /// // WRITE YOUR CODE HERE $mod1 = $_POST['first_mod']; $mod2 = $_POST['second_mod']; $mod3 = $_POST['third_mod']; $mod4 = $_POST['fourth_mod']; $all_mods = [$mod1, $mod2, $mod3, $mod4]; // check num of unique mods (returns an array) $results = array_unique($all_mods); //var_dump($results); if (count($all_mods) != count($results)){ echo "<h1>You have repeated modules! Please submit your form again.</h1>"; echo "<a href='./bidding.html' /> Back to form </a>"; } else{ echo "<h1>Here are the Professors and Instructors for your selected modules.</h1> <br>"; echo "<table border='2'> <th>Modules Chosen</th> <th>Professor</th> <th>Instructor</th>"; $units_cleared = 0; foreach($all_mods as $mods){ $module = $modules[$mods]; $info_array = $modules_info[$module]; $prof_arr = $info_array[0]; $instr_arr = $info_array[1]; $units_cleared += $info_array[2]; $num_prof = count($prof_arr); // var_dump($info_array); echo "<tr> <td rowspan='$num_prof'>$module</td>"; foreach($prof_arr as $prof){ echo "<td>$prof</td>"; } if(count($instr_arr) > 0){ foreach($instr_arr as $instr){ echo "<td>$instr</td>"; } } echo "</tr>"; } } echo "</table>"; ?>
Editor is loading...