\documentclass[12pt]{article}
\usepackage{palatino}
\usepackage{epsfig}
\usepackage{enumerate}
\pagestyle{myheadings}
\markboth{CS316 Spring 2021: Midterm exam}{CS316 Spring 2021: Midterm exam}
\setlength{\topmargin}{-0.5in}
\setlength{\hoffset}{-1.1in}
\setlength{\textheight}{8.8in}
\setlength{\textwidth}{7.1in}
\usepackage{hyperref} % 
\hyperbaseurl{https://www.cs.uky.edu/~raphael/courses/CS316/examples}
\usepackage{url}
\newcommand\answerLine[1]{\rule{#1in}{1pt}}
\newcommand\answerSpace[1]{\\ \rule{0in}{#1in}}

\begin{document}
\section*{General rules}
\begin{enumerate}
\item This test is {\bf open book}.  You may consult the class notes, the
recordings of the lectures, your programs, the textbook, and the Internet.  But
you must cite any sources you consult.
\fbox{\begin{minipage}{6.5in}
Sources consulted: \\
\rule{0pt}{3in}
\end{minipage}}
\item You may use up to 50 minutes for this exam (including any time you spend
consulting sources).  If you have a documented disability, you may spend
additional time as agreed upon in your official letter of accommodation. \\
\fbox{\begin{minipage}{6.5in}
Reason for turning in after 9:50 EST Monday, March 15: \\
\rule{0in}{.5in}\\
\end{minipage}
}
\item You must submit this exam via Canvas.
You may
(1) print the exam, write on it, then scan or photograph it, or
(2) write the answers on paper, then scan/photograph them, or
(3) enter the answers into a computer file using Word or something similar,
including pictures, then export the file as PDF.
I prefer PDF, but JPEG is also acceptable.  You may submit multiple pages either
by multiple submissions or (preferably) as a single ZIP file.
\item You must sign this note (either scan this page or write it on your test:\\
\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.  I have only used the allowed amount of
time on the exam. \\
\rule{0in}{.3in}\\
Signature: \rule{5in}{1pt}
\end{minipage}
}
\end{enumerate}
\newpage

\section{Basics}
\begin{enumerate}[(a)]
\item Is Firefox a {\bf web server} or a {\bf web client}? (Circle one)
\item Consider this URL:
	{\tt https://www.cs.uky.edu/\verb+~+aStudent/file.cgi}
What is the {\bf protocol} of that URL?  \answerLine{1.7}
\item In the MultiLab, what is the {\bf full path name} of the file that the URL
above specifies? \answerSpace{0.6}
\item In the MultiLab, the file that the URL specifies has permissions 664 (in
octal).  Does the web server respond to the URL above by (1) sending the file or
(2) running the file as a program and sending its output (Circle {\bf (1)} or
{\bf (2)}.)
\item Is it valid HTML to embed a {\tt <span>} region within the {\tt <head>}
region? (Circle {\bf yes} or {\bf no}).
\end{enumerate}

\section{HTML}

This question refers to 
\hyperref{https://www.cs.uky.edu/~raphael/courses/CS316/exams/sample.html}{}
{}{https://www.cs.uky.edu/~raphael/courses/CS316/exams/sample.html}.

\begin{enumerate}[(a)]
\item This web page has one HTML error.  What is the error?
\answerSpace{.7}
\item I want to put a black box around the first verse of Frost's poem.
Without putting any content in the {\tt <head>} region or using any JavaScript,
how can I do that?  Be specific: What do you put and where?
\answerSpace{.7}
\item The last lines of the poems are in a different font.  Why?
\answerSpace{.7}
\item What is the purpose of the {\tt integrity} attribute in the {\tt <script>}
region?
\answerSpace{.7}
\end{enumerate}

\section{Navigating the DOM}
This question also refers to 
\hyperref{https://www.cs.uky.edu/~raphael/courses/CS316/exams/sample.html}{}
{}{https://www.cs.uky.edu/~raphael/courses/CS316/exams/sample.html}.
You should try out your answers using the Developer Tools console.
You may not use jQuery for this question.
\begin{enumerate}[(a)]
\item Write a JavaScript expression using the DOM (but without using XPath)
that results in the 
{\tt <pre>} node containing Frost's poem. (There are many correct answers).
\answerSpace{.7}
\item Given that the variable {\tt p} has as its value that {\tt <pre>} node,
write a JavaScript statement that uses {\tt p} and changes the color of that
region to red.
\answerSpace{.6}
\item Write an XPath expression that evaluates to an array of all {\tt <pre>}
nodes.  (There are many correct answers).
\answerSpace{.6}
\item Given that the variable {\tt xp} holds the results of that XPath
expression,
write a single JavaScript statement that uses {\tt xp} and
changes the background color of all {\tt <pre>} nodes to yellow.
\end{enumerate}

\section{CSS and jQuery}
This question also refers to 
\hyperref{https://www.cs.uky.edu/~raphael/courses/CS316/exams/sample.html}{}
{}{https://www.cs.uky.edu/~raphael/courses/CS316/exams/sample.html}.
You might want to copy this web page to one you can modify in order to verify
your answers.
\begin{enumerate}[(a)]
\item Write CSS that you could place in the {\tt <style>} region to put a
6px green shadow, blurring over 6px, to the right and below each {\tt <td>}
region.
\answerSpace{1.0}
\item Write CSS that you could place in the {\tt <style>} region to make the background
color ``lightblue'' and the font weight ``bold'' in the {\tt <td>} region
containing Frost's first verse.
\answerSpace{.6}
\item Write a single JavaScript statement that uses jQuery has exactly the
same effect (color and font weight in that region).
\answerSpace{.6}
\item Write JavaScript code that causes the size of the font in Frost's first
verse to become 30px when the mouse moves into that region (the event is called
"mouseenter").
\answerSpace{.6}
\end{enumerate}

\section{Organization}
\begin{enumerate}[(a)]
\item Does PHP run (1) in the browser or (2) on the web server's host?
(Circle {\bf (1)} or {\bf (2)}.)
\item Are SQL queries generated by (1) the browser or (2) a CGI program?
(Circle {\bf (1)} or {\bf (2)}.)
\item If I have a database relation called {\tt MYRELATION}, what SQL query
returns all the fields of all the entries in that relation?
\answerSpace{.6}
\item Why are AJAX calls sometimes preferable to {\tt <form>} submits?
\answerSpace{.6}
\end{enumerate}


\end{document}

