<?
/*-------------------------------------------------------------------
paper_question_list_stu.php Ver. $Revision: 1.2 $ $Date: 2003/05/21 02:00:39 $
*
*
Copyright (C) 2000 Hong Kong Baptist University
*
This file is part of the Quadrille system.
* This program is free software; it is distributed under the terms of
the GNU General Public License, either version 2, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*
---------------------------------------------------------------------
*/
?>
<?
require "./global_inc.php";
require "./config_inc.php";
include $language_pack;
include "question_stu_{$lang_name}.inc";
require "output_inc.php";
require "template.php";
global $temp_cookie;
/**************/
/* Main part */
/**************/
check_expire();
$temp_cookie["user_uid"] = $cookie["user_uid"];
$temp_cookie["password"] = $cookie["password"];
$temp_cookie["db_index"] = $cookie["db_index"];
$temp_cookie["course_uid"] = $cookie["course_uid"];
$temp_cookie["unit_uid"]= "";
if(isset($paper_uid))
$temp_cookie["paper_uid"] = $paper_uid;
else
$temp_cookie["paper_uid"] = $cookie["paper_uid"];
set_cookie($temp_cookie);
insert_header();
$currentlocation = insert_current_location($temp_cookie["course_uid"], '', $temp_cookie["paper_uid"]);
$content = paper_question_list_stu($paper_uid);
$java = get_file("javascript/paper_question_stu.js");
$java = ereg_replace("<BEGIN>SELECT_QUESTION_FIRST<END>",$SELECT_QUESTION_FIRST,$java);
$java = ereg_replace("<BEGIN>SELECT_ONE_ONLY<END>",$SELECT_ONE_QUES_ONLY,$java);
$java = ereg_replace("<BEGIN>HIDDEN_FIELD<END>","selected_q_list",$java);
$html = get_template($template, $template_dir);
$html=ereg_replace("<BEGIN>TITLE<END>",$PAGE_TITLE["PAPER_QUESTION_LIST"],$html);
$html=ereg_replace("<BEGIN>CURRENTLOCATION<END>",$currentlocation,$html);
$html=ereg_replace("<BEGIN>JAVASCRIPT<END>",$java,$html);
$html=ereg_replace("<BEGIN>CONTENT<END>",$content,$html);
$html=ereg_replace("<BEGIN>COPYRIGHT<END>",$COPYRIGHT,$html);
print $html;
/******************/
/* function part */
/******************/
function paper_question_list_stu($paper_uid) {
include ("./config_inc.php");
include $language_pack;
include "question_stu_{$lang_name}.inc";
global $cookie;
global $paper_type;
global $selected_q_list;
global $q_uid_list;
global $q_mark_list;
global $q_tries_list;
global $q_max_tries_list;
global $mark_gain_list;
global $mark_deduct_list;
global $q_lock_list;
global $array_position;
$content="";
if (strstr($selected_q_list, 'd') != null) { //'d' exists means last question is disabled
$selected_q_list = str_replace("d,", "", $selected_q_list);//delete disabled question..
$selected_q_list = str_replace(",d", "", $selected_q_list);//..from $selected_q_list
}
$selected_q_array = split(",", $selected_q_list);
$q_uid_array = split(",", $q_uid_list);
$q_mark_array = split(",", $q_mark_list);
$q_tries_array = split(",", $q_tries_list);
$q_max_tries_array = split(",", $q_max_tries_list);
$mark_gain_array = split(",", $mark_gain_list);
$mark_deduct_array = split(",", $mark_deduct_list);
$q_lock_array = split(",", $q_lock_list);
if (!empty($q_uid_array)) {
if (count($q_uid_array) >= $nrows_for_two_links)
$content.=insert_link_line();
$content.="<form name=\"form1\" method=\"post\">";
$content.="<table width=\"\" border=\"0\" cellspacing=\"4\" cellpadding=\"5\" >";
$content.="\n\t\t<tr>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\"> </td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$QUESTION_NO</td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$Q_UID</td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$COMPLETED</td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$QUESTION_TYPE_NAME</td>";
if ($paper_type != "EXAM")
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$MAX_TRIAL</td>";
if ($paper_type == "ASSIGNMENT") {
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$CURRENT_TRIES</td>";
}
if ($paper_type != "EXERCISE") {
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$MARK_GAIN</td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$MARK_DEDUCT</td>";
}
if ($paper_type == "ASSIGNMENT")
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$CURRENT_MARK</td>";
$content.="\n\t\t</tr>";
for ($i = 0; $i < count($q_uid_array); $i++) {
$q_uid = $q_uid_array[$i];
$no_of_trial = $q_max_tries_array[$i];
$mark_gain = $mark_gain_array[$i];
$mark_deduct = $mark_deduct_array[$i];
$query_qtype = "SELECT QTYPE_UID FROM QUESTION Q
WHERE Q.UID = $q_uid_array[$i]";
$result_qtype = mysql_query($query_qtype);
if (mysql_num_rows($result_qtype) == 1) {
$row_qtype = mysql_fetch_array($result_qtype);
$qtype_uid = $row_qtype["QTYPE_UID"];
$qtype = $QUESTION_TYPE[$qtype_uid];
}
$locked = $q_lock_array[$i];
$current_tries = $q_tries_array[$i];
$current_mark = $q_mark_array[$i];
$class = ($i%2==0)? "tablerowodd": "tableroweven";
$content.="\n\t\t<tr class=$class>";
$content.="\n\t\t\t<td><input type=\"checkbox\" name=\"checkbox\" value=\"$i\"";
if ($locked) $content.=" disabled";
for ($j = 0; $j < count($selected_q_array); $j++)
if ($q_uid == $q_uid_array[$selected_q_array[$j]]) {
$content.=" checked";
break;
}
$content.="></td>";
$content.= table_cell($class, " ".$i+1, 1);
$content.="\n\t\t\t";
$content.= table_cell($class, " ".$q_uid, 1);
$content.="\n\t\t\t";
$content.="<td><input type=\"checkbox\" name=\"disabled_checkbox\"";
if ($locked) $content.=" checked";
$content.=" disabled></td>";
$content.="\n\t\t\t";
$content.= table_cell($class, " ".$qtype, 1);
$content.="\n\t\t\t";
if ($paper_type != "EXAM") {
$content.= table_cell($class, " ".$no_of_trial, 1);
$content.="\n\t\t\t";
}
if ($paper_type == "ASSIGNMENT") {
$content.= table_cell($class, " ".$current_tries, 1);
$content.="\n\t\t\t";
}
if ($paper_type != "EXERCISE") {
$content.= table_cell($class, " ".$mark_gain, 1);
$content.="\n\t\t\t";
$content.= table_cell($class, " ".$mark_deduct, 1);
}
if ($paper_type == "ASSIGNMENT") {
$content.= table_cell($class, " ".$current_mark, 1);
$content.="\n\t\t\t";
}
$content.="\n\t\t</tr>";
}
if ($paper_type == "ASSIGNMENT") {
$total_marks = 0;
for ($i = 0; $i < count($q_mark_array); $i++)
$total_marks += $q_mark_array[$i];
$total_marks = round($total_marks, $MARK_PRECISION);
$content.="<tr><td colspan=\"8\">";
}
else
$content.="\n\t</table>";
$content.="\n\t<input type=\"button\" name=\"clickall\" value=\"$SELECT_ALL\" onclick=\"click_all()\";>";
$content.="\n\t<input type=\"button\" name=\"unclickall\" value=\"$CLEAR_FORM\" onclick=\"unclick_all()\";>";
if (($lang_name == "eng") && (count($q_uid_array) > 1))
$content.="\n\n$TOTAL_QS_A".count($q_uid_array)."$TOTAL_QS_B";
else
$content.="\n\n$TOTAL_Q_A".count($q_uid_array)."$TOTAL_Q_B";
if ($paper_type == "ASSIGNMENT") {
$content.="</td>";
$content.="<td class = \"tableheading\">$TOTAL_MARKS</td>";
$content.="<td class = \"readonlyfield\">$total_marks</td>";
$content.="</tr>";
$content.="\n\t</table>";
}
$selected_q_list = array_to_list($selected_q_array);
$q_uid_list = array_to_list($q_uid_array);
$q_mark_list = array_to_list($q_mark_array);
$q_tries_list = array_to_list($q_tries_array);
$q_lock_list = array_to_list($q_lock_array);
$q_max_tries_list = array_to_list($q_max_tries_array);
$mark_gain_list = array_to_list($mark_gain_array);
$mark_deduct_list = array_to_list($mark_deduct_array);
$content.="\n\t<input type=\"hidden\" name=\"paper_uid\" value=\"$paper_uid\">";
$content.="\n\t<input type=\"hidden\" name=\"paper_type\" value=\"$paper_type\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"array_position\" value=\"$array_position\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"selected_q_list\" value=\"$selected_q_list\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"q_uid_list\" value=\"$q_uid_list\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"q_mark_list\" value=\"$q_mark_list\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"q_tries_list\" value=\"$q_tries_list\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"q_max_tries_list\" value=\"$q_max_tries_list\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"mark_gain_list\" value=\"$mark_gain_list\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"mark_deduct_list\" value=\"$mark_deduct_list\">";
$content.="\n\t<input type=\"hidden\" name=\"source_from\" value=\"".basename(__FILE__)."\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"current_tries\" value=\"0\">";
$content.="\n\t\t\t\t<input type=\"hidden\" name=\"q_lock_list\" value=\"$q_lock_list\">";
$content.="\n</form>";
$content.=insert_link_line();
}
else {
$content.="\n<br /><p class=\"warning\">$NO_QUESTION</p>";
$content.=insert_done_link_line();
}
return $content;
} //end of function paper_question_list_stu()
function insert_link_line()
{ $a = array ( 'TO_ANSWER' => "javascript:ans_paper_question();"
, 'DONE' => "paper_list_stu.php"
);
return link_line($a, "");
} //end of function insert_link_line()
function insert_done_link_line()
{ $a = array ( 'DONE' => "paper_list_stu.php" );
return link_line($a, "");
} //end of function insert_empty_link_line()
?>