Final Exam

advertisement
COMP 4620 Web-Based Information Systems
Final Exam – Fall 2014
Student Name:
Student Number:
Note: Correct answers including syntax are expected, and partial marks will not be given as announced.
1. (19 marks) Fill in the blanks in each of the following.
a) List the three tiers in the 3-tier web application architecture: _______________, _______________ and
_______________.
b) _______________ is used to display web content, and _______________ is used to style web content.
c) _______________ is a JavaScript library that makes things like HTML document traversal and
manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API.
d) A _______________ database provides a mechanism for storage and retrieval of data that is modeled in
means other than the tabular relations used in relational databases.
e) _______________ is a cross-platform document-oriented database.
f) jQuery _______________ are used to find (or select) HTML elements based on their id, classes, types,
attributes, values of attributes and much more.
g) With jQuery, you can hide and show elements with the _______________ method.
h) You can define a normal JavaScript function and create an _______________ by using the new keyword.
i) A _______________ in JavaScript is a function having access to the parent scope, even after the parent
function has closed.
j) _______________ allow web developers to define new types of HTML elements.
k) _______________ is an open source, cross-platform runtime environment for server-side and
networking applications. It provides an event-driven architecture and a non-blocking I/O API.
l) The _______________ system in Node.js makes it easy to create extensions to the platform. It is simple
to learn and enable us to easily share reusable library code.
m) _______________ is a bidirectional communication technology for web applications which operates
over a single socket.
n) _______________ was designed to describe data, not to display data. Its tags are not predefined.
o) _______________ is an industry standard for character encoding of text documents. It defines every
possible international character by a name and a number.
p) The _______________ object is used to exchange data with a server behind the scenes. This is used to
update web content without reloading the entire web content.
q) _______________ is an architecture style for designing networked application. The idea is that, rather
than using complex mechanisms such as SOAP to connect between machines, simple HTTP is used to
make calls between machines.
r) _______________ is a structural framework for dynamic web applications. Its data binding and
dependency injection eliminate much of the code.
s) A _______________ is a piece of executable code that is passed as an argument to other code, which is
expected to execute the argument at some convenient time.
2. (2 marks) List the three important frontend web technologies.
3. (2 marks) List the three important backend web technologies.
4. (4 marks)
a) Write the JavaScript function, named trujq, that receives a string and returns an HTML element object
having the string as its id.
b) Write the JavaScript code that extends the above function, so that you can use the above function as an
object as well. This object should have a method, named version(), and it returns a string of version
number. (You can use any version number.)
5. (4 marks) Write the jQuery code that shows the all <p> elements belonging to a class ‘fun’ when the mouse
moves over a button of id ‘ShowMe’. This code hides all the same elements when the mouse leaves the
button. (You should not assume that the document is already fully loaded.)
6. (5 marks) We’d like to implement a jQuery like library, jFun, that is used in the form, jFun(id).css(property,
value). Answer the following questions. (Note that you should not use jQuery.)
a) (2 marks) Write jFun(id). This function should return a jFunObj object in which the property element
has the HTML element object having id as its id.
function jFun(id) {
// id is a string
return _______________
__________________________________________________;
}
function jFunObj(id) {
// id is a string
_______________.element = ________________________________________________;
}
b) (2 marks) Add the method css(property, value) to the above prototype jFunObj. (You should not rewrite
jFunObj.)
c) (1 mark) Give an example how to use the above jFun(id).css(property, value).
7. (4 marks) Write the JavaScript code that creates an object that includes two private properties name and age,
two set methods to set name and age, and two get methods to return name and age.
8. (4 marks) Answer the following questions.
a) Write a JavaScript function that has three parameters – two integers a and b, and a callback function cb.
The function computes a + b and return the result to the caller by using cb.
b) Write an example how to use the above function. The example code should use alert() to print the result
passed from the function.
9. (2 marks) Assuming Node is used, write the code in A.js that shows how the function multi() in B.js can be
used in A.js.
// filename: A.js
|// filename: B.js
|
function multi(x, y) {
|
|
|
|
return x * y;
}
10. (3 marks) Complete the following code for a web server with port number 8080.
var http = _______________('_______________');
_______________ start(route) {
var server = http._______________(function(_______________, response) {
route(request, response);
});
server._______________(_______________);
}
_______________.start = _______________;
11. (2 marks) List the two advantages of using Node over PHP, with short explanations why.
12. (2 marks) Write an example how to connect to your MongoDB database on cs.tru.ca using JavaScript.
13. (6 marks) Write the code that shows how to delete (or unsubscribe) a user in your chatting application with
MongoDB. The user should be deleted from the database only when two variables username and password
entered by the user are valid. (You can just use the two variables username and password without
considering how to get the user input.)
14. (2 marks) Here is the information of two books.

Category – children

Category – web

Title – Harry Potter

Title – Learning XML

Author – J. K. Rowling

Author – Erik T. Ray

Year – 2005

Year – 2003

Price – 29.99

Price – 39.95
Write XML data for the above book information.
15. (4 marks) Write the code to get the above XML data using AJAX. The code also displays the number of
books in the data.
16. (4 marks) Write an AngularJS example that includes two <input> elements for the quantity and the cost.
The example includes a paragraph displaying the total value at the same time when the two inputs are
updated. (The total value is the multiplication of the quantity and the cost.) The example also includes the
initialization of the quantity and the cost with 10 and 5.
17. (4 marks) Explain clearly how the dynamic binding between trujs-model and trujs-bind in TruJS is
supported.
18. (2 marks) List the three WebSocket client-side events. List the two WebSocket client-side methods.
Download