">
$output ="
".(($dir =="0")?"تسجيل الخروج "
:"L o g o u t")." ";
$user_id=intval($_SESSION[user_id]);
$qu=mysql_query("select * from `tduser` where `user_id`='$user_id' ");
$ru=mysql_fetch_array($qu);
$step=$ru[step_id];
$class=$ru[class_id];
$part=$ru[part];
function strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}
function selfURL() {
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
switch ($_GET['do'])
{
case "class":
classs();
break;
case "topics":
topics();
break;
case "test":
test();
break;
case "qfailed":
qfailed();
break;
case "logout":
logout();
break;
case "exam":
exam();
break;
case "back":
back();
break;
case "logout":
logout();
break;
default:
classs();
break;
}
function classs()
{
global $dir , $output ,$step , $class , $part ;
if($step =="13"){
$part=1;
}
$output .="";
$qtopic=@mysql_query("SELECT `td_topics`.`topics_id`,`td_topics`.`topics_name`,
`td_topics`.`step_id`,`td_step`.`step_name`,`td_topics`.`class_id`,
`td_class`.`class_name`
FROM `td_topics`
Inner Join `td_class` ON `td_topics`.`class_id` = `td_class`.`class_id`
Inner Join `td_step` ON `td_topics`.`step_id` = `td_step`.`step_id`
where `td_topics`.`class_id` ='$class' AND `part`='$part' AND `active` ='1' ORDER BY `arrange`,`topics_id` ");
$num=@mysql_num_rows($qtopic);
if($num > 0){
$i=1;
while($rtopic=@mysql_fetch_array($qtopic))
{
$info="{$rtopic[step_name]} \t >> \t{$rtopic[class_name]}
";
$topics.="";
$q ="SELECT `td_test`.`test_id`,`td_test`.`topics_id`,`td_test`.`test_name`,
`td_test`.`active`,`td_test`.`test_success`
FROM `td_test` where (`td_test`.`topics_id`='$rtopic[topics_id]') AND ( `active` ='1' ) ORDER BY `td_test`.`test_id` ";
$q=@mysql_query($q)or die(mysql_error());
while($r=@mysql_fetch_array($q)){
$topics .=" \t \t \t \t \t \t \t \t".(($dir =="0")?"الإمـتـحان \t ":"Exam \t")." \t: \t
{$r[test_name]} \t \t ";
$qu=@mysql_query("SELECT `history`.`h_id`,`history`.`user_id`,
`history`.`test_id`,`history`.`exam_degree`,`td_test`.`test_success`
FROM `history`
Inner Join `td_test` ON `history`.`test_id` = `td_test`.`test_id` where `user_id`='".$_SESSION[user_id]."' AND ( `history`.`test_id`='".$r[test_id]."')");
$ru=@mysql_fetch_array($qu);
if(($ru[test_id]==$r[test_id])&&($ru[exam_degree] < $ru[test_success]))
{
$topics .="
";
}elseif(($ru[test_id]==$r[test_id])&&($ru[exam_degree] >= $ru[test_success]))
{
$topics .="
";
}
$topics .="
";
}
$i++;
}
$output .=$info.$topics;
}else
{
$output .="
".(($dir =="0")?"نأسف لا يمكنك الالتحاق بالاختبارات فى هذا الصف الان لعدم اضافتة وحداته بعد":"Sorry you can not enter the test related to this class now")."
";
} }
//topics
function topics()
{
global $dir , $output ,$step , $class , $part ;
$output .=" ";
$qu1=@mysql_query("SELECT `td_topics`.`topics_id`,`td_topics`.`atype`,`td_topics`.`topics_name`,`td_topics`.`topics_title`,
`td_topics`.`step_id`,`td_step`.`step_name`,`td_topics`.`class_id`,`td_class`.`class_name` FROM `td_step`
Inner Join `td_topics` ON `td_topics`.`step_id` = `td_step`.`step_id`
Inner Join `td_class` ON `td_topics`.`class_id` = `td_class`.`class_id`
WHERE `td_topics`.`topics_id`='".$_REQUEST['id']."' ")or die(mysql_error());
$rqu=mysql_fetch_array($qu1);
$output .= " {$rqu[step_name]} \t >> \t{$rqu[class_name]} \t >> \t{$rqu[topics_name]}
";
if($rqu['atype'] =="1"){
if($rqu['topics_title'] != ""){
$output .= " ";
}elseif($rqu['topics_title'] == "") {
$output .= "".(($dir=="0")?"عـفــوا لا يـوجد ملف مضاف الى هذه الوحدة":"Sorry this topics no contain Any File")." ";
}
}else {
$output .= "{$rqu[topics_title]} ";
}
$output .="".(($dir=="0")?" يمكنك خـوض إمتحانات هذه الوحدة من":"you can Enter Exam following this topics")." ".(($dir=="")?"هـنــا":"HER")." ";
}
//test
function test ()
{
global $dir , $output ;
$output .=" ";
$qu=@mysql_query("select * from `history` where `user_id`='".$_SESSION[user_id]."' ");
if(@mysql_num_rows($qu) > 0) {
while($ru=mysql_fetch_array($qu)) {
$do_test.= $ru['test_id'].",";
}
}
$part[1]="".(($dir=="0")?"الفصل الدراسى الاول":"First Term")."";
$part[2]="".(($dir=="0")?"الفصل الدراسى الثانى":"Second Term")."";
$topics=intval($_REQUEST['id']);
$qtopic=@mysql_query("SELECT
`td_topics`.`topics_id`,
`td_topics`.`topics_name`,
`td_topics`.`topics_title`,
`td_topics`.`step_id`,
`td_topics`.`class_id`,
`td_topics`.`part`,
`td_class`.`class_name`,
`td_step`.`step_name`
FROM
`td_topics`
Inner Join `td_step` ON `td_topics`.`step_id` = `td_step`.`step_id`
Inner Join `td_class` ON `td_topics`.`class_id` = `td_class`.`class_id` where `topics_id`='$topics' ");
$rtopic=@mysql_fetch_array($qtopic);
$nq="SELECT `td_test`.`test_id`,`td_test`.`topics_id`, `td_test`.`test_name`,
`td_test`.`active` FROM `td_test` WHERE `topics_id`='$topics' AND `active`='1' ";
$do_test =explode(",",$do_test);
foreach($do_test as $value){
if($value !="") {
$nw.="AND ( `td_test`.`test_id` <> '$value' ) ";
}
}
$nq=$nq.$nw;
$qtest=@mysql_query($nq)or die(mysql_error());
if(@mysql_num_rows($qtest) > 0) {
$output .="".(($dir=="0")?"إختبار":"test")."\t ".$rtopic['topics_name']."\t\t >>\t ".$part[$rtopic['part']]."\t\t>>\t".$rtopic['class_name']."\t\t>>\t".$rtopic['step_name']."
";
$i=1;
while($rtest=mysql_fetch_array($qtest)){
$output .=" \t $i \t -\t ".(($dir =="0")?"عـنـوان الإختبار":"Address Test")."\t :\t {$rtest[test_name]}
";
$i++;
}
}else {
$output .="".(($dir =="0")?"عــفــواً لا توجد أمتحانات جديدة":"Sorry No New Exam ")." ";
}
}
//exam
function exam() {
global $dir , $output ;
$output .=" ";
$test=intval($_REQUEST['test']);
$qht=@mysql_query("SELECT `history`.`h_id`,`history`.`user_id`,`history`.`test_id`
FROM `history` WHERE `test_id`='$test' AND `user_id`='".$_SESSION[user_id]."' ");
$nt=@mysql_num_rows($qht);
if($nt > 0) {
$output .="".(($dir =="0")?"عــفــوا لقد قمت بأداء هذا الاختبار من قبل":"Sorry you really did this test ")." ";
$output .=" ";
}else {
$qch=@mysql_query("SELECT `td_test`.`test_id`,`td_test`.`test_degree`,`td_question`.`question_id`,
sum(`td_question`.`question_degree`) as `cq` FROM `td_test`
Inner Join `td_question` ON `td_test`.`test_id` = `td_question`.`test_id`
WHERE `td_test`.`test_id`='$test' group by `td_test`.`test_id` Order by `td_test`.`test_id` ASC ");
$nh=@mysql_num_rows($qch);
$rch=@mysql_fetch_array($qch);
if(($nh > 0 )&&($rt['cq'] == $rt['test_degree'] )) {
$i=1;
if($_POST['action']=="insert") {
$qq=@mysql_query("SELECT `td_question`.`test_id`,`td_question`.`question_id`,
`td_question`.`question`,`td_question`.`rightanswer`,`td_test`.`test_success`,
`td_test`.`test_degree`,`td_test`.`topics_id`,`td_test`.`test_name`
FROM `td_question`
Inner Join `td_test` ON `td_question`.`test_id` = `td_test`.`test_id` WHERE `td_question`.`test_id` ='$test' order by arrange,question_id")or die(mysql_error());
while($rr=mysql_fetch_array($qq))
{
$topic_id=$rr['topics_id'];
$qu="quesion$i";
$question=$_POST[$qu];
$answer=$_POST[$i];
$output .= "{$rr[question]} ";
$qans=mysql_query("SELECT `td_answer`.`answer_id`,`td_answer`.`answer_title`,`td_answer`.`question_id`
FROM `td_answer` where `question_id`='$rr[question_id]' ");
$output .= "
";
while($rans=mysql_fetch_array($qans))
{
$output .= " {$rans[answer_title]} ";
}
$suresult=$rr['test_success'];
$fresult =$rr['test_degree'];
$result+=0;
$qright=mysql_query("select * from `td_question` where `rightanswer`='$answer' and `question_id`='$question' ");
if($nm=mysql_num_rows($qright) > 0) {
$rq=mysql_fetch_array($qright);
$result +=$rq['question_degree'];
$topic=$rr['topics_id'];
$output .= "".(($dir=="0")?"الاجابة صحيحة":"The Right Answer")." \t(
)\t \t \t \t
";
}else
{
$output .= "".(($dir=="0")?"الاجابة خطأ":"This Wrong Answer")." \t(
)\t \t \t \t
".(($dir=="0")?" الاجـابة الصحيحة هى":"The correct Answer")." ".$rr['rightanswer']." ";
}
$i++;
}
$qq=@mysql_query("SELECT `td_test`.`test_id`,`td_test`.`active`,
`td_question`.`question_id`,`td_test`.`topics_id`
FROM `td_test`
Inner Join `td_question` ON `td_test`.`test_id` = `td_question`.`test_id`
Where (`td_test`.`test_id` > '$test') AND (`td_test`.`topics_id` ='$topic_id') AND (`td_test`.`active` = '1')
group by `td_test`.`test_id` order by `td_test`.`test_id` ASC ");
$rrq=@mysql_fetch_array($qq);
$testid=$rrq['test_id'];
$output .= "".(($dir=="0")?"مجموع الــدرجات التى حصلت عليها عن هذا الامتحان هى ":"Your Degree Get in the Exam")." \t : \t".$result." / ".$fresult." ";
if($result >= $suresult) {
$output .= "".(($dir=="0")?"تــهـانينا لقد حصل على درجة النجاح فى هذه الوحدة":"congratulations You Get on sucessed degree this unit ")."\t \t".(($dir=="0")?"العودة إلى صفحة الأختبارات":"Back to Exams page")." \t | \t";
if (($testid !="")&&($testid !="0")) {
$output .="".(($dir=="0")?"الأخـتـبار الـتـالـى":" Next Exam ")." ";
}
}else {
$output .= "".(($dir=="0")?"عــفـوا لـم تتمكن من الحصول على درجة النجاح ":"Sorry you can't get on sucessed degree to this unit")."".(($dir=="0")?"الامتحان الملحق":" Exam Failed ")." ";
}
@mysql_query("insert into `history`(`user_id`,`test_id`,`exam_degree`,`exam_date`,`type_exam`)VALUES('".$_SESSION[user_id]."','$test','$result','".date('Y-m-d')."','1')");
}else {
$part[1]="".(($dir=="0")?"الفصل الدراسى الاول":"First term");
$part[2]="".(($dir=="0")?"الفصل الدراسى الثانى":"SECOND term");"";
$qts=@mysql_query("SELECT `td_test`.`test_id`,`td_test`.`test_name`,`td_test`.`topics_id`,
`td_topics`.`topics_name`,`td_topics`.`class_id`,`td_class`.`class_name`,
`td_step`.`step_name`,`td_topics`.`part`,`td_class`.`step_id`
FROM `td_test`
Inner Join `td_topics` ON `td_test`.`topics_id` = `td_topics`.`topics_id`
Inner Join `td_class` ON `td_topics`.`class_id` = `td_class`.`class_id`
Inner Join `td_step` ON `td_class`.`step_id` = `td_step`.`step_id` where `td_test`.`test_id`='$test' ");
$rts=mysql_fetch_array($qts);
$output .= "
".$rts['test_name']." ".$rts['topics_name']." ".$part[$rts['part']]." ".$rts['class_name']." ".$rts['step_name']." ";
$output .= "
";
$user=$_SESSION[user_name];
if(session_is_registered(user))
{
global $output;
echo $output;
}else
{
echo " ";
}
?>