Tryag File Manager
Home
-
Turbo Force
Current Path :
/
home
/
cluster1
/
data
/
bu01
/
1121861
/
html
/
jlex
/
qbank
/
Upload File :
New :
File
Dir
/home/cluster1/data/bu01/1121861/html/jlex/qbank/qbank_quiz.php4
<? include_once("../php4/query_object.php4"); include_once("../php4/project_defaults.php4"); include_once("../php4/mysql_to_xml.php4"); function get_xml_for_question($session_vars) { $qo = $_SESSION["qo"]; $ids = $_SESSION["ids"]; $converter = $_SESSION["converter"]; $cur_question = $_SESSION["cur_question"]; $header_subjects = $_SESSION["header_subjects"]; $header_sections = $_SESSION["header_sections"]; $header_keywords = $_SESSION["header_keywords"]; $stylesheet = "question.xsl"; $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml .= "<?xml-stylesheet href='$stylesheet' type='text/xsl'?>\n"; $xml .= "<quiz>\n"; $xml .= "<subjects>$header_subjects</subjects>\n"; $xml .= "<sections>$header_sections</sections>\n"; $xml .= "<keywords>$header_keywords</keywords>\n"; $xml .= "<cur_question>".($cur_question+1)."</cur_question>\n"; $xml .= "<num_questions>".count($ids)."</num_questions>\n"; $group = $converter->load_resultset_into_group($qo,$ids[$cur_question]); $template = explode(" ",trim($group->template)); $xml .= $group->to_xml_3($template,false); $xml .= "</quiz>"; return $xml; } session_start(); $form_vars = array_merge($_GET, $_POST); $function = $form_vars["function"]; if($function == "start_quiz") { $qo = new query_object(); $qo->set_project("qbank"); $i = 0; $subject = $form_vars["subject"]; $header_subjects = ""; if(count($subject) > 0) { $subjects = ""; foreach($subject as $s) { $subjects .= $s."|"; $header_subjects .= "$s, "; } $subjects = substr($subjects,0,-1); $header_subjects = substr($header_subjects,0,-2); $form_vars["db_cols_".$i] = "subject"; $form_vars["reg_exp_".$i] = "contains sequence"; $form_vars["string_".$i] = $subjects; $form_vars["connective_".$i] = "AND"; $i++; } $section = $form_vars["section"]; $header_sections = ""; if(count($section) > 0) { $sections = ""; foreach($section as $s) { $sections .= $s."|"; $header_sections .= "$s, "; } $sections = substr($sections,0,-1); $header_sections = substr($header_sections,0,-2); $form_vars["db_cols_".$i] = "section"; $form_vars["reg_exp_".$i] = "contains sequence"; $form_vars["string_".$i] = $sections; $form_vars["connective_".$i] = "AND"; $i++; } $header_keywords = trim($form_vars["keywords"]); $keywords = explode(" ",$header_keywords); if(count($keywords) > 0) { $words = ""; $in_phrase = false; foreach($keywords as $s) { if(ereg("^\"",$s)) { $in_phrase = true; $s = substr($s,1); } if($in_phrase) { $words .= "$s "; if(ereg("\"$",$s)) { $words = substr($words,0,-2)."|"; $in_phrase = false; } } else { $words .= $s."|"; } } $words = substr($words,0,-1); $form_vars["db_cols_".$i] = "keywords"; $form_vars["reg_exp_".$i] = "contains sequence"; $form_vars["string_".$i] = $words; } $pd = new project_defaults(); $defaults = $pd->get_project_defaults("defaults.xml"); $form_vars["project"] = "qbank"; $qo->fill_query_object($form_vars,$defaults); $converter = new mysql_to_xml(); $qo = $converter->query_database($qo); $ids = $qo->get_main_ids(); shuffle($ids); $_SESSION["ids"] = $ids; $_SESSION["cur_question"] = 0; $_SESSION["qo"] = $qo; $_SESSION["converter"] = $converter; $_SESSION["header_subjects"] = $header_subjects; $_SESSION["header_sections"] = $header_sections; $_SESSION["header_keywords"] = $header_keywords; $xml = get_xml_for_question($_SESSION); header("Content-Type: application/xml"); echo $xml; } else if($function == "next_question") { $cur_question = $_SESSION["cur_question"]; $cur_question++; $_SESSION["cur_question"] = $cur_question; $xml = get_xml_for_question($_SESSION); header("Content-Type: application/xml"); echo $xml; } else if ($function == "prev_question") { $cur_question = $_SESSION["cur_question"]; $cur_question--; $_SESSION["cur_question"] = $cur_question; $xml = get_xml_for_question($_SESSION); header("Content-Type: application/xml"); echo $xml; } else if($function == "goto_question") { $cur_question = $form_vars["question_number"]; $cur_question--; $_SESSION["cur_question"] = $cur_question; $xml = get_xml_for_question($_SESSION); header("Content-Type: application/xml"); echo $xml; } ?>