Nothing Special   »   [go: up one dir, main page]

Web Tech MID Term Exam FA23 - Solution

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

MID TERM EXAMINATION (FA23)

DEPARTMENT OF COMPUTER SCIENCE

Class / Program: BCS Repeaters Day/Date: Monday / Oct 30, 2023


Course: Web Technologies (CSC336) Instructor: Mr. Mian M. Talha
Time Allowed: 60 Minutes Maximum Marks: 50 Marks
Note:
• Read the questions’ scenario carefully before attempting the questions.
• Attempt all the questions as directed on separately provided answer sheets.
• Understanding is part of examination. So, don’t disturb your invigilator.
Question # 01: CLO1-(SO(1))

(Part a) Choose the best answers. Each part carries only ONE correct answer. (10 Marks)

1. _____________ are computers that store and serve web content to users when requested.
a. Web Page b. Web Server c. WWW d. Local Server
2. _________ is a frontend framework / library used for web application development.
a. Node JS b. Vue JS c. Express JS d. Django
3. What is the correct syntax to write an HTML comment?
a. /* comment */ b. <! - - comment - - > c. // comment d. All of the above
4. What are the types of unordered lists in HTML?
a. circle, square, disk b. triangle, square, disk c. oval, triangle, disk d. All of the above
5. If a background image is smaller than the screen on which it is being displayed, what will
occur on the webpage?
a. The blank space will be shown in black. b. They can be used for text only.
c. They can be repeated. d. None of the above
6. How can we select an element with a specific ID in CSS?
a. ^ b. # c. . d. None of these
7. In the below code snippet, in what order will the margins be added?

a. Top, Bottom, Right, Left b. Top, Right, Bottom, Left


c. Top, Right, Left, Bottom d. Top, Bottom, Left, Right

8. Which of the following bootstrap classes indicates the capitalized text?


a. .text-capitalize b. .text-upper c. .uppercase d. .text-uppercase
9. Command to start Laravel Application?
a. php artisan start b. php artisan new
c. php artisan serve d. php artisan
10. In which file we can set database connections?
a. database.php b. config.php c. .env file d. Both A and B

Question # 02: CLO4-(SO(2,3,4))

(Part a) Trace out the output of the following code snippet. Give Brief Explanation also. (10 Marks)

<!DOCTYPE html>
<html>
<head>
<title>Complex Web Code</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body { background-color: #f0f0f0; }
.container { margin-top: 30px; }
</style>
</head>
<body>
<div class="container">
<h1 class="text-center">Complex Web
Code</h1>
<form id="myForm">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Enter your name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" placeholder="Enter your email">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<div id="message" class="mt-3"></div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
document.getElementById('myForm').addEventListener('submit', function (e) {
e.preventDefault();
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
if (name && email) {
document.getElementById('message').innerHTML = `<div class="alert alert-success">Form submitted successfully.
Name: ${name}, Email: ${email}</div>`;
} else {
document.getElementById('message').innerHTML = `<div class="alert alert-danger">Please fill in all fields.</div>`;
}
});
</script> </body> </html>
(Part b) Find out any 05 hidden errors from the code. Also, rewrite the correct code. (10 Marks)

<!DOCTYPE html>

<html>

<head>

<title>Error-Filled Code</title>

<link rel="stylesheet" href="style.css"> you need to provide a valid path to your stylesheet.

</head>

<body>

<h1>Error-Filled Code</h1>

<div class="container">

<div class="row">

<div class="col-md-6"> You're using Bootstrap grid classes like "col-md-6," but you haven't included Bootstrap in
your project. Add Bootstrap CDNs to include Bootstrap or at least mention this issue.

<label for="name">Name:</label>

<input type="text" id="name" placeholder="Enter your name">

</div>

<div class="col-md-6">

<label for="email">Email:</label>

<input type="email" id="email" placeholder="Enter your email">

</div>

</div>

<button class="btn btn-primary">Submit</button> You have a submit button outside the form element, which may not
work as expected.

<form action="/submit-form" method="post">

<button class="btn btn-danger" type="submit">Submit</button>

@csrf In the form section, you have an "@" symbol before "csrf" . Remove "@" before "csrf."

<input type="text" name="name">

<input type="email" name="email" placeholder="Enter your email"> a missing "name" attribute for the second input
element.

</form>

</div>

</body>

</html>
(Part c) Understand the Scenario below and give code according to requirements. (20 Marks)

Scenario:

You are a developer working on a hospital management system. The system is responsible for
managing the records. The hospital wants to improve its digital infrastructure to streamline its
operations. You are tasked with designing and implementing the software.

Questions:

(i) What are the entities in the hospital management system scenario?

Entities in the hospital management system scenario:


• Patient
• Doctor
• Appointment
• MedicalRecord
• Staff
• Department
• Billing
• Pharmacy
• LaboratoryTest
• Surgery
• Inventory
• Room
• Insurance
• Supplier
(ii) Write code to create models for any 3 entities from the scenario.

// Patient Model
php artisan make:model Patient

// Doctor Model
php artisan make:model Doctor

// Appointment Model
php artisan make:model Appointment

(iii) Write code to create controllers for the chosen entities in question ii.

// Patient Controller
php artisan make:controller PatientController

// Doctor Controller
php artisan make:controller DoctorController

// Appointment Controller
php artisan make:controller AppointmentController
(iv) For the 'ODD registration number' entities, write code for creating and updating records
for 2 of the chosen entities in question iii.

// Creating a new patient record


$patient = new Patient;
$patient->name = 'John Doe';
$patient->gender = 'Male';
$patient->dob = '1990-05-15';
$patient->save();

// Updating a patient record


$updatedPatient = Patient::find(1);
$updatedPatient->name = 'Jane Smith';
$updatedPatient->save();

For the 'EVEN registration number' entities, write code for reading and deleting records
for 2 of the chosen entities in question iii.

// Reading an appointment record


$appointment = Appointment::find(1);

// Deleting an appointment record


$deletedAppointment = Appointment::find(2);
$deletedAppointment->delete();

// Reading a doctor record


$doctor = Doctor::find(1);

// Deleting a doctor record


$deletedDoctor = Doctor::find(2);
$deletedDoctor->delete();

(v) What is the command for to make changes to the schema of an entity?

php artisan make:migration

(vi) Write a command to drop all tables.

php artisan migrate:reset

*** GOOD LUCK ***

You might also like