Philadelphia University



Philadelphia University

Lecturer: Dr. Samer Hanna

Internal Examiner: Dr. Saed Goul

Coordinator: Dr. Samer Hanna

Special Topics in Software Engineering

(0721439 ) Section 1 Final Exam’s Key Summer Session of 2014/2015

Date: Wednesday, August 31st, 2015-------- Time: 50 min.

Q1) (6 marks)

1. Write the advantages and disadvantages of building Web applications using vs. using PHP (2 marks)

PHP

Advantages

Open source

Can be run on all platforms

Disadvantages

Takes more time to build an application



Advantages

takes less time to build an application because of the drag and drop controls and other ready code.

Disadvantages

Paid

Can run only on Microsoft based platforms

2. Write two of the differences between the three technologies: JavaScript, PHP and regarding user input validation. (2 marks)

|JavaScript | |PHP |

|Client-side input validation |Server-side input validation |Server-side input validation |

|Use document.getElementById method to retrieve an |Use $_Post[“input name”] array to retrieve an input |Use Text1.Text property to retrieve an input |

|input | | |

3. Compare between the datatypes used by HTML vs. the datatypes used by XML Schema Definition (XSD). Also, what are the datatypes that are supported by HTML not supported by XSD, and the datatypes that are supported by XSD not supported by HTML? (2 marks)

HTML uses the datatypes: number, text, email, password, date, etc.

XSD use the datatypes: decimal, integer, nonPositiveInteger, etc.

Email, password that are supported by HTML are not supported by XSD

integer, nonPositiveInteger are supported by XSD are not supported by HTML

Q2) (6 marks)

Suppose that Philadelphia asked you to build a Web form to insert the information of the books at the University library. The design of the required web page is in the following figure:

[pic]

1. Write the needed HTML to build this Web form [note that the form has a right column that contains links to three of the Jordanian Universities libraries]. (4 marks)

2. Write the needed CSS to build this page (2 marks)

Sol.

1.

Books

Books at Philadelphia Library

Book title:

First Author Name:

Number of authors:

Publication date:

Jordan University Library

JUST University Library

Yarmouk University Library

2.

#wrap

{

width: 615px;

margin: auto;

background-color: lightblue;

}

#content

{

width: 400px;

float: left;

}

aside

{

width: 200px;

float: right;

background-color: aqua;

height: 350px;

}

.auto-style1

{

text-align: center;

}

#submit

{

font-weight: 700;

text-align: center;

}

#content

{

margin-left: 14px;

}

Q3) (6 marks)

Add the needed JavaScript functions to the Web form in Question 2 in order to:

1. Making sure that the inserted number of authors is between 1 and 10. A proper error message must be printed otherwise. (2 marks)

2. Making sure that the publication date of the book is before the current date of the system. A proper error message must be printed otherwise. (2 marks)

3. Changing the background color of the right column that contains universities links. (2 marks)

Sol.

1.

function checkAuthors() {

var a = document.getElementById("authors").value;

if (a < 1 || a > 10)

{

alert("invalid users");

}

}

2.

function checkDate() {

var publish = document.getElementById("publish").value;

var publishDate = Date.parse(publish);

var today = new Date();

if (publishDate > today)

{ alert("ivalid date");}

}

3.

function changeColor() {

var elem = document.getElementById("a");

elem.style.backgroundColor = "red";

alert ("color changed");

}

Q4) (6 marks)

Write the needed PHP code to accomplish the following:

1. Declaring a class of type Book depending on the inputs of the forms in Q2 [note. The class must have a constructor]. (2 marks)

2. Declaring an object of type Book and the filling the form’s inputs in Question 2 with the objects data when the user clicks the okay button. (2 marks)

3. Making sure that the inserted number of authors is between 1 and 10. A proper error message must be printed otherwise. (2 marks)

Sol.

1.

class Book

{

public $title;

public $authorName;

public $copies;

public $publishDate;

function __construct($title, $authorName, $copies, $publishDate) {

$this->title = $title;

$this->authorName = $authorName;

$this->copies = $copies;

$this->publishDate = $publishDate;

}

}

2.

#wrap

{

width: 615px;

margin: auto;

background-color: lightblue;

}

#content

{

width: 400px;

float: left;

}

aside

{

width: 200px;

float: right;

background-color: aqua;

height: 300px;

}

.auto-style1

{

text-align: center;

}

#submit

{

font-weight: 700;

text-align: center;

}

#content

{

margin-left: 14px;

}

3.

public function validateAuthors()

{

if ($this->authorsauthors>10)

{

echo "invalid number of authors";

}

}

Q5) (4 marks)

1. Write an XML document corresponding to the data of three books inserted using the form in Question 2. (2 marks)

2. Write the XSD file corresponding to the XML document in 1. (2 marks)

Sol.

1.

Software Engineering

Summervile

5

2012-08-01

PHP

Samer

3

2015-08-01

2.

Q6) (6 marks)

Suppose that we want to build the application in Q2 using MVC;

1. Write the code of the controller that is responsible to create Book object and send it to the view (2 marks)

2. Write the code of the model. (1 mark)

3. Write the code of the view that is responsible to generate the same form such as that in Q2. [The view should be displayed whenever the user visits the control URL. (3 marks)

Sol.

Controller

namespace MvcLibrary.Controllers

{

public class LibraryController : Controller

{

public ActionResult GetBook()

{

Book book = new Book()

{

Title = "Software Engineering",

Author = "Summervile",

NumAuthors = 5,

PublishDate = new DateTime(2014, 10, 01)

};

return View(book);

}

}

}

Model

namespace MvcLibrary.Models

{

public class Book

{

public string Title { get; set; }

public string Author { get; set; }

public int NumAuthors { get; set; }

public DateTime PublishDate { get; set; }

}

}

View

@model MvcLibrary.Models.Book

@{

ViewBag.Title = "Books at Philadelphia Library";

}

#wrap

{

width: 615px;

margin: auto;

background-color: lightblue;

}

#content

{

width: 400px;

float: left;

}

aside

{

width: 200px;

float: right;

background-color: aqua;

height: 250px;

}

.auto-style1

{

text-align: center;

}

#submit

{

font-weight: 700;

text-align: center;

}

#content

{

margin-left: 14px;

}

Books at Philadelphia Library

Book title:

First Author Name:

Number of authors:

Publication date:

Jordan University Library

JUST University Library

Yarmouk University Library

Q7) (4 marks)

For the same form in Q2, write the needed based code to:

1. Make sure that the number of authors is between 1 and 10. Print proper error message to the user otherwise. (2 marks)

2. Make sure that the publish year of the book is equal or after 2010; otherwise a message indicating that the book is old should be printed. (2 marks)

Sol.

1.

2.

protected void Button1_Click(object sender, EventArgs e)

{

string n = String.Format("{0}", Request.Form["publish"]);

int year = DateTime.Parse(Request.Form["publish"]).Year;

Label1.Text = year.ToString();

if (year < 2010)

Label1.Text = "Old book published in " + year;

}

[pic]

-----------------------

[pic]

Faculty of Information Technology

Department of Software Engineering

Examination Key

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download