<?php 
include_once("_dirinfo.php");

$sessionHandling = true;

include_once("../init.php");


// *************************************************************
$project = "MAB_Integral_2013";
$questions = array("q5","q6","q8","q9","n11","n12","n13");
// *************************************************************
// 

foreach ($questions AS $item_quest) {
	$sql = "SELECT * FROM Warpit_Webcati_base.`".$project."___EngineLog` WHERE `q_name` LIKE '".$item_quest."'";
	//echo "$sql<br>";
	$res = $db->SQLexecute($sql);
	
	while ($zad =  $db->fetchAssoc($res)) {
		$text = "";
		
		$obj = json_decode($zad['eventLogger'],1);
		foreach ($obj as $key=>$val) {
			$chkVar = "answers[".$item_quest."_1]";
			//echo "key: $key <br>=>val Name: ".$val['objName']." = val Value: ".$val['objValue']."<br>$chkVar<br><br>";
			if ($val['objName'] == $chkVar) {
				$text = $val['objValue'];
			}
		}

		$sql = "UPDATE Warpit_Webcati_base.`".$project."_structure` SET ".$item_quest."_1 = '$text' WHERE id = ".$zad['id_structure'];
		$db->SQLexecute($sql);
		echo $sql."<br>";
	}
}

?>