Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 1 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
Preview Test: Midterm 2Preview Test: Midterm 2
Description Second Midterm for CT310 Spring 2014Instructions This test is to be taken at the appointed time in CSB 110 using RamCT. It is closed book,
closed notes, no use of online tools (behond RamCT) etc. You are encouraged to open theassociated Addendum Page where clarifications will be posted during the exam should itbecome necessary.
MultipleAttempts
Not allowed. This test can only be taken once.
ForceCompletion
This test can be saved and resumed later.
Save All AnswersSave All Answers Close WindowClose Window Save and SubmitSave and Submit
Select below the best example of a Hiearchical Database - or at least a common way of organizing datathat captures the essence of a Hierarchical Database.
Plain text fileUnix file systemSpreadsheetSQLite database
Question 14 points Save AnswerSave Answer
Select below the best example of a Flat Database - or at least a common way of organizing data thatcaptures the essence of a Flat Database.
Plain text fileUnix file systemSpreadsheetSQLite database
Question 24 points Save AnswerSave Answer
Select below the best example of a Relational Database - or at least a common way of organizing datathat captures the essence of a Relational Database.
Plain text fileUnix file systemSpreadsheetSQLite database
Question 34 points Save AnswerSave Answer
Question Completion Status:
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 2 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
Select from the options below the best statement regarding the difference between MySQL and SQLiteMySQL stores data in files deeply hidden on a server, maybe the same platform and maybe not, andaccessed by the database server program while SQLite stores data for a database in a single filetypically kept on the same file system as the webpage accessing the data. They are essentially the same with the key distinction that MySQL is owned by a large commericaldatabase company, Oracle, while the source code for SQLite is in the public domain. Both implementa client server model with database services provided by a database deamon running on a serverplatform. The two are very similar, each using essentially the SQL language for interacting with databases. Thekey distinction is that SQLite keeps a set of databases in a single file resident on the same platformas the webpage acessing those databases while MySQL is accessed through a connection to stand-alone deamon server program often running on some other platform. MySQL stores data in memory on a seperate machine running as a dedicated server while SQLitestores data for a database in a single file typically kept on the same file system as the webpageaccessing the data.
Question 44 points Save AnswerSave Answer
This is the first in a squence of questions concerning a movies and directors database. Below are the SQLcommands used to initially create the database with one key bit of information missing: the relations.The relations have been left blank and you must fille them in precisely with the text that should appear intheir place. You need to know this example involves three movies by two directors:The Great Race by Blake EdwardsLawrence of Arabia by David LeanDoctor Zhivago by David LeanCREATE TABLE director ( director_id int(5) NOT NULL, director_first varchar(50), director_last varchar(50), PRIMARY KEY (director_id));CREATE TABLE movie ( movie_id int(5) NOT NULL, movie_name varchar(50), director_id int(5) NOT NULL, PRIMARY KEY (movie_id), FOREIGN KEY (director_id) REFERENCES director(director_id));INSERT INTO director VALUES (1, 'Blake', 'Edwards');INSERT INTO director VALUES (2, 'David', 'Lean');INSERT INTO movie VALUES (1, 'The Great Race', );
INSERT INTO movie VALUES (2, 'Lawrence of Arabia', );
INSERT INTO movie VALUES (3, 'Doctor Zhivago', );
Here are the same SQL commands in a plain text file: s14mid2q05.sql.txt
Question 54 points Save AnswerSave Answer
Here you are provided the source code for a page displaying the movies in a table and a screenshot ofthe page displayed. There is also a link to the HTML presented when 'view soruce' is used in thebrowswer displaying the page. In the source code below the critical line that defines the database query
Question 64 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 3 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
is omitted. From below, pick the best choice of query to result in the page as displayed.
Here is the HTML for the above screenshot recovered from view source s14mid2q06source.txt <p>Here are the contents of the Movie Databse</p><div style="margin: 8px;"><?phptry { $dbh = new PDO ( "sqlite:./movies.db" );} catch ( PDOException $e ) { echo $e->getMessage ();}<query construction line omitted><query construction line omitted>$ret = $dbh->query ( $qur );?> <table border="1" cellpadding="2"> <tr> <th align="right">Movie</th> <th align="right">Director</th> </tr><?phpforeach ( $ret as $row ) { $mN = $row ["movie_name"]; $dN = $row ["director_first"] . " " . $row ["director_last"]; echo " <tr><td align=\"right\"> $mN </td>" . "<td align=\"right\"> $dN</td>" . "</tr> \n";}?></table>Here is the source PHP with the same line omitted and in plain text: s14mid2q06.php.txt
$qur = 'SELECT movie_name, director_first, director_last FROM movie NATURAL JOIN director ORDERBY movie_name;';$qur = 'SELECT movie_name, director_first, director_last FROM movie JOIN director ORDER BYdirector_last, movie_name;';
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 4 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
$q = 'SELECT movie_name, director_first, director_last FROM movie JOIN director ORDER BYdirector_last, movie_name;';$q = 'SELECT movie_name, director_first, director_last FROM movie NATURAL JOIN director ORDER BYdirector_last, movie_name;';$qur = 'SELECT movie_name, director_first, director_last FROM movie JOIN director ORDER BY movie_name;';$qur = 'SELECT movie_name, director_first, director_last FROM movie NATURAL JOIN director ORDERBY director_last, movie_name;';
With the disclaimer that the following question assumes an overly simplistic approach to extending thecontents of a database, for example PRIMAY KEY values will be given as specific integers, here you mustselect the correct PHP code required to add a second movie by Blake Edwards to the database. Assumethe state of the databse when this command is run matches that defined in the previous two questions.
ADD INTO movie VALUES (4, "Revenge of the Pink Panther", 1);INSERT INTO movie VALUES (4, "Revenge of the Pink Panther", "Blake Edwards");ADD INTO movie VALUES (1, "Revenge of the Pink Panther", "Blake Edwards");INSERT INTO movie VALUES (4, "Revenge of the Pink Panther", 1);ADD INTO movie VALUES (1, "Revenge of the Pink Panther", 1);INSERT INTO movie VALUES (1, "Revenge of the Pink Panther", "Blake Edwards");
Question 74 points Save AnswerSave Answer
The following PHP implements a page that simply counts the number of movies and writes out aparagraph with the answer. Select from the options below the best choice of the line that has beenomitted.<body><div style="margin: 8px;"><?phptry { $dbh = new PDO ( "sqlite:./movies.db" );} catch ( PDOException $e ) { echo $e->getMessage ();}<this line omitted><this line omitted>$result = $dbh->query($quer);$rows = $result->fetch(PDO::FETCH_ASSOC);$n = $rows['nnn'];
?> <p>There are <?php echo $n ?> movies in the database.</p></div></body>Here is the plain text version of the code above with the key line omitted: s14mid2q08.php.txt
$quer = "SELECT sum(*) AS n FROM movie;";$quer = "SELECT sum(*) AS n FROM table;";$quer = "SELECT count(*) AS nnn FROM table;";$quer = "SELECT count(*) AS nnn FROM movie;";$quer = "SELECT count(*) AS n FROM movie;";
Question 84 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 5 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
$quer = "SELECT sum(*) AS nnn FROM table;";
In the music database PHP examples there was one example where user entered input was thensubmitted to demonstrate how an SQL injection attack might operate. In this example, entering the stringDELETE FROM cd WHERE cd_name='Mudlark'; DROP TABLE cd;"will result in the destuction of the table containing the CDs.
True False
Question 94 points Save AnswerSave Answer
Consider the following simple 8 by 8 pixel image:3 3 3 3 3 3 3 33 3 3 3 3 3 3 33 3 3 8 8 8 3 33 3 8 8 8 8 3 33 3 8 8 8 3 3 33 3 3 3 3 3 3 33 3 3 3 3 3 3 33 3 3 3 3 3 3 3
How many length-value tuples are required to encode this image using run length encoding?
Question 104 points Save AnswerSave Answer
To encode a blue on white logo where space is a premium select below the image format orcombinations of formats that would be appropriate.
JPGPNG-8PNG-24JPG and PNG-8JPG and PNG-24PNG-8 and PNG-24JPG and PNG-8 and PNG-24
Question 113 points Save AnswerSave Answer
To encode a photograph of Yosemite Falls meant to be visually rich and enticing, select below the imageformat or combinations of formats that would be appropriate.
JPGPNG-8PNG-24JPG and PNG-8
Question 123 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 6 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
JPG and PNG-24PNG-8 and PNG-24JPG and PNG-8 and PNG-24
Below are four different explanations of anti-aliasing in the context of text rendering and the web. Which is best given an audience of web developers (not students in a digital signal processing class).
Anti-aliased text is always represented abstractly as a mathematicall construct and thus avoids hardedge by never ever being reduced to pixels.A softening of the edges around letters in text so that whatever the color of the text there existpixels along the boundary that blend smoothly that color with whatever background is behind thetext. The result of passing the rendered text through a low-pass filter.An increase in the resolution of text relative to the display sufficient to make the extreme colordifferences between pixels in the letters and adjacent pixels in the background no longer apparent tothe eye.
Question 134 points Save AnswerSave Answer
Select below the attribute introduced in HTML 5 (CSS 3 to be precise) that is most closely assocaited withthe concept of an alpha-channel.
opacitytransparencyluminosityveracityvisibilitycolor
Question 144 points Save AnswerSave Answer
The following is the entire page body for a hello world example. The view source in Chrome of this pageshow exactly one pair of open close paragraph tags in the HTML page body. (not counting what appearswithin the script tags.)<body><script> document.write("<p>Hello World.</p>");</script></body>
True False
Question 153 points Save AnswerSave Answer
The following is the entire page body for a hello world example. The view DOM in Chrome of this pageshow exactly one pair of open close paragraph tags in the HTML page body. (not counting what appearswithin the script tags.)
Question 163 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 7 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
<body><script> document.write("<p>Hello World.</p>");</script></body>
True False
Here is code, much like that presented in lecture (but not identical).<head><script> function fact(n) { if (n > 2) { return(1); } else { return(n * fact(n-1)); } } function showResult() { nn = parseInt(document.enter.num.value); nc = "The factoral of " + nn + " is " + fact(nn); document.getElementById("result").innerHTML = nc; }</script></head><body><form name="enter"> <input type="text" value="9" name="num" onchange="showResult()" /></form><p id="result">Factorial will appear here when you enter a number above.</p></body>Here is the same code as a plain text attachement: s14mid2q17.html.txt Read this code carefully and select from below the text displayed on this page after the integer 4 isentered into the form. You may safely assume the event 'onchange' fired when '4' entered.
The factoral of 4 is 1The factoral of 4 is 2The factoral of 4 is 4The factoral of 4 is 8The factoral of 4 is 16The factoral of 4 is 24Factorial will appear here when you enter a number above
Question 174 points Save AnswerSave Answer
Here are the SQL commands to create a toy dog social media database with three profiles. The first threelines defining the table have been omitted. Select the proper substitution for these lines from below.CREATE TABLE profile ( .... PRIMARY KEY (pid));
INSERT INTO profile VALUES (1, 'George Tirebiter', 'If you cannot drive a carthen chase it.');
Question 184 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 8 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
INSERT INTO profile VALUES (2, 'Snoopy', 'I need no introduction and I likeJazz.');INSERT INTO profile VALUES (3, 'Fala', 'A president cannot wish for more.');Also, here is file as plain text s14mid2q18.sql.blanks.txt
pdesc varchar(500), pid int(5) NOT NULL, pname varchar(50), pname varchar(50), pid int(5) NOT NULL, pdesc varchar(500), pname varchar(50), pdesc varchar(500), pid int(5) NOT NULL, pdesc varchar(500), pname varchar(50), pid int(5) NOT NULL, pid int(5) NOT NULL, pdesc varchar(500), pname varchar(50), pid int(5) NOT NULL, pname varchar(50), pdesc varchar(500),
Below you are shown the PHP source for a page that loads the database introduced in the previous question. You will see blanks in lines generating the table - you will be asked fill these in a subsequent question. For thisquestion, pick the URL from below that created the page you are shown (yes you have enough information toanswer this question). Along with the screenshot is a link to the HTML shown by a show source command. Here is the screen shot:
Question 194 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 9 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cour…ent_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
Same page show source: s14mid2q19.html.txt Here is the PHP source (also as plain text s14mid2q19.php.blanks.txt )<html xmlns="http://www.w3.org/1999/xhtml"><head><?php $dogid = isset($_GET['i']) ? $_GET['i'] : 2;?><style> div { margin:8px } div.n { border: 1px solid blue; margin:4px; } div.d { border: 1px solid green; margin:4px; } p { padding-left:8px; }</style><title>Question 19 - Dog Book</title></head><body><h3>Social Media for Dogs - Member <?php echo $dogid ?></h3><?phptry { $pdb = new PDO ( "sqlite:./s14mid2q18.db" );} catch ( PDOException $e ) { echo $e->getMessage ();}$qtxt = "SELECT pname, pdesc FROM profile WHERE pid = $dogid;";$ret = $pdb->query($qtxt)->fetch(PDO::FETCH_ASSOC);;?><div><div class="n"><p> blank 1</p></div><div class="d"><p> blank 2</p></div></div></body></html>
http://localhost/ct310/yr2014sp/bplay/exam02/s14mid2q19.php?http://localhost/ct310/yr2014sp/bplay/exam02/s14mid2q19.php?i=1http://localhost/ct310/yr2014sp/bplay/exam02/s14mid2q19.php?i=2http://localhost/ct310/yr2014sp/bplay/exam02/s14mid2q19.php?i=2
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 10 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cou…nt_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
Continuing on from the previous question, now about those blanks. Attached here is the complete PHP for the page with divisions with content leftblank: s14mid2q20.php.blanks.txt Enter precisely the needed code for blank 1
Enter precisely the needed code for blank 2
Question 204 points Save AnswerSave Answer
Here is the complete HTML source for page. Select below the most accurate summation of how this pagebehaves.<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Question 21 - Count Down</title><script type="text/javascript">var ts = 60;function init() { setTimeout(doStep, 10); }function doStep () { document.getElementById("ds").innerHTML = parseInt(ts--); if (ts > 0) { setTimeout(doStep, 1000); }}window.onload = init();</script> </head><body><h1 id="ds" style="text-align:center"> This text will be replaced.</h1></body></html>Page as a separate attachement: s14mid2q21.html.txt
Upon loading this page starts countdown timer at 60 that counts down seconds and then stops whendisplaying zero. Upon loading this page displays in h1 format the text "This text will be replaced."Upon loading this page starts countdown timer at 60 that counts down seconds and then repeatsuntil the page is closed.Upon loading this page starts countdown timer at 60 that counts down seconds and then stops whendisplaying minus one.
Question 214 points Save AnswerSave Answer
Building on the previous example, here is a page with a button called "Restart". You are given thecomplete page with "xxx" standing in for the blank you must fill in with the precise correct code.<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Question 22 - Count Down With Restart</title><script type="text/javascript">var ts = 60;function init() {
Question 224 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 11 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cou…nt_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
setTimeout(doStep, 10);}function doStep () { document.getElementById("ds").innerHTML = parseInt(ts--); if (ts >= 0) { setTimeout(doStep, 1000); }}function restart () { ts = 60; doStep();}window.onload = init();</script> </head><body><h1 id="ds" style="text-align:center"> This text will be replaced.</h1><button type="button" onclick="xxx">Restart</button></body></html>Here is the same example as plain text: s14mid2q22.html.txt What should you enter for xxx ?
One, and only one, of the following is not a valid JavaScript mouse event. Which is it. onmousedownonclickondroponmouseout
ontoponmouseuponmouseoveronmousemove
Question 234 points Save AnswerSave Answer
Here is the complete HTML for a JavaScript Whack-a-Mole page. Select below the best description of thebehavior of this page.<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Midterm 2 Question 15</title><style>div#main { margins:auto; width:330px; border:solid }div#hole0 { float:left; text-align:center; width:100px;}div#hole1 { float:left; text-align:center; width:100px;}div#hole2 { float:left; text-align:center; width:100px;}div#footer { clear:both; text-align:center }}</style>
Question 246 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 12 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cou…nt_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
<script>var holes = new Array();holes[0] = "Mole";holes[1] = "...";holes[2] = "...";function jump(hole) { if (holes[hole] == "Mole") { holes[hole] = "..."; holes[(hole + 1) % 3] = "Mole"; document.getElementById("hole0").innerHTML = holes[0]; document.getElementById("hole1").innerHTML = holes[1]; document.getElementById("hole2").innerHTML = holes[2]; }}</script></head><body><div id="main"><div id="hole0" onmouseover="jump(0)">Mole</div><div id="hole1" onmouseover="jump(1)">...</div><div id="hole2" onmouseover="jump(2)">...</div><div id="footer">Whack a Mole.</div></div></body></html>Here is the same code as a plain text attachment: s14mid2q24.html.txt
The Mole moves away from the mouse, jumping to the right and wrapping around when in the farright hole. All calls to the JavaScript function jump result in the Mole switching holes. The Mole is attracted to the mouse and jumps into the hole over which the mouse hovers. The Mole is attracted to the mouse and jumps into the hole over which the mouse hovers. All calls tothe JavaScript function jump result in the Mole changing holes. The Mole moves away from the mouse, jumping to the left and wrapping around when in the far lefthole. All calls to the JavaScript function jump result in the Mole switching holes. The Mole moves away from the mouse, jumping to the left and wrapping around when in the far lefthole. The Mole moves away from the mouse, jumping to the right and wrapping around when in the farright hole.
In JavaScript the followingwindow.location.hrefreturns what amounts to the URL of the current page. It may be used on either the left or right hand sideof an assignments statement.
True False
Question 252 points Save AnswerSave Answer
Unlike PHP, JavaScript is not case sensitive. True False
Question 262 points Save AnswerSave Answer
5/11/14, 1:59 PMPreview Test: Midterm 2
Page 13 of 13https://ramct.colostate.edu/webapps/assessment/take/launch.jsp?cou…nt_id=_49470_1&course_id=_23769_1&content_id=_1787317_1&step=null
Click Save and Submit to save and submit. Click Save All Answers to save all answers. Click Close Window to close window.
Save All AnswersSave All Answers Close WindowClose Window Save and SubmitSave and Submit
We have discussed in lecture the 'zip-file test'. In other words, if all files and subdirecties in 'public_html'(or equivalent) are placed in a zip file, can an independent fresh copy be created by unpacking the zip-file in a clean 'public_html' directory on a new server. A site built to keep content in a MySQL serverrunning on a separate machine has the advantage of requiring less content in the zip-file and so passesthe zip-file test - perhaps better than a site built using SQLite.
True False
Question 272 points Save AnswerSave Answer
Save and Submit