<?php
###########################
# QMOTIONS OPTIM
###########################
function getQMotion($catId)
{
	return db_fetch_assoc(main_db_query("SELECT * FROM QMotions WHERE Category = '".$catId."'"));
}

function getQMotionTypesAnswers($motionId)
{
	$rows = main_db_query("SELECT * FROM QMotionTypesAnswers WHERE MotionId='".$motionId."' ORDER BY Id");
	
	while($row = db_fetch_assoc($rows))
		$optim_qanswers_tab[$row['Id']] = $row;

	return $optim_qanswers_tab;
}

function setReponse($reponseId)
{
	main_db_query("UPDATE QMotionTypesAnswers SET Extra=Extra+1 WHERE Id='".$reponseId."'");
}


function getQRightMotionTypesAnswers($motionId, $rep)
{
	global $optim_qanswers_tab;
	
	return $optim_qanswers_tab[$motionId][$rep];
}

###########################
# QCATEGORIES OPTIM
###########################

function getQActualCategory()
{
	$date = date("Y-m-d H:i:s", my_local_time());
	$row = db_fetch_assoc(main_db_query("SELECT CategoryId FROM QCategories WHERE ShowTime < '".$date."' AND EndTime > '".$date."'"));
	
	return 	$row['CategoryId'];
}

?>