8. Coding
<%@ page language="java"%>
<html>
<head>
<title>E-LEARNING</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
.activeMenu{
font-family:verdana;font-weight:bold;font-size:11px;color:#666666;text-decoration:none;
}
A.menuLink{
font-family:verdana;font-size:11px;color:#666666;text-decoration:none;
}
A.menuLink:hover{
font-family:verdana;font-size:11px;color:#666666;text-decoration:none;
}
TD.infoLabel{
font-family:verdana;font-size:11px;color:#666666;text-decoration:none;
}
TD.infoValue{
font-family:verdana;font-weight:bold;font-size:11px;color:#336699;text-decoration:none;
}
TD.login{
font-family:verdana;font-size:11px;color:#111111;text-decoration:none;
}
</style>
<script>
function fnValidate()
{
if(document.f1.user_name.value==""){
alert("Enter your user name.");
return false;
}
if(document.f1.pass_word.value==""){
alert("Enter your Password.");
return false;
}
}
</script>
</head>
<body background="bg.jpg" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr> <td></td> <td height="100"> </td> </tr>
</table>
<table width="100%" border="0">
<tr>
<td>
<!--start of result display-->
<table width="100%" align="center">
<tr> <td>
<%
if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate">
<strong><font color="#FFffff" size="2" face="Arial">
<%=request.getParameter("result")%>
</font></strong></marquee>
<%
}
%>
</td> </tr> </table>
<!--end of result display-->
<br>
<br>
<form name=f1 action="user_login_verification.jsp" method=post >
<table width="50%" border="0" align="right" cellpadding="0" cellspacing="2">
<tr>
<td rowspan="5"> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td height="25" colspan="2" align="center"><div align="left">
<font color="#666666" size="2" face="Arial"><strong>Login
by Participant</strong></font></div></td>
</tr>
<tr>
<td width="25%" class="infoLabel"> User ID:</td>
<td width="75%"><font color="#999999">
<input type="text" name="user_name" >
</font></td>
</tr>
<tr>
<td class="infoLabel"> Password:</td>
<td> <input type="password" name="pass_word"> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name=submit value=Login onClick="return fnValidate()"></td>
</tr>
<tr>
<Td colspan=2> </Td>
</tr>
<tr>
<Td colspan=2> </Td>
</tr>
<tr>
<td> </td>
<Td colspan=2><div align="left"><font size="2" face="Arial, Helvetica, sans-serif">
<a href="forgot_password.jsp"><font color="#FF0000">Forgot Password? </font></a></font><font size="2"> </font>
<font size="2" face="Arial, Helvetica, sans-serif"><a href="signup.jsp">
<font color="#FF0000">New
User?Sign up</font></a></font>
<font size="2"> </font></div></Td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<p> </p>
</body>
</html>
------------------------------------------------------------------------------------------
signup.jsp
<%@ page import="INCLUDES.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<html>
<head>
<title>e-Learning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function fnMenuBg1(elementId)
{
document.getElementById(elementId).style.backgroundColor="#dfdfdf";
}
function fnMenuBg2(elementId)
{
document.getElementById(elementId).style.backgroundColor="#ffffff";
}
function fnValidate()
{
if(document.f1.trainee_name.value==""){
alert("Enter your name.");
return false;
}
if(document.f1.email.value==""){
alert("Enter your Email Id.");
return false;
}
if(document.f1.user_name.value==""){
alert("Enter username.");
return false;
}
if(document.f1.pass_word.value==""){
alert("Enter Password");
return false;
}
if(document.f1.retype_pass.value==""){
alert("Retype Password");
return false;
}
if(document.f1.pass_word.value!=document.f1.retype_pass.value){
alert("Password did not match");
return false;
}
}
</script>
</head>
<body background="signup.jpg">
<!--start of result display-->
<table width="100%" >
<tr>
<td>
<%if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate"><strong><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif"><%=request.getParameter("result")%></font></strong></marquee>
<%
}%>
</td>
</tr>
</table>
<!--end of result display-->
<table width="45%" border="0" align="right" cellpadding="0" cellspacing="0" bordercolorlight="#FFFFFF">
<tr>
<td>
<form name="f1" action="signup_insert.jsp" method="post">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="3">
<tr>
<td colspan="2" class="infoLabel"><strong>
<font color="#000099" size="2" face="Arial, Helvetica, sans-serif">
Enter Your Personal Details</font></strong></td>
</tr>
<tr>
<td class="infoLabel"><font color="#FF0000">*</font>Your Name:</td>
<td><input type="text" name="trainee_name"></td>
</tr>
<tr>
<td class="infoLabel"><font color="#FF0000">*</font>Email ID:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td class="infoLabel"> City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td class="infoLabel"> Country:</td>
<td><input type="text" name="country"></td>
</tr>
<tr>
<td class="infoLabel">Designation:</td>
<td><input type="text" name="designation"></td>
</tr>
<tr>
<td class="infoLabel"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" class="infoLabel">
<font color="#000099" size="2" face="Arial, Helvetica, sans-serif">
<strong>Enter Your Login Details</strong></font></td>
</tr>
<tr>
<td class="infoLabel"><font color="#FF0000">*</font>User Name:</td>
<td><input type="text" name="user_name" ></td>
</tr>
<tr>
<td class="infoLabel"><font color="#FF0000">*</font>Password:</td>
<td><input type="password" name="pass_word"></td>
</tr>
<tr>
<td class="infoLabel"><font color="#FF0000">*</font>Retype Password:</td>
<td><input type="password" name="retype_pass"></td>
</tr>
<tr>
<td class="infoLabel"> </td>
<td><input type="submit" name="submit" value="Submit" onClick="return fnValidate()" >
</table>
</form></td>
</tr>
</table>
</body>
</html>
-----------------------------------course_list1_model2.jsp-------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<%
String sort_by="";
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp?
result=Session Timed Out.Please, Login again.");
}
if(request.getParameter("sort_by")!=null)
{
sort_by=request.getParameter("sort_by");
}
if(sort_by.equals("category"))
{
sort_by="course_category,course_name";
}
else
{
sort_by="course_name";
}
String statement="select * from x_masterListOfCourses s,x_masterListOfCategory cat where s.course_category_id=cat.course_category_id order by " + sort_by;
ResultSet objRs=null;
ResultSet oRsTraineeStatus=null;
try
{
DB.setStatement(statement);
objRs=(ResultSet)DB.result();
}
catch(Exception e)
{
%>error occured : <%=e%><%
}
%>
<html>
<head>
<title>e-Learning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function fnMenuBg1(elementId)
{
document.getElementById(elementId).style.backgroundColor="#dfdfdf";
}
function fnMenuBg2(elementId)
{
document.getElementById(elementId).style.backgroundColor="";
}
</script>
</head>
<body topmargin="0">
<table width="100%" height="200" background="bg_top.jpg">
<tr>
<td align="right" valign="top">
<table border="0" align="right" cellpadding="0" cellspacing="0" >
<tr align="center">
<td height="15" id=home><a href="course_list_index2.jsp" class="menuLink" onMouseOver="fnMenuBg1('home')" onMouseOut="fnMenuBg2('home')">
Home </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=profile><a href="view_profile.jsp" class="menuLink" onMouseOver="fnMenuBg1('profile')" onMouseOut="fnMenuBg2('profile')"> View
Profile </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=password><a href="change_password.jsp" class="menuLink" onMouseOver="fnMenuBg1('password')" onMouseOut="fnMenuBg2('password')"> Change
Password </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td width="1" height="15" id=logout><a href="logout.jsp" class="menuLink" onMouseOver="fnMenuBg1('logout')" onMouseOut="fnMenuBg2('logout')"> Logout </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" align="right" class="login" > Login by:<%=user_name%>
</td>
</tr>
</table>
</td>
</tr></table>
<!--start of result display-->
<table width="100%" >
<tr>
<td>
<%if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate"><strong>
<font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">
<%=request.getParameter("result")%></font></strong></marquee>
<% }%>
</td>
</tr>
</table>
<!--end of result display-->
<table width="100%" height="858" >
<tr>
<td align="center" valign="top"> <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#FFFFFF">
<tr bgcolor="#FF9900">
<td width="4%" height="25"> <div align="center">
<font color="#FFFFFF" face="Arial, Helvetica, sans-serif"><strong>
<font size="2">S.No</font></strong></font></div></td>
<td height="25"> <div align="center"><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"><strong><font size="2">C.
Code</font></strong></font></div></td>
<td width="34%" height="25"> <div align="center">
<font color="#FFFFFF"><a href="course_list1_model2.jsp?sort_by=course" title="Click here to sort by course name">
<font face="Arial, Helvetica, sans-serif"><strong><font size="2" color="#FFFFFF">Course
Name</font></strong></font></a></font></div></td>
<td width="21%" height="25"> <div align="center">
<font color="#FFFFFF"><a href="course_list1_model2.jsp?sort_by=category" title="Click here to sort by course name"><font face="Arial, Helvetica, sans-serif"><strong><font size="2" color="#FFFFFF">Course
Category</font></strong></font></a></font></div></td>
<td width="24%" height="25"> <div align="center">
<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>Your
Status</strong></font></div></td>
<td width="10%" height="25"> <div align="center">
<font color="#FFFFFF" face="Arial, Helvetica, sans-serif"><strong> </strong></font></div></td>
</tr>
<%
try
{
int i=1;
while(objRs.next())
{
%>
<%
int course_id=objRs.getInt("course_id");
int no_of_attempts=0;
int is_successfully_completed=0;
String date_of_registration_str=null;
String course_completed_date_str=null;
java.util.Date date_of_registration=null;
java.util.Date course_completed_date=null;
int is_registered=0;
String back_color="";
try
{
String statement1="select * from x_master_trainee_detail_online where course_id=" + course_id + " and user_name='" + session.getAttribute("user_name") + "'";
DB1.setStatement(statement1);
oRsTraineeStatus=DB1.result();
if(oRsTraineeStatus.next())
{
is_registered=oRsTraineeStatus.getInt("is_registered");
date_of_registration=oRsTraineeStatus.getDate("doe");
date_of_registration_str=date_of_registration.getDate() + "-" + (date_of_registration.getMonth()+1) + "-" + (date_of_registration.getYear()+1900);
is_successfully_completed=oRsTraineeStatus.getInt("is_successfully_completed");
course_completed_date=oRsTraineeStatus.getDate("course_completed_date");
course_completed_date_str=course_completed_date.getDate() + "-" + (course_completed_date.getMonth()+1) + "-" + (course_completed_date.getYear()+1900);
}
}
catch(Exception ex)
{
}
if(is_successfully_completed==1)
{
back_color="bgcolor=#FFFFCC";
}
else
{
if(is_registered==1)
{
back_color="bgcolor=#f0f0ff";
}
else
{
back_color="";
}
}
%>
<tr <%=back_color%>>
<td height="30"> <div align="center"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=i%></font></div></td>
<td height="30" ><div align="center"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=course_id%></font>
</div></td>
<td height="30" title="<%=objRs.getString("course_description")%>" ><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=objRs.getString("course_name")%></font></td>
<td height="30"> <div align="left"><font color="#666666" size="2" face="Verdana, Arial, Helvetica, sans-serif" ><%=objRs.getString("course_category")%></font></div></td>
<td height="30"> <font color="#666666">
<%
if(is_successfully_completed > 0)
{%>
<font size="1" face="Arial, Helvetica, sans-serif">Successfully completed
on <%=course_completed_date_str%></font></font> <font color="#666666">
<%
}
else
{
if(is_registered==1)
{
%>
<font size="1" face="Arial, Helvetica, sans-serif"> Enrolled on <%=date_of_registration_str%><br>
(not yet completed)</font></font> <font color="#666666">
<% }
else
{%>
<font size="1" face="Arial, Helvetica, sans-serif">Not yet enrolled</font></font><font color="#666666" size="2" face="Arial, Helvetica, sans-serif"><strong>
</strong></font> <font color="#666666">
<% }
}%>
</font></td>
<td height="30"> <div align="center"><a href="course_step.jsp?course_id=<%=course_id%>">
<font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif"><strong>
select<font color=#336699 face="Times New Roman">► </font></strong></font></a></div></td>
</tr>
<%
i=i+1;
}
}
catch(Exception e)
{
%>
Error ocuured in while : <%=e%>
<%
}
%>
</table>
<!--old----------------------------------------------->
<font color="#000099" size="2" face="Arial, Helvetica, sans-serif"><br>
<br>
</font> </td>
</tr>
</table>
<br>
</div>
</body>
</html>
------------------------------------------course_step.jsp-----------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<%
int course_id=0;
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp?result=Session Timed Out.Please, Login again.");
}
String statement="";
String course_name="";
String course_category="";
String trainee_name="";
int no_of_papers=0;
String course_description="";
if(request.getParameter("course_id")!=null)
{
course_id=Integer.parseInt(request.getParameter("course_id"));
session.setAttribute("course_id",Integer.toString(course_id));
}
ResultSet objRs=null;
ResultSet oRsTraineeStatus=null;
try
{
statement="select * from x_master_elearning_user u,x_masterListOfCourses c,x_masterListOfCategory cat where c.course_category_id=cat.course_category_id and c.course_id=" + course_id + " and u.user_name='" + user_name + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.result();
}
catch(Exception e)
{
%>error occured : <%=e%><%
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>e-Learning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function fnMenuBg1(elementId)
{
document.getElementById(elementId).style.backgroundColor="#dfdfdf";
}
function fnMenuBg2(elementId)
{
document.getElementById(elementId).style.backgroundColor="";
}
function fnClick(getElement,course_id)
{
if(getElement=="enroll")
{
location.href="enroll.jsp?course_id=" + course_id;
}
if(getElement=="tutorial")
{
location.href="view_document.jsp?course_id=" + course_id;
}
if(getElement=="evaluate")
{
location.href="course_registration_form.jsp?course_id=" + course_id;
}
if(getElement=="exam")
{
location.href="course_tutorial1.jsp?course_id=" + course_id;
}
if(getElement=="result")
{
location.href="course_registration_form.jsp?course_id=" + course_id;
}
if(getElement=="certificate")
{
location.href="view_certificate.jsp?course_id=" + course_id;
}
if(getElement=="choose")
{
location.href="course_list1_model2.jsp";
}
}
</script>
</head>
<body background="bg_step.jpg" topmargin="0" leftmargin="0">
<%
try
{
if(objRs.next())
{
trainee_name=objRs.getString("first_name");
course_name=objRs.getString("course_name");
course_category=objRs.getString("course_category");
no_of_papers=objRs.getInt("no_of_papers");
course_description=objRs.getString("course_description");
}
}
catch(Exception e)
{
out.print("Error occured in objRs : " + e);
}
%>
<table border="0" align="right" cellpadding="0" cellspacing="0" >
<tr align="center">
<td height="15" id=home><a href="course_list1_model2.jsp" class="menuLink" onMouseOver="fnMenuBg1('home')" onMouseOut="fnMenuBg2('home')">
Home </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=profile><a href="view_profile.jsp" class="menuLink" onMouseOver="fnMenuBg1('profile')" onMouseOut="fnMenuBg2('profile')"> View
Profile </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=password><a href="change_password.jsp" class="menuLink" onMouseOver="fnMenuBg1('password')" onMouseOut="fnMenuBg2('password')"> Change
Password </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td width="1" height="15" id=logout><a href="logout.jsp" class="menuLink" onMouseOver="fnMenuBg1('logout')" onMouseOut="fnMenuBg2('logout')"> Logout </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" align="right" class="login" > Login by:<%=user_name%>
</td>
</tr>
</table>
<table width="100%" >
<tr>
<td align="center" valign="top">
<!--start of result display-->
<table width="100%" align="center">
<tr>
<td>
<%
if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate">
<strong><font color="#FFffff" size="2" face="Arial, Helvetica, sans-serif"><%=request.getParameter("result")%></font></strong></marquee>
<%
}
%>
</td>
</tr>
</table>
<!--end of result display-->
<%
try
{
statement="select * from x_master_trainee_detail_online where course_id=" + course_id + " and user_name='" + session.getAttribute("user_name") + "'";
DB1.setStatement(statement);
oRsTraineeStatus=(ResultSet)DB1.result();
}
catch(Exception e)
{
%>error occured in parameters : <%=e%><%
}
int is_registered=0;
int is_successfully_completed=0;
int is_paper1_completed=0;
int is_paper1_tutorial_viewed=0;
int is_evaluated=0;
String date_of_registration="";
String course_completed_date="";
try
{
if(oRsTraineeStatus.next())
{
is_paper1_tutorial_viewed=oRsTraineeStatus.getInt("is_paper1_tutorial_viewed");
is_paper1_completed=oRsTraineeStatus.getInt("is_paper1_completed");
is_registered=oRsTraineeStatus.getInt("is_registered");
date_of_registration=oRsTraineeStatus.getString("doe");
is_successfully_completed=oRsTraineeStatus.getInt("is_successfully_completed");
course_completed_date=oRsTraineeStatus.getString("course_completed_date");
session.setAttribute("trainee_id",oRsTraineeStatus.getString("trainee_id"));
}
}
catch(Exception e)
{
out.print("exception occured in Trainee Status " + e);
}
%>
<tr><td>
<table width="50%" border="0" align="right" cellpadding="0" cellspacing="0" bordercolordark="#FF9900" bordercolorlight="#FFCC00" bordercolor="#FF9900">
<tr>
<td bordercolor="#000000">
<table width="100%" border="0" cellpadding="5">
<tr>
<td width="50%" align="right" class="infoLabel">Your Name:</td>
<td class="infoValue"><%=trainee_name%></td>
</tr>
<tr>
<td width="50%" align="right" class="infoLabel">Course Name:</td>
<td class="infoValue"><%=course_name%></td>
</tr>
<tr>
<td width="50%" align="right" class="infoLabel">Course Category:</td>
<td class="infoValue"><%=course_category%></td>
</tr>
<tr>
<td width="50%" align="right" class="infoLabel">Total no. of Modules:</td>
<td class="infoValue"><%=no_of_papers%></td>
</tr>
<tr>
<td width="50%" align="right" class="infoLabel">Course Description:</td>
<td class="infoValue"><%=course_description%></td>
</tr>
</table></td></tr></table></td></tr>
<table width="100%">
<tr>
<td width="404" valign=top>
<!--left box for steps-->
<table width="100%" border="0" align="left" cellspacing="3">
<tr>
<td width="24%"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">step
1.</font></td>
<td width="76%">
<%if(is_registered==0)
{%>
<input style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" type="button" value="Enroll for this course" name="enroll" onClick="fnClick('enroll','<%=course_id%>')">
<%
}
else
{%>
<input disabled style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" type="button" value="Enroll for this course" name="enroll">
<%}%>
</td>
</tr>
<tr>
<td><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">step
2.</font></td>
<%
if(is_registered==1)
{
%>
<td><input type="button" style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" value="View the study material" name="tutorial" onClick="fnClick('tutorial','<%=course_id%>')"></td>
<%
}
else
{
%>
<td><input disabled type="button" style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" value="View the study material" name="tutorial" onClick="fnClick('tutorial','<%=course_id%>')"></td>
<%}%>
</tr>
<tr>
<td><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">step
3.</font></td>
<td>
<%if(is_registered==0 || is_paper1_tutorial_viewed==0 || is_successfully_completed==1)
{%>
<input disabled type="button" style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" name="exam" value="Appear for the exam" onClick="fnClick('exam','<%=course_id%>')">
<%
}
else
{%>
<input type="button" style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" name="exam" value="Appear for the exam" onClick="fnClick('exam','<%=course_id%>')">
<%}%>
</td>
</tr>
<tr>
<td><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">step
4.</font></td>
<td>
<%if(is_paper1_completed==0 || is_registered==0)
{%>
<input disabled type="button" style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" value="View Result" name=result onClick="fnClick('result','<%=course_id%>')">
<%
}
else
{%>
<input type="button" style="text-align:left;padding-left:10px;width:220px;background:#dddddd;font-face:verdana;font-weight:bold" value="View Result" name=result onClick="location.href='view_result.jsp?course_id=<%=course_id%>' ">
<%}%>
</td>
</tr>
</table>
<!--left box ends-->
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
----------------------------------------course_tutorial1.jsp-------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<%
int course_id=0;
int is_objRs_present=0;
String statement="";
ResultSet objRs=null;
ResultSet objRsPaper=null;
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp?result=Session Timed Out.Please, Login again.");
}
String trainee_name="";
String course_name="";
if(request.getParameter("course_id")!=null)
{
course_id=Integer.parseInt(request.getParameter("course_id"));
}
try
{
statement="select * from x_master_elearning_user u,x_master_trainee_detail_online t,x_masterListOfCourses c,x_masterListOfCategory cat where c.course_id=t.course_id and t.user_name=u.user_name and c.course_category_id=cat.course_category_id and c.course_id=" + course_id + " and u.user_name='" + user_name + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.result();
if(objRs.next())
{
trainee_name=objRs.getString("first_name");
course_name=objRs.getString("course_name");
is_objRs_present=1;
}
else
{
response.sendRedirect("course_list_index2.asp?result=Session Timed out");
}
session.setAttribute("trainee_id",objRs.getString("trainee_id"));
}
catch(Exception e)
{
%>error occured : <%=e%><%
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>e-Learning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="exam.jpg" topmargin="0">
<table border="0" align="right" cellpadding="0" cellspacing="0" >
<tr align="center">
<td height="15" id=home><a href="course_list1_model2.jsp" class="menuLink" onMouseOver="fnMenuBg1('home')" onMouseOut="fnMenuBg2('home')">
Home </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=back><a href="course_step.jsp?course_id=<%=course_id%>" class="menuLink" onMouseOver="fnMenuBg1('back')" onMouseOut="fnMenuBg2('back')">
Back </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=profile><a href="view_profile.jsp" class="menuLink" onMouseOver="fnMenuBg1('profile')" onMouseOut="fnMenuBg2('profile')"> View
Profile </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=password><a href="change_password.jsp" class="menuLink" onMouseOver="fnMenuBg1('password')" onMouseOut="fnMenuBg2('password')"> Change
Password </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td width="1" height="15" id=logout><a href="logout.jsp" class="menuLink" onMouseOver="fnMenuBg1('logout')" onMouseOut="fnMenuBg2('logout')"> Logout </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" align="right" class="login" > Login by:<%=user_name%>
</td>
</tr>
</table><br>
<table width="100%">
<tr>
<td height="34" colspan="4" valign="top"> </td>
<td align="center" valign="middle">
<p> </p><table border="0" align="right" cellpadding="5">
<tr>
<td align="right" class="infoLabel">Your Name:</td>
<td class="infoValue"><%=trainee_name%></td>
</tr>
<tr>
<td align="right" class="infoLabel">Course Name:</td>
<td class="infoValue"><%=course_name%></td>
</tr>
</table> </td>
</tr>
</table>
<table width="100%" height="858" >
<tr>
<td align="center" valign="top">
<!--start of result display-->
<table width="100%" align="center">
<tr>
<td>
<%
if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate"><strong><font color="#FFffff" size="2" face="Arial, Helvetica, sans-serif"><%=request.getParameter("result")%></font></strong></marquee>
<%
}
%>
</td>
</tr>
</table>
<!--end of result display-->
<br>
<table width="50%" border="0" align="right" cellpadding="3" cellspacing="3" bordercolorlight="#FFffff">
<%
try
{
statement="select * from x_masterListOfPapers where course_id=" + course_id;
DB1.setStatement(statement);
objRsPaper=(ResultSet)DB1.result();
}
catch(Exception e)
{
%>
error occured in paper : <%=e%>
<%
}
try
{
if(is_objRs_present==1)
{
int is_previous_paper_completed=1;
int total_marks=0;
while(objRsPaper.next())
{
int paper_no=objRsPaper.getInt("paper_no");
int no_of_attempts=0;
int attempt_id=0;
int marks=0;
java.util.Date appeared_on=null;
String back_color="";
String attempt_message="";
String paper_name=objRsPaper.getString("paper_name");
no_of_attempts=objRs.getInt("paper" + paper_no + "_no_of_attempts");
int paper_id=objRsPaper.getInt("paper_id");
String dbase=objRsPaper.getString("dbase");
int is_paper_completed=objRs.getInt("is_paper" + paper_no + "_completed");
if(paper_no==1)
{
total_marks=objRs.getInt("total_marks");
}
if(is_paper_completed==1)
{
back_color="bgcolor=#ffffcc";
}
else
{
back_color="";
}
if(is_paper_completed==1)
{
attempt_message="Successfully Completed ";
}
else
{
if(is_previous_paper_completed==0)
{
attempt_message="Not yet Eligible as you have not completed previous modules";
}
else
{
switch(no_of_attempts)
{
case 0:
attempt_id=1;
attempt_message="Not completed, You have a total of 3 attempts";
break;
case 1:
attempt_id=2;
attempt_message="Not completed,1 attempt exhausted ,you have 2 more attempts.";
break;
case 2:
attempt_id=3;
attempt_message="Not completed,2 attempts exhausted,you have 1 more attempt.";
break;
case 3:
attempt_message="All the attempts are exhausted and so you cannot complete the e ";
break;
default:
attempt_message="Not completed, and you are eligible for the exam ";
}
}
}
%>
<tr>
<td colspan="3"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Module.<%=paper_no%> : <%=paper_name%> </font></strong>
<%
if(paper_no==1)
{
if(no_of_attempts<3 && is_paper_completed==0)
{%>
<a href="course_tutorial2.jsp?attempt_id=<%=attempt_id%>&course_id=<%=course_id%>&paper_id=<%=paper_id%>&dbase=<%=dbase%>&no_of_attempts=<%=no_of_attempts%>&paper_no=<%=paper_no%>"><strong><font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">
Appear for the exam</font></strong></a> <font size="2">
<%
}
else
{
%>
<del><strong><font color="#ff0000" face="Arial, Helvetica, sans-serif" size="2">Appear
for the exam</font></strong></del>
<%
}
}
else
{
if(is_previous_paper_completed==1 && no_of_attempts<3 && is_paper_completed==0)
{
%>
<a href="course_tutorial2.jsp?attempt_id=<%=attempt_id%>&course_id=<%=course_id%>&paper_id=<%=paper_id%>&dbase=<%=dbase%>&no_of_attempts=<%=no_of_attempts%>&paper_no=<%=paper_no%>"><strong><font color="#FF0000" face="Arial, Helvetica, sans-serif" size="2">Appear
for the exam</font></strong></a>
<%
}
else
{
%>
<del><strong><font color="#ff0000" face="Arial, Helvetica, sans-serif" size="2">Appear
for the exam</font></strong></del></font>
<%
}
}
%>
</td>
</tr>
<tr>
<td> </td><td colspan="2"><font color="#FFFF00" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=attempt_message%></font></td>
</tr>
<%if(no_of_attempts>0)
{%>
<tr>
<td width="7%" class="infoLabel" > </td>
<td width="31%" class="infoLabel">Marks obtained :</td>
<%
marks=(objRs.getInt("paper" + paper_no + "_marks")*100)/total_marks;
%>
<td width="62%" class="infoValue"><%=marks%>%</td>
</tr>
<%
appeared_on=objRs.getDate("paper" + paper_no + "_appeared_on");
String appeared_on_str=appeared_on.getDate() + "-" + (appeared_on.getMonth()+1) + "-" + (appeared_on.getYear()+1900);
%>
<tr>
<td> </td>
<td class="infoLabel">Appeared On :</td>
<td class="infoValue"><%=appeared_on_str%></td>
<%
%>
</tr>
<tr>
<td> </td>
<td class="infoLabel">No. of Attempts :</td>
<td class="infoValue"><%=no_of_attempts%></td>
</tr>
<%}%>
<tr>
<td colspan="3"><hr noshade color="#FFFFCC"></td>
</tr>
<%
is_previous_paper_completed=is_paper_completed;
}
%>
<tr>
<td class="infoLabel" colspan="3">Pass precentage :50%</td>
</tr>
<%
}
else
{
out.print("NIL");
}
%>
</table>
<div align="left">
</div></td>
</tr>
<%
}
catch(Exception e)
{
out.print("error occured in while of paper : " + e);
}
%>
</table>
</body>
</html>
--------------------------------------------course_tutorial2.jsp------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<html>
<head>
<title>
ELEARNING
</title>
<script>
function fnMenuBg1(elementId)
{
document.getElementById(elementId).style.backgroundColor="#dfdfdf";
}
function fnMenuBg2(elementId)
{
document.getElementById(elementId).style.backgroundColor="";
}
</script>
</head>
<body background="instruction.jpg" topmargin="0">
<%
String statement="";
ResultSet objRs=null;
ResultSet oRsQn=null;
int course_id=0;
int paper_no=0;
int attempt_id=0;
String attempt="";
String paper_name="";
String course_name="";
String trainee_name="";
int number_of_questions=0;
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp?result=Session Timed Out.Please, Login again.");
}
if(request.getParameter("course_id")!=null)
{
course_id=Integer.parseInt(request.getParameter("course_id"));
paper_no=Integer.parseInt(request.getParameter("paper_no"));
attempt_id=Integer.parseInt(request.getParameter("attempt_id"));
}
try
{
statement="select * from x_master_elearning_user u,x_master_trainee_detail_online t,x_masterListOfCourses c,x_masterListOfPapers p where c.course_id=t.course_id and t.user_name=u.user_name and c.course_id=p.course_id and c.course_id=" + course_id + " and u.user_name='" + user_name + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.result();
if(objRs.next())
{
paper_name=objRs.getString("paper_name");
course_name=objRs.getString("course_name");
trainee_name=objRs.getString("first_name");
}
}
catch(Exception e)
{
out.print("Error occured : " + e);
}
if(attempt_id==1)
{
attempt="first";
}
else
{
if(attempt_id==2)
{
attempt="second";
}
else
{
attempt="third";
}
}
try
{
statement="select * from TRAINING_CENTRE_PARAMETERS";
DB1.setStatement(statement);
oRsQn=(ResultSet)DB1.result();
if(oRsQn.next())
{
number_of_questions=oRsQn.getInt("number_of_questions");
}
else
{
number_of_questions=25;
}
session.setAttribute("number_of_questions","" + number_of_questions);
}
catch(Exception e)
{
out.print("errror occured 2 : " + e);
}
%>
<table border="0" align="right" cellpadding="0" cellspacing="0" >
<tr align="center">
<td height="15" id=home><a href="course_list1_model2.jsp" class="menuLink" onMouseOver="fnMenuBg1('home')" onMouseOut="fnMenuBg2('home')">
Home </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=back><a href="course_step.jsp?course_id=<%=course_id%>" class="menuLink" onMouseOver="fnMenuBg1('back')" onMouseOut="fnMenuBg2('back')">
Back </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=profile><a href="view_profile.jsp" class="menuLink" onMouseOver="fnMenuBg1('profile')" onMouseOut="fnMenuBg2('profile')"> View
Profile </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=password><a href="change_password.jsp" class="menuLink" onMouseOver="fnMenuBg1('password')" onMouseOut="fnMenuBg2('password')"> Change
Password </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td width="1" height="15" id=logout><a href="logout.jsp" class="menuLink" onMouseOver="fnMenuBg1('logout')" onMouseOut="fnMenuBg2('logout')"> Logout </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" align="right" class="login" > Login by:<%=user_name%>
</td>
</tr>
</table><br>
<table width="100%">
<tr>
<td height="34" colspan="4" valign="top"> </td>
<td align="center" valign="middle">
<p> </p><table border="0" align="right" cellpadding="5">
<tr>
<td align="right" class="infoLabel">Your Name:</td>
<td class="infoValue"><%=trainee_name%></td>
</tr>
<tr>
<td align="right" class="infoLabel">Course Name:</td>
<td class="infoValue"><%=course_name%></td>
</tr>
</table> </td>
</tr>
</table>
<!--start of result display-->
<table width="100%" align="center">
<tr>
<td>
<%
if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate"><strong><font color="#FFffff" size="2" face="Arial, Helvetica, sans-serif"><%=request.getParameter("result")%></font></strong></marquee>
<%
}
%>
</td>
</tr>
</table>
<!--end of result display-->
<table width="75%" border="0" cellpadding="0" cellspacing="0" bordercolorlight="#FFFFFF">
<tr>
<td><table width="100%" border="0" cellpadding="5">
<tr>
<td width="8%"> </td>
<td width="92%" class="infoValue"> </td>
</tr>
<tr>
<td align="center" class="infoLabel">1.</td>
<td class="infoLabel">You have chosen to attempt the module <font color="#000099"><%=paper_name%></font>
of <font color="#000099"><%=course_name%>.</font></td>
</tr>
<tr>
<td align="center" class="infoLabel">2.</td>
<td class="infoLabel">Click on 'Begin Test' button to start the test.</td>
</tr>
<tr>
<td align="center" class="infoLabel">3.</td>
<td class="infoLabel">It is considered as your <font color="#000099"><%=attempt%></font>
attempt.</td>
</tr>
<tr>
<td align="center" class="infoLabel">4.</td>
<td class="infoLabel">Click on the 'Next' button to move to the next question.</td>
</tr>
<tr>
<td align="center" class="infoLabel">5.</td>
<td class="infoLabel">Click the 'Review' button to review your answers after completing.</td>
</tr>
<tr>
<td align="center" class="infoLabel">6.</td>
<td class="infoLabel">All questions carry equal marks.</td>
</tr>
<tr>
<td align="center" class="infoLabel">7.</td>
<td class="infoLabel">Each test contains <font color="#000099"><%=number_of_questions%></font> questions.</td>
</tr>
<tr>
<form action="CourseToSession_final.jsp" method=post>
<input type=hidden name="paper_no" value="<%=paper_no%>">
<input type=hidden name="course_id" value="<%=course_id%>">
<input type=hidden name="no_of_attempts" value="<%=request.getParameter("no_of_attempts")%>">
<input type=hidden name="dbase" value="<%=request.getParameter("dbase")%>">
<input type=hidden name="attempt_id" value="<%=attempt_id%>">
<input type=hidden name="paper_id" value="<%=request.getParameter("paper_id")%>">
<td> </td>
<td><input type=submit value="Begin Test" style="font-size:16pt;">
</td>
</form>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
--------------------------------------exam_question.jsp---------------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<jsp:useBean id="DB2" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB2" property="*"/>
<%
String dbase=(String)session.getAttribute("dbase");
String trainee_id=(String)session.getAttribute("trainee_id");
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp?result=Session Timed Out.Please, Login again.");
}
int attempt_id=Integer.parseInt((String)session.getAttribute("attempt_id"));
int number_of_questions=Integer.parseInt((String)session.getAttribute("number_of_questions"));
int course_id=Integer.parseInt((String)session.getAttribute("course_id"));
int paper_id=Integer.parseInt((String)session.getAttribute("paper_id"));
String statement=null;
ResultSet objRs=null;
ResultSet objRsQNo=null;
ResultSet objRsQ=null;
int no_of_papers=0,paper_no=0;
String course_name="",trainee_name="",paper_name="";
try
{
statement="select * from x_master_elearning_user u,x_master_trainee_detail_online t,x_masterListOfCourses c ,x_masterListOfPapers p where p.course_id=c.course_id and c.course_id=t.course_id and t.user_name=u.user_name and c.course_id=" + course_id + " and u.user_name='" + user_name + "' and p.paper_id=" + paper_id;
DB.setStatement(statement);
objRs=(ResultSet)DB.result();
if(objRs.next())
{
course_name=objRs.getString("course_name");
trainee_name=objRs.getString("first_name");
paper_name=objRs.getString("paper_name");
no_of_papers=objRs.getInt("no_of_papers");
paper_no=objRs.getInt("paper_no");
}
}
catch(Exception e)
{
out.print("error occured 1 :" + e);
}
int i=0;
if(request.getParameter("question_no")==null)
{
i=1;
}
else
{
i=Integer.parseInt(request.getParameter("question_no"))+1;
}
try
{
statement="select * from results where paper_id=" + paper_id + " and course_id=" + course_id + " and trainee_id='" + trainee_id + "'";
DB1.setStatement(statement);
objRsQNo=(ResultSet)DB1.result();
if(objRsQNo.next())
{
if(i<= number_of_questions)
{
statement="select * from x_masterListOfQuestions where paper_id=" + paper_id + " and question_id=" + objRsQNo.getInt("qn" + i);
DB2.setStatement(statement);
objRsQ=(ResultSet)DB2.result();
}
}
}
catch(Exception e)
{
out.print("error occured 22 :" + e);
}
%>
<form method="post" action="exam_question_insert.jsp" >
<input type="hidden" name="question_no" value=<%=i%>
<table width="75%" align="right" >
<tr>
<td colspan="3"><hr color="#FFFFff" noshade size="1"></td>
</tr>
<%
try
{
if(objRsQ.next())
{
%>
<tr >
<td width="9%" class="infoLabel">Q No.<strong><%=i%></strong></td>
<td colspan="2" class="infoValue"><%=objRsQ.getString("question")%></td>
</tr>
<tr>
<td> </td>
<td colspan="2" class="infoValue"> <input type="radio" name="choice<%=i%>" value=1>
<%=objRsQ.getString("choice1")%></td>
</tr>
<tr>
<td> </td>
<td colspan="2" class="infoValue"> <input type="radio" name="choice<%=i%>" value=2>
<%=objRsQ.getString("choice2")%></td>
</tr>
<tr>
<td> </td>
<td colspan="2" class="infoValue"> <input type="radio" name="choice<%=i%>" value=3>
<%=objRsQ.getString("choice3")%></td>
</tr>
<tr>
<td> </td>
<td colspan="2" class="infoValue"> <input type="radio" name="choice<%=i%>" value=4>
<%=objRsQ.getString("choice4")%></td>
</tr>
<%
}
}
catch(Exception e)
{
out.print("error occured 55 : " + e);
}
%>
<tr>
<td colspan="3"><hr color="#FFFFff" noshade size="1"></td>
</tr>
<tr>
<td align=center> </td>
<td align="right">
<%if(i== number_of_questions)
{
%>
<div align="right">
<input type="submit" value="Finish" style="font-size:13pt;" name="submit" onClick="return fnConfirm()">
<%
}
else
{
%>
<input type="submit" value="Next" style="font-size:13pt;" name="submit">
<%
}
%>
</div></td>
<td width="47%" align="right"><input type="submit" value="Review" style="font-size:13pt" name="submit"></td>
</tr>
</table>
</form>
</body>
</html>
--------------------------------------result_calculation-------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<jsp:useBean id="DB2" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB2" property="*"/>
<jsp:useBean id="DB3" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB3" property="*"/>
<jsp:useBean id="DB4" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB4" property="*"/>
<%
String trainee_id=(String)session.getAttribute("trainee_id");
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp?result=Session Timed Out.Please, Login again.");
}
int number_of_questions=Integer.parseInt((String)session.getAttribute("number_of_questions"));
int course_id=Integer.parseInt((String)session.getAttribute("course_id"));
int paper_id=Integer.parseInt((String)session.getAttribute("paper_id"));
int attempt_id=Integer.parseInt((String)session.getAttribute("attempt_id"));
String statement=null;
ResultSet objRs=null;
ResultSet objRs1=null;
ResultSet objRsQNo=null;
ResultSet objRsUpdate=null;
ResultSet objRsUpdate1=null;
String trainee_name="",course_name="",paper_name="",course_category="";
int no_of_papers=0,paper_no=0;
try
{
statement="select * from x_master_elearning_user u,x_master_trainee_detail_online t,x_masterListOfCourses c ,x_masterListOfPapers p,x_masterListOfCategory cat where c.course_category_id=cat.course_category_id and p.course_id=c.course_id and c.course_id=t.course_id and t.user_name=u.user_name and c.course_id=" + course_id + " and u.user_name='" + user_name + "' and p.paper_id=" + paper_id;
DB.setStatement(statement);
objRs1=(ResultSet)DB.result();
if(objRs1.next())
{
trainee_name=objRs1.getString("first_name");
course_name=objRs1.getString("course_name");
paper_name=objRs1.getString("paper_name");
course_category=objRs1.getString("course_category");
no_of_papers=objRs1.getInt("no_of_papers");
paper_no=objRs1.getInt("paper_no");
}
}
catch(Exception e)
{
out.print("error occured ");
}
try
{
statement="select * from results where attempt_id=" + attempt_id + " and course_id=" + course_id + " and paper_id=" + paper_id + " and trainee_id='" + trainee_id + "'";
DB1.setStatement(statement);
objRsQNo=(ResultSet)DB1.result();
objRsQNo.next();
}
catch(Exception e)
{
out.print("error occured 22 :"+e);
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>e-Learning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function fnMenuBg1(elementId)
{
document.getElementById(elementId).style.backgroundColor="#dfdfdf";
}
function fnMenuBg2(elementId)
{
document.getElementById(elementId).style.backgroundColor="";
}
function fnConfirm()
{
return confirm("Are you sure you want to FINISH the exam?");
}
function fnClick()
{
location.href="course_tutorial1.jsp?course_id=<%=course_id%>";
}
</script>
</head>
<body background="result.jpg" >
<table border="0" align="right" cellpadding="0" cellspacing="0" >
<tr align="center">
<td height="15" id=home><a href="course_list1_model2.jsp" class="menuLink" onMouseOver="fnMenuBg1('home')" onMouseOut="fnMenuBg2('home')">
Home </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=profile><a href="view_profile.jsp" class="menuLink" onMouseOver="fnMenuBg1('profile')" onMouseOut="fnMenuBg2('profile')"> View
Profile </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=password><a href="change_password.jsp" class="menuLink" onMouseOver="fnMenuBg1('password')" onMouseOut="fnMenuBg2('password')"> Change
Password </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td width="1" height="15" id=logout><a href="logout.jsp" class="menuLink" onMouseOver="fnMenuBg1('logout')" onMouseOut="fnMenuBg2('logout')"> Logout </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" align="right" class="login" > Login by:<%=user_name%>
</td>
</tr>
</table><br>
<table width="100%">
<tr>
<td height="34" colspan="4" valign="top"> </td>
<td align="center" valign="middle">
<table border="0" align="right" cellpadding="5">
<tr>
<td align="right" class="infoLabel">Your Name:</td>
<td class="infoValue"><%=trainee_name%></td>
</tr>
<tr>
<td align="right" class="infoLabel">Course Name:</td>
<td class="infoValue"><%=course_name%></td>
</tr>
<tr>
<td align="right" class="infoLabel">Module Name:</td>
<td class="infoValue"><%=paper_name%></td>
</tr>
<tr>
<td align="right" class="infoLabel">Module No.:</td>
<td class="infoValue"><%=paper_no%>/<%=no_of_papers%></td>
</tr>
<tr>
<td align="right" class="infoLabel">Attempt No.:</td>
<td class="infoValue"><%=attempt_id%>/3</td>
</tr>
</table> </td>
</tr>
</table>
<!--start of result display-->
<!--end of result display-->
<table width="100%" height="100%" border="0">
<tr>
<td valign="top">
<table width="75%" border="0">
<tr>
</tr>
<%
int i=1;
int total=0;
String back_color="",choice1="",choice2="",choice3="",choice4="";
int objRsQNans=0;
String question="";
while(i<= number_of_questions)
{
int user_ans=0;
try
{
statement="select * from x_masterListOfQuestions where paper_id=" + paper_id + " and question_id=" + objRsQNo.getInt("qn" + i);
DB2.setStatement(statement);
objRs=(ResultSet)DB2.result();
if(objRs.next())
{
user_ans=objRs.getInt("ans");
choice1=objRs.getString("choice1");
choice2=objRs.getString("choice2");
choice3=objRs.getString("choice3");
choice4=objRs.getString("choice4");
question=objRs.getString("question");
}
objRsQNans=objRsQNo.getInt("ans" + i);
}
catch(Exception e)
{
out.println("error occured 55 : "+e);
}
%>
<tr>
<td width="5%" rowspan="5" align="left" valign="top" class="infoLabel"><%=i%>.</td>
<td width="95%" class="infoValue"><%=question%></td>
</tr>
<%if(user_ans==1)
{
back_color="";
}
else
{
back_color="";
}
%>
<tr <%=back_color%>>
<%if(objRsQNans==1)
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=1 checked disabled>
<%=choice1%>
<%if(user_ans==1)
{%>
<img src="qbright.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">1
mark</font>
<%total=total+1;%>
<%
}
else
{%>
<img src="qbwrong.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">0
mark</font>
<%}%>
</td>
<%
}
else
{%>
<%if(objRsQNans==0)
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=1 disabled>
<%=choice1%><img src="not_attempted.gif" height="20" border="0"><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif">Not
attempted</font></td>
<%}
else
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=1 disabled>
<%=choice1%></td>
<%}%>
<%}%>
</tr>
<%
if(user_ans==2)
{
back_color="";
}
else
{
back_color="";
}
%>
<tr <%=back_color%>>
<%if(objRsQNans==2)
{%>
<td class="infoValue" >
<input type="radio" name="choice<%=i%>" value=2 checked disabled>
<%=choice2%>
<%if(user_ans==2)
{%>
<img src="qbright.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">1
mark</font>
<%total=total+1;%>
<%
}
else
{%>
<img src="qbwrong.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">0
mark</font>
<%}%>
</td>
<%}
else
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=2 disabled>
<%=choice2%></td>
<%}%>
</tr>
<%
if(user_ans==3)
{
back_color="";
}
else
{
back_color="";
}
%>
<tr <%=back_color%>>
<%if(objRsQNans==3)
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=3 checked disabled>
<%=choice3%>
<%if(user_ans==3)
{%>
<img src="qbright.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">1
mark</font>
<%total=total+1;%>
<%
}
else
{%>
<img src="qbwrong.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">0
mark</font>
<%}%>
</td>
<%
}
else
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=3 disabled>
<%=choice3%></td>
<%}%>
</tr>
<%
if(user_ans==4)
{
back_color="";
}
else
{
back_color="";
}
%>
<tr <%=back_color%>>
<%if(objRsQNans==4)
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=4 checked disabled>
<%=choice4%>
<%if(user_ans==4)
{%>
<img src="qbright.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">1
mark</font>
<%total=total+1;%>
<%
}
else
{%>
<img src="qbwrong.gif" height="20" border="0"><font color="#FF0000" size="2" face="Verdana, Arial, Helvetica, sans-serif">0
mark</font>
<%}%>
</td>
<%
}
else
{%>
<td class="infoValue">
<input type="radio" name="choice<%=i%>" value=4 disabled>
<%=choice4%></td>
<%}%>
</tr>
<tr>
<td colspan="2"><hr color="#FFffff" size="1" ></td>
</tr>
<%
i=i+1;
}
%>
<tr>
<td colspan="2"><font color="#FF0000" size="5" face="Arial, Helvetica, sans-serif">TOTAL
MARKS : <strong><%=total%>/<%=number_of_questions%></strong><br>
</strong>
<%
try
{
statement="select * from results where attempt_id=" + attempt_id + " and course_id=" + course_id + " and paper_id=" + paper_id + " and trainee_id='" + trainee_id + "'";
DB3.setStatement(statement);
objRsUpdate=(ResultSet)DB3.resultUpdate();
objRsUpdate.next();
objRsUpdate.updateInt("Result",total);
objRsUpdate.updateRow();
}
catch(Exception e)
{
out.println("eror occured 66 : " + e);
}
try
{
statement="select * from x_master_trainee_detail_online where course_id=" + course_id + " and trainee_id='" + trainee_id + "'";
DB4.setStatement(statement);
objRsUpdate1=(ResultSet)DB4.resultUpdate();
objRsUpdate1.next();
objRsUpdate1.updateInt("paper_id" + paper_no,paper_id);
objRsUpdate1.updateInt("paper" + paper_no + "_no_of_attempts",attempt_id);
objRsUpdate1.updateInt("paper" + paper_no + "_marks",total);
objRsUpdate1.updateInt("is_attended_exam",1);
java.util.Date now=new java.util.Date();
java.sql.Date date = new java.sql.Date(now.getYear(),now.getMonth(),now.getDate());
objRsUpdate1.updateDate("paper" + paper_no + "_appeared_on",date);
objRsUpdate1.updateInt("total_marks",number_of_questions);
if(total>(number_of_questions /2))
{
objRsUpdate1.updateInt("is_paper" + paper_no + "_completed",1);
objRsUpdate1.updateDate("paper" + paper_no + "_completed_date",date);
out.print("STATUS:<strong>PASS</strong> <br>");
if(paper_no==no_of_papers)
{
objRsUpdate1.updateInt("is_successfully_completed",1);
objRsUpdate1.updateDate("course_completed_date",date);
}
}
else
{
out.print("STATUS:<strong>FAIL</strong> <br>");
}
objRsUpdate1.updateRow();
}
catch(Exception e)
{
out.println("error occured 77 : " + e);
}
%>
ATTEMPT NO.:<strong><%=attempt_id%></strong> </FONt></td>
</tr>
<tr>
<td colspan="2"><hr noshade color="#FFFFFF" size="1"></td>
</tr>
<tr>
<td colspan="2"><input type=button value="Continue" onClick="fnClick()"></td>
</tr>
</table>
</td>
</tr>
</table>
<%
session.removeAttribute("paper_no");
session.removeAttribute("paper_id");
session.removeAttribute("attempt_id");
%>
<p> </p>
</body>
</html>
-------------------------------view_result.jsp--------------------------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<%
int course_id=0;
int is_objRs_present=0;
String statement="";
ResultSet objRs=null;
ResultSet objRsPaper=null;
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.sendRedirect("course_list_index2.jsp?result=Session Timed Out.Please, Login again.");
}
String trainee_name="";
String course_name="";
if(request.getParameter("course_id")!=null)
{
course_id=Integer.parseInt(request.getParameter("course_id"));
}
try
{
statement="select * from x_master_elearning_user u,x_master_trainee_detail_online t,x_masterListOfCourses c,x_masterListOfCategory cat where c.course_id=t.course_id and t.user_name=u.user_name and c.course_category_id=cat.course_category_id and c.course_id=" + course_id + " and u.user_name='" + user_name + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.result();
if(objRs.next())
{
trainee_name=objRs.getString("first_name");
course_name=objRs.getString("course_name");
is_objRs_present=1;
}
else
{
response.sendRedirect("course_list_index2.asp?result=Session Timed out");
}
session.setAttribute("trainee_id",objRs.getString("trainee_id"));
}
catch(Exception e)
{
%>error occured : <%=e%><%
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>e-Learning</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
.activeMenu{
font-family:verdana;font-weight:bold;font-size:11px;color:#666666;text-decoration:none;
}
A.menuLink{
font-family:verdana;font-size:11px;color:#666666;text-decoration:none;
}
A.menuLink:hover{
font-family:verdana;font-size:11px;color:#666666;text-decoration:none;
}
TD.infoLabel{
font-family:verdana;font-size:11px;color:#666666;text-decoration:none;
}
TD.infoValue{
font-family:verdana;font-weight:bold;font-size:11px;color:#336699;text-decoration:none;
}
TD.login{
font-family:verdana;font-size:11px;color:#111111;text-decoration:none;
}
</style>
<script>
function fnMenuBg1(elementId)
{
document.getElementById(elementId).style.backgroundColor="#dfdfdf";
}
function fnMenuBg2(elementId)
{
document.getElementById(elementId).style.backgroundColor="";
}
function fnClick(course_id)
{
location.href="course_step.jsp?course_id=" + course_id;
}
</script>
</head>
<body background="result.jpg" topmargin="0">
<table border="0" align="right" cellpadding="0" cellspacing="0" >
<tr align="center">
<td height="15" id=home><a href="course_list1_model2.jsp" class="menuLink" onMouseOver="fnMenuBg1('home')" onMouseOut="fnMenuBg2('home')">
Home </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=back><a href="course_step.jsp?course_id=<%=course_id%>" class="menuLink" onMouseOver="fnMenuBg1('back')" onMouseOut="fnMenuBg2('back')">
Back </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=profile><a href="view_profile.jsp" class="menuLink" onMouseOver="fnMenuBg1('profile')" onMouseOut="fnMenuBg2('profile')"> View
Profile </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" id=password><a href="change_password.jsp" class="menuLink" onMouseOver="fnMenuBg1('password')" onMouseOut="fnMenuBg2('password')"> Change
Password </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td width="1" height="15" id=logout><a href="logout.jsp" class="menuLink" onMouseOver="fnMenuBg1('logout')" onMouseOut="fnMenuBg2('logout')"> Logout </a></td>
<td width="1" height="15" class="infoLabel">|</td>
<td height="15" align="right" class="login" > Login by:<%=user_name%>
</td>
</tr>
</table><br>
<table width="100%">
<tr>
<td height="34" colspan="4" valign="top"> </td>
<td align="center" valign="middle">
<p> </p><table border="0" align="right" cellpadding="5">
<tr>
<td align="right" class="infoLabel">Your Name:</td>
<td class="infoValue"><%=trainee_name%></td>
</tr>
<tr>
<td align="right" class="infoLabel">Course Name:</td>
<td class="infoValue"><%=course_name%></td>
</tr>
</table> </td>
</tr>
</table>
<table width="100%" height="858" >
<tr>
<td align="center" valign="top">
<!--start of result display-->
<table width="100%" align="center">
<tr>
<td>
<%
if(request.getParameter("result")!=null)
{
%>
<marquee loop="1" behavior="alternate"><strong><font color="#FFffff" size="2" face="Arial, Helvetica, sans-serif"><%=request.getParameter("result")%></font></strong></marquee>
<%
}
%>
</td>
</tr>
</table>
<!--end of result display-->
<br>
<table width="50%" border="0" align="left" cellpadding="3" cellspacing="3" bordercolorlight="#FFffff">
<%
try
{
statement="select * from x_masterListOfPapers where course_id=" + course_id;
DB1.setStatement(statement);
objRsPaper=(ResultSet)DB1.result();
}
catch(Exception e)
{
%>
error occured in paper : <%=e%>
<%
}
try
{
if(is_objRs_present==1)
{
int is_previous_paper_completed=1;
int total_marks=0;
while(objRsPaper.next())
{
int paper_no=objRsPaper.getInt("paper_no");
int no_of_attempts=0;
int attempt_id=0;
int marks=0;
java.util.Date appeared_on=null;
String back_color="";
String attempt_message="";
String paper_name=objRsPaper.getString("paper_name");
no_of_attempts=objRs.getInt("paper" + paper_no + "_no_of_attempts");
int paper_id=objRsPaper.getInt("paper_id");
String dbase=objRsPaper.getString("dbase");
int is_paper_completed=objRs.getInt("is_paper" + paper_no + "_completed");
if(paper_no==1)
{
total_marks=objRs.getInt("total_marks");
}
if(is_paper_completed==1)
{
back_color="bgcolor=#ffffcc";
}
else
{
back_color="";
}
if(is_paper_completed==1)
{
attempt_message="Successfully Completed ";
}
else
{
if(is_previous_paper_completed==0)
{
attempt_message="Not yet Eligible as you have not completed previous modules";
}
else
{
switch(no_of_attempts)
{
case 0:
attempt_id=1;
attempt_message="Not completed, You have a total of 3 attempts";
break;
case 1:
attempt_id=2;
attempt_message="Not completed,1 attempt exhausted ,you have 2 more attempts.";
break;
case 2:
attempt_id=3;
attempt_message="Not completed,2 attempts exhausted,you have 1 more attempt.";
break;
case 3:
attempt_message="All the attempts are exhausted and so you cannot complete the e ";
break;
default:
attempt_message="Not completed, and you are eligible for the exam ";
} } } %>
<tr>
<td colspan="3"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Module.<%=paper_no%> : <%=paper_name%> </font></strong>
</td> </tr>
<tr>
<td> </td><td colspan="2"><font color="#FFFF00" size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=attempt_message%></font></td>
</tr>
<%if(no_of_attempts>0)
{%>
<tr>
<td width="7%" class="infoLabel" > </td>
<td width="31%" class="infoLabel">Marks obtained :</td>
<%
marks=(objRs.getInt("paper" + paper_no + "_marks")*100)/total_marks;
%>
<td width="62%" class="infoValue"><%=marks%>%</td>
</tr>
<% appeared_on=objRs.getDate("paper" + paper_no + "_appeared_on");
String appeared_on_str=appeared_on.getDate() + "-" + (appeared_on.getMonth()+1) + "-" + (appeared_on.getYear()+1900);
%>
<tr>
<td> </td>
<td class="infoLabel">Appeared On :</td>
<td class="infoValue"><%=appeared_on_str%></td>
</tr>
<tr>
<td> </td>
<td class="infoLabel">No. of Attempts :</td>
<td class="infoValue"><%=no_of_attempts%></td>
</tr>
<%}%>
<tr>
<td colspan="3"><hr noshade color="#FFFFCC"></td>
</tr>
<% is_previous_paper_completed=is_paper_completed;} %>
<tr>
<td class="infoLabel" colspan="3">Pass precentage :50%</td>
</tr>
<% }
else
{ out.print("NIL");
}
%>
</table> <td></tr>
<% }
catch(Exception e)
{ out.print("error occured in while of paper : " + e);
}
%>
</table>
</body>
</html>
8.2 Back End
------------------------------------DBConnection.class---------------------------------------------
package INCLUDES;
import java.io.Serializable;
import java.sql.*;
import java.io.*;
public class DBConnection
{
String strStatement="";
ResultSet rs=null;
Connection conn=null;
public void setStatement(String statement)
{ this.strStatement=statement; }
public ResultSet result()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn=DriverManager.getConnection
("jdbc:odbc:ELEARNING_DATASOURCE","","");
Statement stat=conn.createStatement();
rs=stat.executeQuery(strStatement);
}
catch(Exception e)
{ e.printStackTrace();
}
return rs;
}
public ResultSet resultUpdate()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn=DriverManager.getConnection
("jdbc:odbc:ELEARNING_DATASOURCE","","");
Statement stat=conn.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stat.executeQuery(strStatement);
}
catch(Exception e)
{ e.printStackTrace();
}
return rs;
}
public int insert()
{
int count=0;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn=DriverManager.getConnection
("jdbc:odbc:ELEARNING_DATASOURCE","","");
Statement stat=conn.createStatement();
count=stat.executeUpdate(strStatement);
}
catch(Exception e)
{ e.printStackTrace();
}
return count;
}
public void closeConn()
{
try
{ conn.close();
}
catch(Exception e)
{ e.printStackTrace();
}
}
}
------------------------------------------signup_insert.jsp---------------------------------------
<%@ page import="INCLUDES.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<%
String user_name=request.getParameter("user_name");
ResultSet objRs=null;
String statement="";
try
{
statement="select * from x_master_elearning_user where user_name='" +
user_name + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.resultUpdate();
if(objRs.next())
{
response.sendRedirect("signup.jsp?result=User name already exists");
}
else
{
objRs.updateString("user_name",user_name);
objRs.updateString("pass_word",request.getParameter("pass_word"));
objRs.updateString("first_name",request.getParameter("trainee_name"));
objRs.updateString("designation",request.getParameter("designation"));
objRs.updateString("email",request.getParameter("email"));
objRs.updateInt("is_validated",0);
objRs.updateString("validation_code","xxxx");
objRs.updateString("city",request.getParameter("city"));
objRs.updateString("country",request.getParameter("country"));
objRs.insertRow();
response.sendRedirect("course_list_index2.jsp?result=
Succesfully regsitered.Please, Login to access other features.");
}
}
catch(Exception e)
{ out.print("error occured " + e);
}
%>
---------------------------------------user_login_verification.jsp------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<%
String user_name=request.getParameter("user_name");
session.setAttribute("user_name",user_name);
String pass_word=request.getParameter("pass_word");
String statement="SELECT * from x_master_elearning_user where user_name='" + user_name + "'";
try{
DB.setStatement(statement);
ResultSet rs=(ResultSet)DB.result();
if(rs.next()){
if(pass_word.equals(rs.getString("pass_word"))){
response.sendRedirect("course_list1_model2.jsp");
}
else{
response.sendRedirect("course_list_index2.jsp?
result=Incorrect Username/Password");
}
}
else{
response.sendRedirect("course_list_index2.jsp?
result=Incorrect Username/Password");
}
}
catch(Exception ex){
ex.printStackTrace();
}
%>
----------------------------------------profile_update.jsp----------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<%
String user_name=(String)session.getAttribute("user_name");
if(user_name==null)
{
response.redirect("course_list_index2.jsp?result=Session timed out.Please Login again.");
}
ResultSet objRs=null;
String statement="";
try
{
statement="select * from x_master_elearning_user where user_name='" + user_name + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.resultUpdate();
if(objRs.next())
{
objRs.updateString("first_name",request.getParameter("trainee_name"));
objRs.updateString("designation",request.getParameter("designation"));
objRs.updateString("email",request.getParameter("email"));
objRs.updateString("city",request.getParameter("city"));
objRs.updateString("country",request.getParameter("country"));
objRs.updateRow();
response.sendRedirect("view_profile.jsp?result=Succesfully updated profile.");
}
else
{
response.sendRedirect("view_profile.jsp?result=Sorry.You Profile could not be updated .");
}
}
catch(Exception e)
{
out.print("error occured " + e);
}
%>
---------------------------------------------password_update.jsp--------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<%
String user_name=(String)session.getAttribute("user_name");
String old_pass=request.getParameter("old_pass");
String new_pass=request.getParameter("new_pass");
ResultSet objRs=null;
String statement="";
try
{
statement="select * from x_master_elearning_user where user_name='" + user_name + "' and pass_word='" + old_pass + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.resultUpdate();
if(objRs.next())
{
objRs.updateString("pass_word",new_pass);
objRs.updateRow();
response.sendRedirect("course_list_index2.jsp?result=Password Changed Successfully.Please Login Again.");
}
else
{
response.sendRedirect("change_password.jsp?result=Incorrect Password.Try Again!");
}
}
catch(Exception e)
{
out.print("error occured " + e);
}
%>
--------------------------------------------enroll.jsp--------------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<%
int course_id=Integer.parseInt(request.getParameter("course_id"));
int no_of_papers=0;
String statement="";
try
{
statement="select no_of_papers from x_masterListOfCourses where course_id=" + course_id;
DB1.setStatement(statement);
ResultSet objRs=(ResultSet)DB1.result();
if(objRs.next())
{
no_of_papers=objRs.getInt("no_of_papers");
}
}
catch(Exception e)
{
out.print("error occured 11:" + e);
}
try
{
String user_name=(String)session.getAttribute("user_name");
java.util.Date now=new java.util.Date();
java.sql.Date date=new java.sql.Date(now.getYear(),now.getMonth(),now.getDate());
String trainee_id="OL_" + course_id + "_" + user_name;
statement="select * from x_master_trainee_detail_online";
DB.setStatement(statement);
ResultSet objRsInsert=(ResultSet)DB.resultUpdate();
objRsInsert.next();
objRsInsert.updateString("trainee_id",trainee_id);
session.setAttribute("trainee_id",trainee_id);
objRsInsert.updateString("user_name",user_name);
objRsInsert.updateInt("is_registered",1);
objRsInsert.updateInt("is_paper1_tutorial_viewed",0);
objRsInsert.updateInt("is_paper2_tutorial_viewed",0);
objRsInsert.updateInt("is_paper3_tutorial_viewed",0);
objRsInsert.updateInt("is_paper4_tutorial_viewed",0);
objRsInsert.updateInt("is_paper5_tutorial_viewed",0);
objRsInsert.updateInt("is_attended_exam",0);
objRsInsert.updateInt("course_id",course_id);
objRsInsert.updateInt("paper1_no_of_attempts",0);
objRsInsert.updateInt("paper2_no_of_attempts",0);
objRsInsert.updateInt("paper3_no_of_attempts",0);
objRsInsert.updateInt("paper4_no_of_attempts",0);
objRsInsert.updateInt("paper5_no_of_attempts",0);
objRsInsert.updateInt("is_paper1_completed",0);
objRsInsert.updateInt("is_paper2_completed",0);
objRsInsert.updateInt("is_paper3_completed",0);
objRsInsert.updateInt("is_paper4_completed",0);
objRsInsert.updateInt("is_paper5_completed",0);
objRsInsert.updateInt("paper1_marks",0);
objRsInsert.updateInt("paper2_marks",0);
objRsInsert.updateInt("paper3_marks",0);
objRsInsert.updateInt("paper4_marks",0);
objRsInsert.updateInt("paper5_marks",0);
objRsInsert.updateDate("doe",date);
objRsInsert.updateInt("no_of_papers",no_of_papers);
objRsInsert.insertRow();
response.sendRedirect("course_step.jsp?result=Enrolled successfully.&course_id=" + course_id);
}
catch(Exception e)
{
out.print("error occured : " + e);
}
%>
----------------------------------------update_tutorial_viewed.jsp---------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<%
int course_id=0;
String statement="";
ResultSet objRs=null;
int paper_id=Integer.parseInt(request.getParameter("paper_id"));
int paper_no=Integer.parseInt(request.getParameter("paper_no"));
String file_name=request.getParameter("doc");
String user_name=(String)session.getAttribute("user_name");
String col1="paper_id" + paper_no;
String col2="is_paper" + paper_no + "_tutorial_viewed";
if(request.getParameter("course_id")!=null)
{
course_id=Integer.parseInt(request.getParameter("course_id"));
}
try
{
statement="select * from x_master_trainee_detail_online where course_id=" + course_id + " and user_name='" + user_name + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.resultUpdate();
objRs.next();
objRs.updateInt(col1, paper_id);
objRs.updateInt(col2,1);
objRs.updateRow();
response.sendRedirect(file_name);
}
catch(Exception e)
{
out.println("error occured 11 : " + e);
}
%>
------------------------------------CourseToSession_final.jsp-----------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<jsp:useBean id="DB2" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB2" property="*"/>
<jsp:useBean id="DB3" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB3" property="*"/>
<jsp:useBean id="DB4" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB4" property="*"/>
<%
String statement=null;
ResultSet objRs=null;
ResultSet oRsQn=null;
ResultSet oRsTotQns=null;
int number_of_questions=3;
int course_id=0;
int paper_no=0,paper_id=0,attempt_id=0;
String trainee_id=null;
int total_qns=0;
if(request.getParameter("course_id")!=null)
{
course_id=Integer.parseInt(request.getParameter("course_id"));
session.setAttribute("course_id",""+course_id);
trainee_id=(String)session.getAttribute("trainee_id");
paper_no=Integer.parseInt(request.getParameter("paper_no"));
session.setAttribute("paper_no",""+paper_no);
attempt_id=Integer.parseInt(request.getParameter("attempt_id"));
session.setAttribute("attempt_id",""+attempt_id);
paper_id=Integer.parseInt(request.getParameter("paper_id"));
session.setAttribute("paper_id",""+paper_id);
}
try
{
statement="select * from x_master_trainee_detail_online where course_id=" + course_id + " and trainee_id='" + trainee_id + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.result();
if(objRs.next())
{
String viewed_field="is_paper" + paper_no + "_tutorial_viewed";
out.print(viewed_field);
if(objRs.getInt(viewed_field)==0)
{
response.sendRedirect("course_tutorial1.jsp?course_id=" + course_id + "&result=You must first read the tutorials.You may <a href=view_document.jsp?course_id=" + course_id + ">click here</a>.");
}
}
}
catch(Exception e)
{
out.print("errror occured 1 : " + e);
}
number_of_questions=Integer.parseInt((String)session.getAttribute("number_of_questions"));
try
{
statement="select count(*) as total_qns from x_masterListOfQuestions where paper_id=" + paper_id;
DB2.setStatement(statement);
oRsTotQns=(ResultSet)DB2.result();
if(oRsTotQns.next())
{
total_qns=oRsTotQns.getInt("total_qns");
}
}
catch(Exception e)
{
out.print("errror occured 3 : " + e);
}
if(total_qns < number_of_questions)
{
response.sendRedirect("course_tutorial1.jsp?result=This Course contains less than " + number_of_questions + " questions. Hence Test is not permitted. Please select some other course");
}
int last_qn=total_qns-1;
int i=0;
ResultSet oRsID=null;
int qn_array[]=new int[total_qns];
try
{
statement="select question_id from x_masterListOfQuestions where paper_id=" + paper_id;
DB3.setStatement(statement);
oRsID=(ResultSet)DB3.result();
while(oRsID.next())
{
qn_array[i]=oRsID.getInt("question_id");
i=i+1;
}
}
catch(Exception e)
{
out.print("errror occured 4 : " + e);
}
/*randomize
for j=last_qn to number_of_questions step -1
random_no=int(rnd* last_qn)
qn_array(random_no)=qn_array(last_qn)
redim preserve qn_array(last_qn)
last_qn=last_qn-1
next
redim preserve qn_array(ubound(qn_array)-1)
for i=0 to ubound(qn_array)
for j=0 to (ubound(qn_array)-i-1)
if qn_array(j)>qn_array(j+1) then
temp=qn_array(j)
qn_array(j)=qn_array(j+1)
qn_array(j+1)=temp
end if
next
next
response.write("sorted list")
*/
try
{
String qn_qns_str="";
String qn_qns_val="";
String qn_ans_str="";
String qn_ans_val="";
for(int k=0;k<i;k++)
{
qn_qns_str=qn_qns_str + ",qn" + (k+1);
qn_qns_val=qn_qns_val + "," + qn_array[k];
qn_ans_str=qn_ans_str + ",ans" + (k+1);
qn_ans_val=qn_ans_val + ",0";
}
statement="insert into results(course_id,trainee_id,paper_id,attempt_id" + qn_qns_str + qn_ans_str + ") values(" + course_id + ",'" + trainee_id + "'," + paper_id + "," + attempt_id + qn_qns_val + qn_ans_val + ")";
DB4.setStatement(statement);
int count=(int)DB4.insert();
if(count>0)
{
out.println("successfully");
}
else
{
out.print("failure");
}
}
catch(Exception e)
{
out.print("error occured 55 : " + e);
}
try
{
response.sendRedirect("exam_question.jsp");
}
catch(Exception e)
{
out.println("error occured :" + e);
}
%>
----------------------------------------exam_question_insert.jsp-------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<%
String trainee_id=(String)session.getAttribute("trainee_id");
int number_of_questions=Integer.parseInt((String)session.getAttribute("number_of_questions"));
int course_id=Integer.parseInt((String)session.getAttribute("course_id"));
int paper_id=Integer.parseInt((String)session.getAttribute("paper_id"));
int attempt_id=Integer.parseInt((String)session.getAttribute("attempt_id"));
int i=Integer.parseInt(request.getParameter("question_no"));
String statement=null;
ResultSet objRs=null;
try
{
statement="select * from results where attempt_id=" + attempt_id + " and course_id=" + course_id + " and paper_id=" + paper_id + " and trainee_id='" + trainee_id + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.resultUpdate();
objRs.next();
if(request.getParameter("choice" + i)!=null)
{
objRs.updateInt("ans" + i,Integer.parseInt(request.getParameter("choice" + i)));
}
else
{
objRs.updateInt("ans" + i,0);
}
objRs.updateRow();
}
catch(Exception e)
{
out.print("error occured 11 : " + e);
}
if(request.getParameter("submit").equals("Review"))
{
response.sendRedirect("question_review.jsp");
}
else
{
if(i<number_of_questions)
{
response.sendRedirect("exam_question.jsp?question_no=" + i);
}
else
{
response.sendRedirect("result_calculation.jsp");
}
}
%>
-------------------------------review_insert.jsp-------------------------------------------
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<%
String trainee_id=(String)session.getAttribute("trainee_id");
int number_of_questions=Integer.parseInt((String)session.getAttribute("number_of_questions"));
int course_id=Integer.parseInt((String)session.getAttribute("course_id"));
int paper_id=Integer.parseInt((String)session.getAttribute("paper_id"));
int attempt_id=Integer.parseInt((String)session.getAttribute("attempt_id"));
int i=1;
String statement=null;
ResultSet objRs=null;
try
{
statement="select * from results where attempt_id=" + attempt_id + " and course_id=" + course_id + " and paper_id=" + paper_id + " and trainee_id='" + trainee_id + "'";
DB.setStatement(statement);
objRs=(ResultSet)DB.resultUpdate();
objRs.next();
while(i<=number_of_questions)
{
if(request.getParameter("choice" + i)!=null)
{
objRs.updateInt("ans" + i,Integer.parseInt(request.getParameter("choice" + i)));
}
else
{
objRs.updateInt("ans" + i,0);
}
i=i+1;
}
objRs.updateRow();
}
catch(Exception e)
{
out.print("error occured 11 : " + e);
}
response.sendRedirect("result_calculation.jsp");
%>
|