Javascript : Online Exam

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Javascript : Online Exam as PDF for free.

More details

  • Words: 451
  • Pages: 4
Online Exam

Online Exam simulator



Marks: | Time left:0 sec. | Time Saved : 0 sec.


Question:<span id="statement">
<span id="op1" >
<span id="op2" >
<span id="op3" >
<span id="op4" >





Answered Questions Status


<script> var Radix={}; Radix.Question=function(statement,op1,op2,op3,op4,answer,marks){ this.statement=statement; this.op=[]; this.op[1]= op1; this.op[2]= op2; this.op[3]= op3; this.op[4]= op4; this.answer=answer; this.marks=marks; } /////////////////////////////////////DATA Access Layer Radix.QuestionDAL = function() { this.questionL = []; this.questionL.push(new Radix.Question("What is JavaScript?","Its a scripting language","Not related to Java","Both","None","3","10")); this.questionL.push(new Radix.Question("Java is the product of?","Moon","Sun","Star","Microsoft","2","15")); this.questionL.push(new Radix.Question("What is the maximum heap swap supported on a 32bit JavaVirtualMachine?","1024MB","512KB","2048MB","Unlimited","3","15")); this.questionL.push(new Radix.Question("Who is Richard Stallman ?
","Employe of Microsoft","Actor","Father of GNU Public lisence","A Saint","3","20")); this.questionL.push(new Radix.Question("Who is Mark Shuttleworth ?
","Founder of fedora","Founder of Ubuntu","Founder of Debion","None of above","2","20")); this.questionL.push(new Radix.Question("Identify the guys in below picture ?
","Employes of Microsoft","Founder of Linux","Founders of Google","None of above","3","20")); } Radix.QuestionDAL.prototype={ getquestion : function(a) {return (this.questionL[a]);}, getlength : function() {return this.questionL.length;} }; ////////////////////////////////////////Presentation Logic layer Radix.QuestionPLL=function(){

this.logic=new Radix.QuestionBLL(); this.current_Q = new Radix.Question("-","-","-","-","-","-","-","-"); this.score = 0; this.overall=0; } Radix.QuestionPLL.prototype={ start : function() { this.update(); this.logic.startexam(); }, get_answer : function(){ this.get_score(); this.logic.nextQ(); }, get_score : function(){ Radix.presentation_obj.updatetimer(""+Number(timer.timeout-timer.counter)+"",""+timer.timesaved+""); this.print("
Q: "+this.current_Q.statement+"
Ans: "+this.current_Q.op[this.current_Q.answer]+"."); this.logic.calc_score(document.getElementsByName("choice"),this.current_Q); document.getElementById('s1').disabled=true; }, update : function(){ var currentQ = new Radix.Question("-","-","-","-","-","-","-","-"); currentQ = this.logic.getq(); this.current_Q = currentQ; document.getElementById("statement").innerHTML=currentQ.statement; document.getElementById("op1").innerHTML=currentQ.op[1]; document.getElementById("op2").innerHTML=currentQ.op[2]; document.getElementById("op3").innerHTML=currentQ.op[3]; document.getElementById("op4").innerHTML=currentQ.op[4]; document.getElementById("marks").innerHTML=""+currentQ.marks+""; document.getElementById('s1').disabled=false; }, updatetimer : function(a,b) { document.getElementById('timer').innerHTML = a; document.getElementById('savedtime').innerHTML = b; }, finish_exam: function(a){document.getElementById("exam_status").innerHTML = a ;}, print :function(a){document.getElementById('status').innerHTML = a+document.getElementById('status').innerHTML;} }; //////////////////////////////////////Business Logic Layer Radix.QuestionBLL = function(){ this.dal = new Radix.QuestionDAL(); this.qno = 0; this.tref=null; } Radix.Timer = function(){}; Radix.QuestionBLL.prototype={

startexam : function(){ timer.starttimer(); }, getq : function() { if(this.dal.getlength() > this.qno) return this.dal.getquestion(this.qno++); else return null; }, stopexam : function() { timer.stoptimer(); }, nextQ : function() { timer.stoptimer(); Radix.presentation_obj.update(); timer.starttimer(); }, calc_score : function(ch,ques){ timer.timesaved = timer.timesaved + (timer.timeout-timer.counter); Radix.presentation_obj.overall = Radix.presentation_obj.overall+Number(ques.marks); for(var i=0;i

Exam completed !
Total Score is "+Radix.presentation_obj.score+" / "+Radix.presentation_obj.overall+". Time saved "+timer.timesaved+" sec.

"); this.stopexam(); } } }; //////////////////////////////// TIMER CLASS Radix.Timer=function(){ this.tref=null; this.counter=0; this.timesaved=0; this.timeout = 10; } Radix.Timer.prototype={ process: function() { if(timer.counter == timer.timeout) { Radix.presentation_obj.print("
Timed out. Answer next question"); Radix.presentation_obj.get_score(); Radix.presentation_obj.update(); timer.counter=0;

} Radix.presentation_obj.updatetimer(""+Number(timer.timeout-timer.counter)+"",""+timer.timesaved+""); timer.counter++; }, starttimer:function(){timer.tref=setInterval("timer.process()",1000);}, stoptimer:function() { this.counter=0; clearInterval(this.tref); } }; var timer = new Radix.Timer(); ////////////////////////////////////////OBJECT OF PLL alert("Press OK to start the exam. You get "+timer.timeout+" seconds per questions."); Radix.presentation_obj=new Radix.QuestionPLL(); Radix.presentation_obj.start();

Related Documents

Online C-sharp Exam
June 2020 5
Javascript
November 2019 51
Javascript
June 2020 24
Javascript
November 2019 43
Javascript
June 2020 24