ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions
17 marks · Feasibility studies and user surveys
The developers begin by investigating the hardware and software required for running this system. State the type of feasibility being investigated. The website will allow all users to search for details of a Munro and register for an account. In addition, registered users can add details of any climb they have completed, and if required, they can add a comment about the climb. Registered users can then view details of all climbs that have completed. Draw a UML use case diagram for this website. Information processed by the website is stored in a database in three related tables: Munro, Climber and Climb. Munro munroID munroName height latitude longitude difficulty level Climber climberID forename surname email password climbingAbility Climb climbID climberID* munroID* date timeTaken notes When a new user registers with the website, they complete a registration form. A wireframe for this form is shown below. When submitted, this data is sent to a page called checkUser.php. Register Forename: * Emma Surname: * Hinze Email: * ehinze@freemail.de Password: * gewinner6@$gold Climbing Ability: intermediate Submit When this form data is submitted, the following design is used to check whether the submitted email address has already been registered. … 22. create query to select climbers with email address = submitted email 23. execute SQL query 24. set $matches to __________________________________ 25. if $matches > 0 then 26. __________________________________ 27. else 28. add new user details to Climber table 29. end if Write the pseudocode needed to complete line 24 and line 26 of the design. The HTML form elements used on the registration form are shown below. < input type = "text" name = "first" required > < input type = "text" name = "last" required > < input type = "text" name = "email" required > < input type = "text" name = "pass" required > < input type = "text" name = "level" > Write the PHP code that will be used on the checkUser.php page to assign the data submitted from the registration form to PHP variables. Write the SQL query to add details of the new user shown on the wireframe to the database. The navigational structure of the website is shown below. Home Page Search for Munro Log In Register email email Welcome email (session) email (session) View Climbs Add Climbs When a registered user logs in using their email address and password, the ‘Welcome’ page is displayed. This page contains the following code: session_start(); $email = $_SESSION['email']; The same code is also used on the ‘View Climbs’ and the ‘Add Climb’ pages. Explain why a session variable is necessary on these pages. Describe the use made of this session variable on the ‘View Climbs’ page used to display details of all climbs completed by a logged in user. The ‘Add Climb’ page uses the form below to allow registered users to record details of any Munros they have climbed. Date: 17/04/2024 Time Taken: 05:15 Mountain: Aonach Mor Foggy ascent but beautiful views from the summit. Add Climb Add Climb Notes: The first attempt to create the drop-down list for selection of the mountain resulted in the PHP and HTML code shown below. … Line 59 < select name="mountain" > Line 60 < ?php Line 61 $connection = mysqli_connect("scottishClimbs", "nevis", "lomond", "climbing"); Line 62 $sql = "SELECT munroName, munroID FROM Munro ORDER BY munroName ASC"; Line 63 $result = mysqli_query($sql); Line 64 while($row = mysqli_fetch_array()) { Line 65 echo "< option value = " .$row['munroID']." > ".$row['munroName']."< /option >"; Line 66 } Line 67 mysqli_close($connection); Line 69 ? > Line 70 < /select > … Identify the username for this database connection. When this code is executed, the following error messages are produced: PHP Error Message Warning: mysqli_query() error in addClimb.php on line 63 PHP Error Message Warning: mysqli_fetch_array() error in addClimb.php on line 64 Explain these errors and describe how they could be resolved. The ‘View Climbs’ page is used to display details of climbs completed by registered users of the website. PHP code is to be added to this page. The design of one process performed by the code is shown below. 1. set $numClimbers to number of climbers in Climber table 2. set $most = 0 3. start loop from 1 to $numClimbers 4. set $climberID = loop 5. set $howMany = number of climbs completed by $climberID 6. if $howMany > $most then 7. set $most = $howMany 8. end if 9. end loop 10. create query to select full name of climber(s) with number of climbs completed = $most 11. execute query and assign results to $result 12. assign $result to array $target 13. display forename(s) and surname(s) stored in $target Describe the intended purpose of this design. Identify a potential problem at line 5 of the design. A Munro is a mountain in Scotland that is over 3,000 feet high. A database-driven website is being created to share information about these mountains and to allow climbers to record which Munros they have climbed. The details of each Munro will be stored, along with a difficulty level from 1 (easy) to 5 (difficult).
Technical See sample solution below. 1 mark for 3 actors with generalisation (DB, unregistered user and registered user). 1 mark for correct use cases (Search for Munro, Register, Login, View climbs, Add climb) together with appropriate relationships. 1 mark for extend for Add comment. Line 24 number of results returned by the query. Line 26 Display error message saying that email address already registered. 1 mark each. Note: accept mysqli_num_rows() for line 24. See sample solution below. 1 mark for correct use of $_POST function 1 mark for correct use of all name attributes used with HTML form elements. Note: do not penalise for use of alternative PHP variable names. $forename = $_POST['first']; $surname = $_POST['last']; $email = $_POST['email']; $password = $_POST['pass']; $ability = $_POST['level']; See sample solution below. 1 mark for INSERT INTO Climber 1 mark for correct list of fields and values.. Note: field list must be correct – climberID should not be present; also, values must be in same sequence as field list. INSERT INTO Climber (forename, surname, email, password, climbingAbility) VALUES ('$forename, '$surname, '$email', '$password', '$ability') Also accept: INSERT INTO Climber (forename, surname, email, password, climbingAbility) VALUES ("emma", "hinze", "ehinze@freemail.de", "gewinner6@$gold", "intermediate") Any username entered on the Log in or Register page would be POSTed to the Welcome page but would not be available to any other pages of the website. A session variable is needed to store the POSTed value so that it can persist across all pages of the website. 1 mark for use of session variable to allow entered email to persist on additional pages of the website. Since the email of the logged in user would be stored in the session variable, the session variable would be used as the search criteria for the SQL query needed to retrieve details of all climbs completed by the user. 1 mark for use of username as search criteria in the SQL query. Username = nevis Line 63 The $connection parameter has been omitted; the correct code should be: mysqli_query($connection, $sql) Line 64 The parameter $result has been omitted; the correct code should be mysqli_fetch_array($result) 1 mark for missing $connection parameter at Line 63 1 mark for missing $result parameter at Line 64 The script will perform a find maximum algorithm to display the forename and surname of the climber with the highest number of climbs in the database. 1 mark for find maximum algorithm. 1 mark for displaying details of climber with the highest number of climbs. At Line 4, the climberID is set to the index of the loop and at Line 5, howMany is set to the number of climbs completed by this climber. However, if the record with this climberID does not exist in the database (for example, the record may have been deleted at some point), then an error may be generated at Line 5. 1 mark for explanation.