< div id='cssmenu'>
< ul>
< li class=''>< a
href='${pageContext.request.contextPath}'>< span>Home<
/span>< /a>< /li>
< li>< a
href='${pageContext.request.contextPath}/login'><
span>Login< /span>< /a>< /li>
< li>< a
href='${pageContext.request.contextPath}/register'><
span>Register< /span>< /a>< /li>
< li class='#'>< a href='#'>< span>Submit a
Question< /span>< /a>< /li>
< li class='#'>< a href='#'>< span>Feedback<
/span>< /a>< /li>
< li>< a href='#'>< span>Contribute<
/span>< /a>< /li>
< li>< a href='#'>< span>Contact us<
/span>< /a>< /li>
< /ul>
< /div>
< c:if test='${not empty sessionScope.user}'>
< div style="position:absolute;top:70px;left:1100px">
Logged as < a href="#" class="button
username">${sessionScope.user}< /a>
< /div>
< div style="position:absolute;top:70px;left:1300px">
< a
href='${pageContext.request.contextPath}/logout'>Logout<
/a>
< /div>
< /c:if>
< div style="position:absolute;left:120px;top:60px">
< table cellpadding="0" cellspacing="50">
< tr>
< td>< a href="takeExam?test=java">< img
height="200" width="200"
src="${pageContext.request.contextPath}/images/java.png"/><
/a>< /td>
< td>< a href="takeExam?test=javascript">< img
height="200" width="200"
src="${pageContext.request.contextPath}/images/javascript.png"/><
/a>< /td>
< td>< a href="takeExam?test=sql">< img height="200"
width="200"
src="${pageContext.request.contextPath}/images/sql-logo.png"/><
/a>< /td>
< td>< a href="takeExam?test=python">< img
height="200" width="200"
src="${pageContext.request.contextPath}/images/python.jpg"/><
/a>< /td>
< /tr>
< tr>
< td>< a href="takeExam?test=css">< img height="200"
width="200"
src="${pageContext.request.contextPath}/images/css.jpg"/><
/a>< /td>
< td>< a href="takeExam?test=php">< img height="200"
width="200"
src="${pageContext.request.contextPath}/images/php-logo.jpg"/><
/a>< /td>
< td>< a href="takeExam?test=linux">< img
height="200" width="200"
src="${pageContext.request.contextPath}/images/logo-linux.png"/><
/a>< /td>
< td>< a href="takeExam?test=mongodb">< img
height="200" width="200"
src="${pageContext.request.contextPath}/images/mongodb_logo.png"/><
/a>< /td>
< /tr>
< /table>
< /div>
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
String username=request.getParameter("username");
String email=request.getParameter("email");
String password=request.getParameter("password");
Connection con=DatabaseConnectionFactory.createConnection();
try
{
Statement st=con.createStatement();
String sql = "INSERT INTO users values
('"+username+"','"+password+"','"+email+"')";
System.out.println(sql);
st.executeUpdate(sql);
}catch(SQLException sqe){System.out.println("Error : While
Inserting record in database");}
try
{
con.close();
}catch(SQLException se){System.out.println("Error : While Closing
Connection");}
request.setAttribute("newUser",username);
RequestDispatcher
dispatcher=request.getRequestDispatcher("/WEB-INF/jsps/regSuccess.jsp");
dispatcher.forward(request, response);
}
public class DatabaseConnectionFactory {
private static String dbURL="jdbc:mysql://localhost/quiz";
private static String dbUser="root";
private static String dbPassword="";
public static Connection createConnection()
{
Connection con=null;
try{
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver
class!");
System.exit(1);
}
con =
DriverManager.getConnection(dbURL,dbUser,dbPassword);
}
catch(SQLException sqe){ System.out.println("Error:
While Creating connection to
database");sqe.printStackTrace();}
return con;
}
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
String username=request.getParameter("username");
String password=request.getParameter("password");
Connection con=DatabaseConnectionFactory.createConnection();
ResultSet set=null;
int i=0;
try
{
Statement st=con.createStatement();
String sql = "Select * from users where username='"+username+"' and
password='"+password+"' ";
System.out.println(sql);
set=st.executeQuery(sql);
while(set.next())
{
i=1;
}
if(i!=0)
{ HttpSession session=request.getSession();
session.setAttribute("user",username);
RequestDispatcher
rd=request.getRequestDispatcher("/WEB-INF/jsps/home.jsp");
rd.forward(request, response);
}
else
{ request.setAttribute("errorMessage","Invalid username or
password");
RequestDispatcher
rd=request.getRequestDispatcher("/WEB-INF/jsps/login.jsp");
rd.forward(request, response);
}
}catch(SQLException sqe){System.out.println("Error : While Fetching
records from database");}
try
{
con.close();
}catch(SQLException se){System.out.println("Error : While Closing
Connection");}
}
@WebServlet(urlPatterns = { "/login", "/register", "/writeExam",
"/logout" })
public class MainController extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException {
String applicationContextPath =
request.getContextPath();
if
(request.getRequestURI().equals(applicationContextPath + "/"))
{
RequestDispatcher dispatcher = request
.getRequestDispatcher("/WEB-INF/jsps/home.jsp");
dispatcher.forward(request, response);
} else if (request.getRequestURI().equals(
applicationContextPath + "/login")) {
RequestDispatcher dispatcher = request
.getRequestDispatcher("/WEB-INF/jsps/login.jsp");
dispatcher.forward(request, response);
} else if (request.getRequestURI().equals(
applicationContextPath + "/register"))
{
RequestDispatcher dispatcher = request
.getRequestDispatcher("/WEB-INF/jsps/register.jsp");
dispatcher.forward(request, response);
} else if (request.getRequestURI().equals(
applicationContextPath + "/writeExam"))
{
request.getSession().setAttribute("currentExam",
null);
String exam = request.getParameter("test");
request.getSession().setAttribute("exam",
exam);
System.out.println(request.getSession().getAttribute("user"));
if (request.getSession().getAttribute("user") ==
null) {
request.getRequestDispatcher("/login").forward(request,
response);
} else {
RequestDispatcher dispatcher =
request
.getRequestDispatcher("/WEB-INF/jsps/quizDetails.jsp");
dispatcher.forward(request,
response);
}
} else if (request.getRequestURI().equals(
applicationContextPath + "/logout"))
{
request.getSession().invalidate();
RequestDispatcher dispatcher = request
.getRequestDispatcher("/WEB-INF/jsps/home.jsp");
dispatcher.forward(request, response);
}
}
}
< quiz>
< title>MongoDB Quiz (01/09/2015)< /title>
< questions>
< question>
<
quizquestion>MongoDB is a < /quizquestion>
<
answer>Relational Database< /answer>
< answer>Object
Relational Database< /answer>
< answer>Graph
Database< /answer>
< answer>Document
Database< /answer>
< correct>3<
/correct>
< /question>
< question>
<
quizquestion>What is the name of MongoDB server ?<
/quizquestion>
<
answer>mongoserver< /answer>
<
answer>mongod< /answer>
<
answer>mongodb< /answer>
< answer>mongo<
/answer>
< correct>1<
/correct>
< /question>
< question>
<
quizquestion>What is the name of MongoDB client ?<
/quizquestion>
< answer>mongo<
/answer>
<
answer>mongod< /answer>
<
answer>mongodb< /answer>
<
answer>mongo-client< /answer>
< correct>0<
/correct>
< /question>
< /questions>
< /quiz>
public class QuizQuestion {
int questionNumber;
String question;
String questionOptions[];
int correctOptionIndex;
public String getQuestion()
{
return question;
}
public int getQuestionNumber()
{
return questionNumber;
}
public void setQuestionNumber(int i)
{
questionNumber=i;
}
public int getCorrectOptionIndex()
{
return correctOptionIndex;
}
public String[] getQuestionOptions()
{
return questionOptions;
}
public void setQuestion(String s)
{
question=s;
}
public void setCorrectOptionIndex(int i)
{
correctOptionIndex=i;
}
public void setQuestionOptions(String[]s)
{
questionOptions=s;
}
}
public class Exam {
Document dom;
public int currentQuestion=0;
public Map selections=new LinkedHashMap();
public ArrayList questionList = new ArrayList(10);
public Exam(String test) throws
SAXException,ParserConfigurationException,IOException,
URISyntaxException{
dom=CreateDOM.getDOM(test);
}
// code
}
public int calculateResult(Exam exam){
int totalCorrect=0;
Map<Integer,Integer>
userSelectionsMap=exam.selections;
List userSelectionsList=new ArrayList(10);
for (Map.Entry<Integer, Integer> entry
:userSelectionsMap.entrySet()) {
userSelectionsList.add(entry.getValue());
}
List questionList=exam.questionList;
List correctAnswersList=new ArrayList(10);
for(QuizQuestion question: questionList){
correctAnswersList.add(question.getCorrectOptionIndex());
}
for(int i=0;i<selections.size();i++){
System.out.println(userSelectionsList.get(i)+"
--- "+correctAnswersList.get(i));
if((userSelectionsList.get(i)-1)==correctAnswersList.get(i)){
totalCorrect++;
}
}
System.out.println("You Got "+totalCorrect+"
Correct");
return totalCorrect;
}
Create a website that displays an adding quiz (use random numbers between 0 and 100 -...
Need urgently.Plz use math.random() formula for random
numbers and show the output as recquired.
Problem (Computer Assisted Instruction) The use of computers in education is referred to as Computer Assisted Instruction (CAI). Develop a Java application that can help an elementary school student learn division of two decimal integer numbers. When the application is launched, its behaviour should be like as described: 1. The application should welcome the learner and ask if ready to learn the topic. Assume the application...
(For Python program) Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...
Question 2 0/1 point (graded) What happens when you remove a directory using the command rm -r? You cannot remove a directory using the rm command. You permanently remove the entire directory, including all files and subdirectories. You move the entire directory to a trash folder, but it can be restored later. You get a warning message asking if you want to proceed, then you delete the directory. incorrect Answer Incorrect: Try again. Unix does not warn you before permanently...
For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...
New Perspectives on HTML5 and CSS3. Solve Chapter 13 Case
Problem 3.
mas_register.js
"use strict";
/*
New Perspectives on HTML5, CSS3, and JavaScript 6th Edition
Tutorial 13
Case Problem 3
Filename: mas_register.js
Author:
Date:
Function List
=============
formTest()
Performs a validation test on the selection of the conference
session package and the conference discount number
calcCart()
Calculates the cost of the registration and saves data
in session storage
writeSessionValues()
Writes data values from session storage in to the
registration...
C LANGUAGE. PLEASE INCLUDE COMMENTS :)
>>>>TheCafe V2.c<<<<
#include <stdio.h>
int main()
{
int fries; // A flag denoting whether they want fries or not.
char bacon; // A character for storing their bacon preference.
double cost = 0.0; // The total cost of their meal, initialized to start at 0.0
int choice; // A variable new to version 2, choice is an int that will store the
// user's menu choice. It will also serve as our loop control...