Current File : /home/inlingua/www/sensoriumpsychologists.com/diagnostics/screening/screening_session.php
<?php 
ob_start();
session_start();
//require_once("../franchise_between/check_franchise.php");
 require_once("../franchise_between/user_details_msg_setup.php");
require_once("../franchise_between/validate_functions.php");
require_once("../franchise_between/student_funcs.php");
 require_once("../franchise_between/screening_funcs.php");

$ref_no=$_SESSION['ref_no'];
$validate_obj=new validate_functions();
$validate_obj->check_isset_empty($ref_no,"ref_no");
$validate_obj->check_is_num($ref_no,"ref_no");

$student_obj=new student_funcs();
$student_obj->set_value("franchise_id",$session_id);
$student_obj->view_child($ref_no);
$child_name=$student_obj->get_value("child_name");
$email=$student_obj->get_value("email");
$school_name=$student_obj->get_value("school_name");
$registration_no=$student_obj->get_value("registration_no");
$theme_link=$student_obj->get_value("theme_class");
$theme_font=$student_obj->get_value("theme_font");

$screening_id=$_SESSION['screening_id'];
$validate_obj=new validate_functions();
$validate_obj->check_isset_empty($screening_id,"screening_id");
$validate_obj->check_is_num($screening_id,"screening_id");

$reply=$student_obj->show_available_screening($ref_no);
if($reply=="no")
{
	
	unset($_SESSION['screening_started']);
		unset($_SESSION['ref_no']);
		unset($_SESSION['screening_id']);
		unset($_SESSION['section_count']);
		unset($_SESSION['ongoing_section_no']);
		unset($_SESSION['start_time']);
		header ("location:view_questionnaire_report.php?ref_no=".$ref_no."&screening_id=".$screening_id);
		
		
	echo("<span style=\"color:#F00;\">No screening available...</span>");
	exit();
}

$screening_obj=new screening_funcs();
$screening_obj->get_screening_name_and_duration($screening_id);
$questionnaire_name=$screening_obj->get_value("questionnaire_name");
$questionnaire_duration=$screening_obj->get_value("questionnaire_duration");
$duration_in_sec=$questionnaire_duration*60;
if(isset($_SESSION['start_time']))
{
	$time_left=time()-$_SESSION['start_time'];
	$time_left=$duration_in_sec-$time_left;
	$duration_in_sec=$time_left;
}
else
{
	echo("Error : Invalid request...");
	exit();
}

if(isset($_SESSION['ongoing_section_no']))
{
	$ongoing_section_no=$_SESSION['ongoing_section_no'];
}
else
{
	$next_section_id=$screening_obj->get_next_screening_section("none",$screening_id);
	if($next_section_id==="error")
	{
		echo("Error : Couldn't load new section...Please contact your administrator..1");//add cancel and reset buttons here
		exit();
	}
	$_SESSION['ongoing_section_no']=$next_section_id;
	$ongoing_section_no=$next_section_id;
	$_SESSION['section_count']=1;
}

if(!empty($_POST)&&(isset($_POST['cancel_exam']))&&($_POST['cancel_exam']=="yes"))
{
	header ("location:cancel_exam.php");
}
else if(isset($_POST['timeout_submit'])&&($_POST['timeout_submit'])=="yes")
{
	$questions_array=array();
	$answers_array=array();
	$total_questions=$_POST['total_questions'];
	for($i=1;$i<=$total_questions;$i++)
	{
		$to_check="question_".$i;
		$ques_id=$_POST[$to_check];
		$ans_name="ans_".$ques_id;
		$answer=$_POST[$ans_name];
		$questions_array[]=$ques_id;
		$answers_array[]=$answer;
	}
	$screening_obj->set_value("questions_array",$questions_array);
	$screening_obj->set_value("answers_array",$answers_array);
	$screening_obj->set_value("created_by",$session_id);
	$screening_obj->set_value("created_ip",$ip);
	$screening_obj->set_value("created_browser",$browser);
	$screening_obj->proceed_with_answers_timeout($ref_no,$session_id,$screening_id,$ongoing_section_no);
}
else if(!empty($_POST))
{
	
	//echo '<pre>'; print_r($_POST); // exit;
	$questions_array=array();
	$answers_array=array();
	$total_questions=$_POST['total_questions'];
	for($i=1;$i<=$total_questions;$i++)
	{
		$to_check="question_".$i;
		$ques_id=$_POST[$to_check];
		$ans_name="ans_".$ques_id;
		$answer=$_POST[$ans_name];
		$questions_array[]=$ques_id;
		$answers_array[]=$answer;
	}
	$screening_obj->set_value("questions_array",$questions_array);
	$screening_obj->set_value("answers_array",$answers_array);
	$screening_obj->set_value("created_by",$session_id);
	$screening_obj->set_value("created_ip",$ip);
	$screening_obj->set_value("created_browser",$browser);
	$next_section_id=$screening_obj->proceed_with_answers($ref_no,$session_id,$screening_id,$ongoing_section_no);
	if($next_section_id=="error")
	{
		echo("Error : Couldn't load new section...Please contact your administrator 2");//add cancel and reset buttons here
		exit();
	}
	$_SESSION['ongoing_section_no']=$next_section_id;
	$ongoing_section_no=$next_section_id;
	$_SESSION['section_count']++;
	header ("location:screening_session.php");
}
include("common/page_head.php");

?>

		<script type="text/javascript" src="countdown/jquery.countdown.js"></script>
		<script type="text/javascript">
		$(function () {
			$('#defaultCountdown').countdown({
				until: +<?php echo($duration_in_sec);?>,
				format: 'YDHMS',
				layout: '<div id="timer">'+
							'<div id="vals">'+
								'<div id="h" class="numbs">{hnn}</div>'+
								'<div id="m" class="numbs">{mnn}</div>'+
								'<div id="s" class="numbs">{snn}</div>'+
							'</div>'+
							'<div id="labels">'+
								'<div id="hl" class="labs">hours</div>'+
								'<div id="ml" class="labs">mins</div>'+
								'<div id="sl" class="labs">secs</div>'+
							'</div>'+
							'<div id="timer_over"></div>'+
						'</div>'
				});
		});
		</script>
		<link rel="stylesheet" type="text/css" href="countdown/style_countdown.css" media="all" />
        

<?php //include("common/header_var.php");

//$top_children=$top_val;
include("../../include/header_2.php"); ?>
<div class="site-breadcrumb">
<div class="container">
<a href="../../index.php"><i class="fa fa-home"></i> Home</a> <i class="fa fa-angle-right"></i>
<span>Screening Start</span>
</div>
</div> 

<section class="about-section spad pt-0">
<div class="container">
 <div class="section-title">
<h3>Screening Start</h3>
<p></p>
</div>
<div class="row">
<div id="main_container">
  <div id="main">
    <table border="0" cellpadding="5px" cellspacing="0" style="width:100%;">
      <tr>
        <td>
          <table style="border:1px solid #000;" cellpadding="5px" cellspacing="0">
            <tr>
              <td><strong>Admission No :</strong> <?php echo($registration_no);?></td>
              <td>&nbsp;&nbsp;&nbsp;</td>
              <td><strong>Name :</strong> <?php echo($child_name);?></td>
              <td>&nbsp;&nbsp;&nbsp;</td>
              <td><strong>Screening :</strong> <?php echo($questionnaire_name);?></td>
            </tr>
          </table>
        </td>
<form name="cancel_form" method="post">
<input type="hidden" name="cancel_exam" id="cancel_exam" value="no" />
</form>
<form name="timeout_form" method="post">
<input type="hidden" name="timeout_submit" id="timeout_submit" value="no" />
</form>
        <td><a href="javascript:cancel_exam()"><div class="site-btn mb-40">Exit Exam & Give Later</div></a></td>
        <td align="right">
          <table cellpadding="5px" cellspacing="0">
            <tr>
              <td><div id="defaultCountdown"></div></td>
            </tr>
          </table>
        </td>
      </tr>
    </table><br>
    <form name="myform" method="post">
    <fieldset>
    <legend>SECTION <?php echo($_SESSION['section_count']);?></legend>
    <table border="0" class="tables_fieldset" style="width:100%;font-size:14px;" cellpadding="3px" cellspacing="0">
<?php
$screening_obj->get_question_details_section($ongoing_section_no);
$question_paragraph=$screening_obj->get_value("question_main");
?>
      <tr>
        <td colspan="3" style="font-weight:500;font-size:14px;">
		<?php
        echo($question_paragraph);
		?>
        </td>
      </tr>
<tr style="height:30px;">
  <td colspan="3"></td>
</tr>
<?php
$screening_obj->print_sub_questions($ongoing_section_no);
?>

<tr style="height:10px;">
  <td colspan="3"></td>
</tr>
      <tr>
        <td colspan="3">
          <a href="javascript:;" onclick="onclickshw();"><div class="site-btn mb-40">Next</div></a>
		  
        </td>
      </tr>
<tr style="height:10px;">
  <td colspan="3"></td>
</tr>
      <tr style="display:none;">
        <td colspan="3">
          <a href="javascript:submit_answers()"><div class="site-btn mb-40" style="color:#FFF;background-color:#060;">Submit & Proceed</div></a>
        </td>
      </tr>
    </table>
    </fieldset>
    </form>
  </div>
</div>
</div>
</section>
<div class="modal" id="modal">
		<div class="modal-dialog">
			<div class="modal-content">
<button type="button" class="close" data-dismiss="modal">&times;</button>
      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title"><?php
        echo($question_paragraph);
		?></h4>
        
      </div>

      <!-- Modal body -->
      <div class="modal-body">
       <div id="question">
	   
	   
	   </div>
	  
	  <input type="hidden" name="next_questions" id="next_questions" value="0">
	  
	  </div>

      <!-- Modal footer -->
      <div class="modal-footer">
        		<a href="javascript:next_ques();"><div class="site-btn">Next</div></a>

      </div>

    </div>
  </div>
</div>		
<style>
table{
	border: 0px;
width: 100%;
    margin: 0 0 0px;
    padding: 0;
    border-spacing: 0;	
}
table td{
border: 0px solid #EAE9E9;	
}
table tr{
border: 0px solid #EAE9E9;	
}

table td, table th {
    padding: 2px 4px;
    text-align: left;
}
/* The Modal (background) */
.modal-dialog {
    max-width: 1100px;
    margin: 0.25rem auto;
}
.modal-dialog h4 {
    font-size: 13px;
    font-weight: 300;
}
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  padding-top: 10px; /* Location of the box */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 10px;
  border: 1px solid #888;
  width: 100%;
}

/* The Close Button */
.close {
  color: #999;
    float: right;
    font-size: 24px;
    font-weight: bold;
    position: absolute;
    right: 15px;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}
.modal-title {
    margin-bottom: 0;
    line-height: 1.4;
}
</style>


<script src="//cdnjs.cloudflare.com/ajax/libs/materialize/0.95.1/js/materialize.min.js"></script>
			
<script>


function onclickshw()
{
	
	var to_check="";
	var ques_id="";
	var ans_name="";
	var response="";
	var span_id="";
	var not_ans="no";
	var total_questions=$("#total_questions").val();
	for(var i=1;i<=total_questions;i++)
	{
		to_check="#question_"+i;
		ques_id=$(to_check).val();
		ans_name="ans_"+ques_id;
		response=$("input:radio[name='"+ans_name+"']").is(":checked");
		if(response==false)
		{
			span_id="#error_span_"+ques_id;
			$(span_id).show();
			not_ans="yes";
		}
		else
		{
			span_id="#error_span_"+ques_id;
			$(span_id).hide();
		}
	}
	if(not_ans=="yes")
	{
		alert("Error : All questions are mandatory...!!!");
		return false;
	}
	else
	{
	modal.style.display = "block";
 var total= $("#total_questions").val();
 $("#next_questions").val(total);
var next=total;
	var dataString = 'next_questions=' + next;
$.ajax({
type: "POST",
url: "question-process.php",
data: dataString,
cache: false,
success: function(html) {
	
	 	
    if(html=='error')
	{
		
	document.myform.submit();	
	}else {	
	$('#question').html(html); 	
	}
	
	
}
});	
	}	
}

function songplay(ID){
	
      var text = $('#message'+ID).val();
      var msg = new SpeechSynthesisUtterance();
      var voices = window.speechSynthesis.getVoices();
      msg.voice = voices[$('#voices').val()];
      //msg.rate = $('#rate').val() / 10;
      //msg.pitch = $('#pitch').val();
      msg.text = text;

      msg.onend = function(e) {
        console.log('Finished in ' + event.elapsedTime + ' seconds.');
      };

      speechSynthesis.speak(msg);
    }
$('#speak2').click(function(){
      var text = $('#message2').val();
      var msg = new SpeechSynthesisUtterance();
      var voices = window.speechSynthesis.getVoices();
      msg.voice = voices[$('#voices').val()];
      //msg.rate = $('#rate').val() / 10;
      //msg.pitch = $('#pitch').val();
      msg.text = text;

      msg.onend = function(e) {
        console.log('Finished in ' + event.elapsedTime + ' seconds.');
      };

      speechSynthesis.speak(msg);
    });						

function next_ques()
{
	//e.preventDefault(); 
 var total= $("#next_questions").val();
 //$("#next_questions").val(total);
var next=total;
var to_check="";
	var ques_id="";
	var ans_name="";
	var response="";
	var span_id="";
	var not_ans="no";
	var totalquestions=$("#nextquestions").val();
	var count=$("#count").val();
	if(count==1)
	{
	var start=totalquestions;
	}else {
	var start=totalquestions - 1;	
	}
	//alert(totalquestions);
	for(var i=start;i<=totalquestions;i++)
	{
		to_check="#question_"+i;
		ques_id=$(to_check).val();
		ans_name="ans_"+ques_id;
		response=$("input:radio[name='"+ans_name+"']").is(":checked");
		
		
		if(response==false)
		{
			span_id="#error_span_"+ques_id;
			$(span_id).show();
			not_ans="yes";
		}
		else
		{
			span_id="#error_span_"+ques_id;
			$(span_id).hide();
		}
	}
	if(not_ans=="yes")
	{
		alert("Error : All questions are mandatory...!!!");
		return false;
	}
	else
	{


	//var dataString = $('#nextform').serialize();
$.ajax({
type: "POST",
url: "question-process.php",
data: $('#nextform').serialize(),
cache: false,
success: function(data) 
	{
		
	if(data=='error')
	{
		
	document.myform.submit();	
	}else {	
	$('#question').html(data); 	
	}
	
	}
});	
	}	
}


</script>

<span id="final_span" class="final"></span>
<span id="interim_span" class="interim"></span>
  <br><br><br><br>
<script>
function submit_answers()
{
	var to_check="";
	var ques_id="";
	var ans_name="";
	var response="";
	var span_id="";
	var not_ans="no";
	var total_questions=$("#total_questions").val();
	for(var i=1;i<=total_questions;i++)
	{
		to_check="#question_"+i;
		ques_id=$(to_check).val();
		ans_name="ans_"+ques_id;
		response=$("input:radio[name='"+ans_name+"']").is(":checked");
		if(response==false)
		{
			span_id="#error_span_"+ques_id;
			$(span_id).show();
			not_ans="yes";
		}
		else
		{
			span_id="#error_span_"+ques_id;
			$(span_id).hide();
		}
	}
	if(not_ans=="yes")
	{
		alert("Error : All questions are mandatory...!!!");
		return false;
	}
	else
	{
		document.myform.submit();
	}
}
function cancel_exam()
{
	var ans=confirm("Are you sure you want to cancel the exam ?");
	if(ans==true)
	{
		$("#cancel_exam").val("yes");
		document.cancel_form.submit();
	}
	else
	{
		return false;
	}
}
function submit_answers_automatically()
{
	$("#timeout_submit").val("yes");
	document.myform.submit();
}
</script>
<script type="text/javascript">
var final_transcript = '';
var recognizing = false;
 
if ('webkitSpeechRecognition' in window) {
 
  var recognition = new webkitSpeechRecognition();
 
  recognition.continuous = true;
  recognition.interimResults = true;
 
  recognition.onstart = function() {
    recognizing = true;
  };
 
  recognition.onerror = function(event) {
    console.log(event.error);
  };
 
  recognition.onend = function() {
    recognizing = false;
  };
  recognition.onresult = function(event) {
    var interim_transcript = '';
    for (var i = event.resultIndex; i < event.results.length; ++i) {
      if (event.results[i].isFinal) {
        final_transcript += event.results[i][0].transcript;
      } else {
        interim_transcript += event.results[i][0].transcript;
      }
    }
	
    final_transcript = capitalize(final_transcript);
    final_span.innerHTML = linebreak(final_transcript);
    interim_span.innerHTML = linebreak(interim_transcript);
    
  };
}
 
var two_line = /\n\n/g;
var one_line = /\n/g;
function linebreak(s) {
  return s.replace(two_line, '<p></p>').replace(one_line, '<br>');
}
 
function capitalize(s) {
  return s.replace(s.substr(0,1), function(m) { return m.toUpperCase(); });
}
 
function startDictation(event) {
  if (recognizing) {
    recognition.stop();
    return;
  }
  final_transcript = '';
  recognition.lang = 'en-IN';
  recognition.start();
  final_span.innerHTML = '';
  interim_span.innerHTML = '';
}
</script>
<script>
function play_sound(id_to_affect)
{
	var google_link="#google_link_"+id_to_affect;
	var embed_link="#embed_"+id_to_affect;
	var google_val=$(google_link).val();
	var embed_div="#embed_div_"+id_to_affect;
	var text="<embed src=\""+google_val+"\" id=\"embed_"+id_to_affect+"\" autostart=\"true\" width=\"2\" height=\"0\"></embed>";
	$(embed_div).html(text);
}
function play_sound_2(sound)
{
	/*var msg = new SpeechSynthesisUtterance(sound);
	window.speechSynthesis.speak(msg);*/
	var msg = new SpeechSynthesisUtterance();
	var voices = window.speechSynthesis.getVoices();
	msg.voice = voices[1]; // Note: some voices don't support altering params
	msg.voiceURI = 'native';
	//msg.volume = 1; // 0 to 1
	//msg.rate = 0.1; // 0.1 to 10
	msg.pitch = 0.1; //0 to 2
	msg.text = sound;
	msg.lang = 'en-IN';
	
	speechSynthesis.speak(msg);
	
}
speechSynthesis.getVoices().forEach(function(voice) {
  console.log(voice.name, voice.default ? '(default)' :'');
});
</script>
<?php include("../../include/footer_2.php");?>