\documentclass[12pt]{article}
\usepackage{palatino}
\usepackage{epsfig}
\usepackage{enumerate}
\pagestyle{myheadings}
\markboth{CS316 Spring 2022: Midterm exam}{CS316 Spring 2022: Midterm exam}
\setlength{\topmargin}{-0.5in}
\setlength{\hoffset}{-1.1in}
\setlength{\textheight}{8.8in}
\setlength{\textwidth}{7.1in}
\usepackage{hyperref} % 
\newcommand\answerLine[1]{\rule{#1in}{1pt}}
\newcommand\answerSpace[1]{\\ \rule{0in}{#1in}}

\begin{document}
\section*{General rules}
\begin{enumerate}
\item This test is {\bf closed book}.  You may not consult the class notes, the
recordings of the lectures, your programs, the textbook, or the Internet.
\item You may use up to 75 minutes for this exam .  If you have a documented disability, you may spend
additional time as agreed upon in your official letter of accommodation.
\item You must sign this note:\\
\fbox{\begin{minipage}{6.5in}
I have not spoken with other people about this exam, and I will not speak with
others who have not finished the exam.  \\
\rule{0in}{.3in}\\
Signature: \rule{5in}{1pt}
\end{minipage}
}
\end{enumerate}

\section{Basics}
\begin{enumerate}[(a)]
\item Is Firefox (1) a {\bf web server}, (2) a {\bf web client}, or (3) a {\bf web
protocol}?
(Circle {\bf (1)}, {\bf (2)}, or {\bf (3)}.)
\item Consider this URL:
	{\tt https://www.cs.uky.edu/\verb+~+abcd123/somewhere/file.php}.
What is the DNS name of the server for that URL?  \answerLine{1.7}
\item In the MultiLab, what is the {\bf full path name} of the file that the URL
above specifies? You may use the tilde abbreviation (\verb+~+)
to refer to a home directory. \answerSpace{0.6}
\item In the MultiLab, the file that the URL above specifies has permissions 664 (in
octal).  Does our Apache web server respond to the URL above by (1) sending the file,
(2) running the file as a program and sending its output, or (3) immediately
logging an error?
(Circle {\bf (1)}, {\bf (2)}, or {\bf (3)}.)
\item Is it valid HTML to embed a {\tt <form>} region within a {\tt <tr>}
region? (Circle {\bf yes} or {\bf no}).
\end{enumerate}

\section{HTML}

\begin{enumerate}[(a)]
\item Name three tags that are required in a properly formatted HTML file.
\answerSpace{.7}
\item Name an attribute that is required in an {\tt <img>} tag.
\answerSpace{.3}
\item I want to put a black box around a {\tt <span>} element.
Without putting any content in the {\tt <head>} region or using any JavaScript,
how can I do that?  Be specific: What do I place in the file and where do I
place it?
\answerSpace{.7}
\item I wish to force the content of a region started by {\tt <div id=howdy>}
to be formatted in the Arial font.  Without adding attributes to the start tag
or using JavaScript, how can I do that?  Be specific: What do I place in the
file and where do I place it?
\answerSpace{.7}
\item What is the purpose of an {\tt integrity} attribute in a {\tt <script>}
region?
\answerSpace{.7}
\end{enumerate}

\section{Navigating the DOM}
\begin{enumerate}[(a)]
\item Write a JavaScript expression using the DOM
that selects the second {\tt <pre>} element in an HTML page.  Do not assume the
existence of any attributes on that tag.  Do not use jQuery.
There are several correct answers.
\answerSpace{.7}
\item Given that the JavaScript variable {\tt myElt} has as its value that {\tt
<pre>} element, write a JavaScript statement {\bf that uses {\tt myElt}} and
changes the font color of that element to red.  Do not use jQuery.
\answerSpace{.6}
\item Write a JavaScript expression using the DOM that
selects all the {\tt <p>} elements that have class {\tt myClass}.
Do not use jQuery.
\answerSpace{.6}
\end{enumerate}

\section{CSS and jQuery}
\begin{enumerate}[(a)]
\item Write CSS that you could place in the {\tt <style>} region to put a
6px dotted green border around each {\tt <li>} region.
\answerSpace{1.0}
\item 
Write CSS that you could place in the {\tt <style>} region to make the background
color \hbox{\it lightblue} and the font weight {\it bold} in each region whose classes
include {\tt myClass}.
\answerSpace{.6}
\item Write a single JavaScript statement that uses jQuery has exactly the
same effect (color and font weight for each region whose classes include {\tt
myClass}).
\answerSpace{.6}
\item Write a single JavaScript statement (optionally using jQuery) that causes
the size of the font in those same regions to become 30px when the mouse moves
into that region (the event is called "mouseenter").
\answerSpace{.6}
\item Same as above (size becoming 30px on mouseenter) but animated to take 2.5
seconds.
\answerSpace{.6}
\end{enumerate}

\section{Organization}
\begin{enumerate}[(a)]
\item {\bf Read this question entirely before starting.}
In class, Dr. Finkel uses a desktop computer to demonstrate examples.
Draw a picture with rectangles depicting the desktop computer, the server's
computer, and the mySQL server's computer.  Inside those rectangles place
circles (shape unimportant) depicting the web server, the SQL server, the
browser, and a running CGI
program.  Place the following numbers in the picture in the right places.
\newpage
	\begin{enumerate}[1]
	\setlength{\itemsep}{-.02in}
	\item Apache2
	\item Firefox
	\item PHP
	\item mysql server program
	\item the front end
	\item the back end
	\item where JavaScript runs
	\item where SQL queries are generated
	\end{enumerate}
Do not put any labels in the picture other than the numbers.
\answerSpace{3}
\item If I have a database table called {\tt mytable}, what SQL query
returns all the fields of all the entries in that table?
\answerSpace{.6}
\item Why are AJAX calls sometimes preferable to {\tt <form>} submits?
\answerSpace{.6}
\item Show a call to the built-in JavaScript function that accomplishes AJAX
to invoke {\tt echo.cgi} using the GET method and providing 
{\tt parameter1} with value {\tt Hello, world!}.
You may assume that the CGI program is in the same directory as the invoking web
page.  The code may ignore the result.
\answerSpace{.6}
\end{enumerate}

\end{document}
