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

1/25/22, 8:12 AM CENG420 Final Exam

Dashboard / Courses / SoEN / Web Programming and Technologies( Tripoli - Section A - 193100) Fall 2021 - 2022 / CENG420 Final

/ CENG420 Final Exam

Time left 1:23:08

Question 1
Not yet answered

Marked out of 3.00

Select the correct JavaScript data type of the following variable:

var code= Number("10");

Your answer is number

Question 2
Not yet answered

Marked out of 3.00

What is the output of the following php code:


$var = “Welcome to CENG” + 420 ;

echo $var;

Select one:
a. Parse Error

b. 420

c. Welcome to CENG

d. Welcome to CENG420

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 1/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 3

Not yet answered

Marked out of 3.00

Which syntax would you use to assign the class myclass to the paragraph having the id par1?

Select one:
a. document.getElementById("par1").class("myclass")

b. document.getElementById("par1").class.add("myclass")

c. document.getElementById("par1").classList.add("myclass")

d. document.getElementById("par1").classList("myclass")

Question 4
Not yet answered

Marked out of 3.00

Set the max numbers of characters allowed in the input field to 40.

<form action="go.php">

< input type="text" =” ”>

< /form>

Question 5

Not yet answered

Marked out of 3.00

Font size can be expressed using:

Select one:
a. px

b. all of the mentioned

c. em

d. percentage

Question 6
Not yet answered

Marked out of 3.00

statement is used to select one of many code blocks to be executed.

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 2/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 7

Not yet answered

Marked out of 3.00

Consider the following form, what happens when click on the button?

<form action=”home.php” method=”POST”>


Username <input type=”text” name=”user” id=”first”/>

<input type=”submit” value=”go”/>

</form>

Select one:
a. the page itself refreshes

b. The user is navigated to another page “home.php”

c. An alert appears

d. nothing happens

Question 8
Not yet answered

Marked out of 3.00

The output of the following code is:


<form>

<input type="radio" name="age" value="under20" checked="checked"/>0-19


<input type="radio" name="age" value="above20" checked="checked"/>20-100

</form>

Select one:
a.

b.

c.

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 3/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 9

Not yet answered

Marked out of 3.00

If you want the webpage to remember your credentials as long as you do not close the browser, you use:

Select one:
a. cookies work or sessions work

b. sessions only

c. cookies only

d. none of them work

Question 10

Not yet answered

Marked out of 3.00

“font-style comes first than font-weight in font attribute”.

Select one:
a. True

b. False

Question 11

Not yet answered

Marked out of 3.00

Consider the following php code. What is the output?


$web = array("HTML", "CSS", "JavaScript", "PHP");

print_r($web);

Select one:
a. HTML , CSS, JavaScript, PHP

b. Array ( [0] => HTML [1] => CSS [2] => JavaScript [3] => PHP )

c. Array ( HTML, CSS , JavaScript, PHP )

d. Array ( 0: HTML, 1: CSS, 2: JavaScript, 3: PHP )

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 4/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 12

Not yet answered

Marked out of 3.00

When using the shorthand property, the order of the values are

Select one:
a. font-family font-variant font-weight font-size font-style

b. font-style font-variant font-weight font-size font-family

c. all of the mentioned

d. font-variant font-weight font-size font-family font-style

Question 13
Not yet answered

Marked out of 3.00

Fill in the blanks such that the below Javascript code creates <option> and appends it to the select list having id "mySelect".

<script>

var mySelect= . ("mySelect");

var option= document. (" ");

option.value=0;

option.text="A";

mySelect. (option);

</script>

Question 14

Not yet answered

Marked out of 3.00

model uses a property of an object to specify an event handler.

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 5/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 15

Not yet answered

Marked out of 6.00

Complete the code such that it validates the inputs on form submit as follows:

1. The name can not be empty and must contain only lowercase alphabets

2. The password is at least 6 characters with lowercase and number

If the above restrictions are satisfied, the user will be redirected to the next page, otherwise, the function returns false and an error alert

message will be displayed.

<body>

< >

validate_inputs(){

var name= . (" ").

var password= . ("

"). ;

if ( ==""){

("Name can't be blank");

}else if(name.match(/ / )){

("Name must contain only lowercase alphabets");

} else if (password.match( )==null){

("password must be at least 6 characters with lowercase and number");

</script>

<form ="next.php" ="return

;" >

Name: <input type="text" id="uname"><br/>

Password: <input type="password" id="upassword"><br/>

<input type="submit" value="Submit">

</form>

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 6/15
1/25/22, 8:12 AM CENG420 Final Exam

</body>

Question 16
Not yet answered

Marked out of 3.00

Select tag that does not include the "multiple" is similar to:

Select one:
a. Checkboxes

b. textarea

c.
Radio

Question 17

Not yet answered

Marked out of 3.00

in HTML body, the <span> tag can be nested inside the <em> tag.

Select one:
True

False

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 7/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 18

Not yet answered

Marked out of 28.00

We wish to build a website for Buy and Sell for Free of goods, in which users are able to login, buy or sell an item (we are interested here on
the Sell part).
Assume that in the database (‘goods_db’), we have 3 tables:

users ( u_id, name, password)


goods(good_id, category_id, item, price)
category(category_id , category_name)

Assume that the connection file is called connection.php. Assume also that all the tables are already created and the table users is filled with
data. The webserver and the database server are on the same physical machine.
Part 1. Compete the code for connection.php.

<?php
$con =

('

','root',' ', 'goods_db');

if(

){

die( 'Failed to connect to MySQL: '. mysqli_connect_error());


}

?>
Part 2: The index.php page contains a form for the user to login as below:

Complete the code below such that if the login is successful, a session is created and filled with name and user_id, and the user is
navigated to a page called home.php. if not successful, he/she is directed back to index.php.

<?php
require_once "

";
if (isset(

) && isset(

)) {

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 8/15
1/25/22, 8:12 AM CENG420 Final Exam

$user = $_POST['user'];

$password =

;
$query = "

";
$result = mysqli_query($con, $query);

$nbr_row =

if ($nbr_row == 1) {
$row =

;
$user_id =

;
$_SESSION['user_id'] = $user_id;

$_SESSION['username'] = $user;
$_SESSION['isLogin'] = True;

header("

");

} else {
header("

");
}

}
?>

<html>

<body>
<h3 >SignIn Form</h3>

<form method="POST" action=

>

<p> Username <input type="text" maxlength="30" name="user" </p>


<p> Password <input type="password" maxlength="30" name="pwd"></p>

<p><input type="submit" value="Sign in"></p>

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 9/15
1/25/22, 8:12 AM CENG420 Final Exam

</form>

</body>
</html>

Part 3.The home.php page contains a greeting to the user “Welcome username to Buy and Sell Goods for Free ” and 2 parts as shown below:

The second part contains 2 links one for buy.php and the other for sell.php.
The last part is a link to "logout.php".

Complete the home.php code below (Note that it is necessary to make sure that a session is established or not. if not navigate the user back
to index.php)

<?php

require_once 'connection.php';

if (isset(

)){

$user_id =

;
$user = $_SESSION['username'];

echo "<h2> Welcome

to Buy and Sell Goods for Free</h2>";

echo '<hr/>';
echo '<p> To BUY <a href= "buy.php">click here </a></p>';

echo '<p> To SELL

</p>';

echo '<hr/>';

echo '<a href="logout.php"> logout </a>';


} else {

header('Location: index.php');
}

?>
Complete the code of logout.php page; once the user logout it is redirected back to index.php.

<?php

;
https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 10/15
1/25/22, 8:12 AM CENG420 Final Exam

unset($_SESSION['name']);

unset(

);
unset($_SESSION['user_id']);

header('Location: index.php');
?>

Part 4: The sell.php contains a form that takes an item, its price and a category (the category list is filled from the table category) and a
button ADD. when the user click on the button, the item is inserted into the table goods and the user is redirected back to home.php.

Complete the code of sell.php below:

<?php

session_start();

require_once 'connection.php';

if (isset($_SESSION['isLogin'])) {

echo '<h2> Add an Item </h2>';

$select_query = "

";

$result = mysqli_query($con, $select_query);

$r =

echo '<form action="

" method="POST">';

echo '<p> Item name <input type="text" name="item" /></p>';

echo '<p> Item Price <input type="text" name="price" /></p>';

echo '<p> Select a category </p>' ;

echo '<select name="category" size="3" required>';

for ($i = 0; $i < $r; $i++) {

$row =

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 11/15
1/25/22, 8:12 AM CENG420 Final Exam

$category_id = $row['category_id'];

$category_name =

echo "<option value=$category_id>$category_name</option>";

echo '</select>';

echo '<p><input type="

" value = "ADD"/></p>';

echo '</form>';

else {

header('Location: index.php');

if (isset(

)&&isset($_POST['item']))

$category_id =

$item = $_POST['item'];

$price = $_POST['price'];

$insert_query = "

";

$result =

('location:home.php');

?>

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 12/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 19

Not yet answered

Marked out of 3.00

The JavaScript prompt() method is used to ask the user to enter something.

Select one:
True

False

Question 20
Not yet answered

Marked out of 3.00

The output of this code is:


<script>

var str="W WYZ YZ Y";


result = str.match(/W?Y/g);

document.write(result);
</script>

Select one:
a. WY,Y,Y

b. W,WY,Y
c. W,WYZ,YZ,Y

Question 21
Not yet answered

Marked out of 3.00

Fill in the blank the appropriate JS method to obtain the output Writing

<script type="text/javascript">

var hobbies = ["Writing", "Blogging", "Dancing", "Reading"];

document.write(hobbies. );

</script>

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 13/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 22

Not yet answered

Marked out of 3.00

Which CSS property is used to change the font into italic?

Select one:
a. emphasis
b. weight

c. variant

d. style

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 14/15
1/25/22, 8:12 AM CENG420 Final Exam

Question 23

Not yet answered

Marked out of 6.00

Fill in the blanks such that the JavaScript code does the following:

1-Ask the user to enter numbers a and b.

2-Calculate cos(a)/b3

3-Display the result in the page inside a <p> tag.

<body>

<p ="myparagraph"></p>

< >

EvaluteValue(a, b){

. (a)/ .pow( ,3);

a= ("Enter the value of a");

if ( (a))

("Please enter a number");

else

b= ("Enter the value b");

if ( (b))

("Please enter a number");

else

. ("myparagraph"). = (a, b);

</script>

</body>

◄ Server Side Lecture 4

Jump to...

https://ems.liu.edu.lb/mod/quiz/attempt.php?attempt=35084&cmid=3988 15/15

You might also like