$row_user_tests = mysql_fetch_row($res_user_tests);
if ($row_user_tests [3] >2) {
//$res_user_courses=mysql_query("SELECT * FROM user_courses WHERE id_user_course='". $id_course. "'");
//$row_user_courses = mysql_fetch_row($res_user_courses);
$user_courses_SQL = "UPDATE user_courses SET status='not', end_date='". date("Y/m/d"). "' WHERE id_user_course='". $id_course. "'";
mysql_query($user_courses_SQL);
}
}
echo "<hr color=\"#FFDFBF\" size=\"1\" style=\"border-style: dotted\"></hr>";
echo "<a class=\"light\" href=\"training. php\">на личную страницу<a>";
}
}
if ($q_count>0 && $q_count<6) {
//прорисовка вопросов - ответов
if ($q_count==1) {
$res_user_tests=mysql_query("SELECT * FROM user_tests WHERE n_user_course='". $id_course. "' AND n_course_part='". $id_part. "'");
if (mysql_num_rows($res_user_tests) ==0) {
$user_tests_SQL = "INSERT INTO user_tests values('0','". $id_course. "','". $id_part. "','1','0','". date("Y/m/d"). "')";
mysql_query($user_tests_SQL);
}
else {
$row_user_tests = mysql_fetch_row($res_user_tests);
$row_user_tests [3] ++;
if ($row_user_tests [3] <4) {
$user_tests_SQL = "UPDATE user_tests SET attemps='". $row_user_tests [3]. "', last_test_date='". date("Y/m/d"). "' WHERE n_user_course='". $id_course. "' AND n_course_part='". $id_part. "'";
mysql_query($user_tests_SQL);
}
}
echo "Выберите ответ на вопрос №". $q_count;
include "body_list_after_header. php";
}
$str_question ="SELECT * FROM questions WHERE id_question='";
if ($q_count==1) {
$res_question=mysql_query($str_question. $q_1. "'");
}
elseif ($q_count==2) {
$res_question=mysql_query($str_question. $q_2. "'");
}
elseif ($q_count==3) {
$res_question=mysql_query($str_question. $q_3. "'");
}
elseif ($q_count==4) {
$res_question=mysql_query($str_question. $q_4. "'");
}
else {
$res_question=mysql_query($str_question. $q_5. "'");
}
$row_question=mysql_fetch_row($res_question);
echo "<b>". $row_question [2]. "</b><br>";
echo "<form name=\"form_test\" action=\"$TestScript\" metod=\"get\" style=\"margin: 0px\">";
$strSQL="SELECT * FROM answers WHERE n_question='". $row_question [0]. "'";
$res_answer=mysql_query($strSQL);
//$answer_count=1;
//echo "<form>";
//
//while ($row_answer=mysql_fetch_row($res_answer)) {
//echo "<input name=\"a_". $answer_count. "\" type=\"checkbox\">". $row_answer [2] ;
//echo "<input name=\"id_a_". $answer_count. "\" type=\"hidden\" value=". $row_answer [0]. "><br>";
//$answer_count++;
//}
$mas_count=0;
while ($mas_temp=mysql_fetch_row($res_answer)) {
$mas_answer [$mas_count] [0] =$mas_temp [0] ;
$mas_answer [$mas_count] [1] =0;
$mas_count++;
}
$mas_count--;
for ($i=1; $i<=5; $i++) {
mt_srand(time());
while (true) {
$mas_index=mt_rand(0,$mas_count);
if ($mas_answer [$mas_index] [1] ==0) {
$mas_answer [$mas_index] [1] =1;
break;
}
}
$strSQL="SELECT * FROM answers WHERE id_answer='". $mas_answer [$mas_index] [0]. "'";
$res_answer=mysql_query($strSQL);
$row_answer=mysql_fetch_row($res_answer);
echo "<input name=\"a_". $i. "\" type=\"checkbox\">". $row_answer [2] ;
echo "<input name=\"id_a_". $i. "\" type=\"hidden\" value=". $row_answer [0]. "><br>";
}
echo "<input name=\"id_course\" type=\"hidden\" value=". $id_course. ">";
echo "<input name=\"id_part\" type=\"hidden\" value=". $id_part. ">";
echo "<input name=\"q_1\" type=\"hidden\" value=". $q_1. ">";
echo "<input name=\"q_2\" type=\"hidden\" value=". $q_2. ">";
echo "<input name=\"q_3\" type=\"hidden\" value=". $q_3. ">";
echo "<input name=\"q_4\" type=\"hidden\" value=". $q_4. ">";
echo "<input name=\"q_5\" type=\"hidden\" value=". $q_5. ">";
echo "<input name=\"q_count\" type=\"hidden\" value=". ++$q_count. ">";
echo "<input name=\"r_count\" type=\"hidden\" value=". $r_count. ">";
echo "<hr color=\"#FFDFBF\" size=\"1\" style=\"border-style: dotted\"></hr>";
echo "<input type=\"submit\" name=\"test_ok\" style=\"height: 18; width: 41\" class=\"buttonOrange\" value=\"ОК\">";
echo "</form>";
}
include "body_list_footer. php";
? >
</td>
</tr>
</table>
Приложение ГЛистинги модуля администрирования
Г.1 Листинг модуля "admin_edit. php"
<html>
<head>
<title> Remote Learning Institute | Administration</title>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
</head>
<body>
<?
include "header. php";
$ScriptAdmAdd="admin_add. php";
$ScriptAdmDel="admin_del. php";
$ScriptAdmMdf="admin_update. php";
global $SelectT;
echo "<table width=\"835\" border=\"0\" cellpadding=\"3\" background=\"#FAF1D8\" cellspacing=\"0\" >";
echo "<tr><td>";
include "body_list_header. php";
echo "Редактирование таблиц данных: ";
include "body_list_after_header. php";
echo "<table splitcell=3><tr>";
require "option. php";
mysql_connect($SERVER,$USER,$PASSWD) or die(mysql_error());
mysql_select_db($DB);
$ListF=mysql_list_fields($DB,$SelectT);
$CounterF=0;
while ($CounterF < mysql_num_fields($ListF)) {
$stItem=mysql_field_name($ListF,$CounterF);
$CounterF++;
$massField [$CounterF] =$stItem;
echo "<td bgcolor=#ffcc00 class=\"textblockBlue\">$massField [$CounterF] </td>";
}
echo "<td bgcolor=#ffcc00 class=\"textblockBlue\">редактировать</td>";
echo "</tr><tr>";
$strSQL ="SELECT * FROM ". $SelectT. "; ";
$res=mysql_query($strSQL);
while ($Row=mysql_fetch_row($res)) {
for ($CounterF=0; $CounterF< mysql_num_fields($ListF); $CounterF++) {
echo "<td class=\"textblockBlue\">$Row [$CounterF] </td>";
}
echo "<td class=\"table_admin\" align=\"center\">";
echo "<a href=\"$ScriptAdmMdf". "? t_name=". urlencode($SelectT). "&t_index=". urlencode($Row [0]). "\">изменить<a>|";
echo "<a href=\"$ScriptAdmDel". "? t_name=". urlencode($SelectT). "&t_index=". urlencode($Row [0]). "\">удалить<a>";
echo "</td></tr><tr>";
}
$ScriptAdmAdd=$ScriptAdmAdd. "? t_name=". urlencode($SelectT);
mysql_free_result($ListF);
echo "</tr></table>";
echo "<tr><td colspan=2><table>";
echo "<form name=\"FormName\" method=\"post\" margin=\"0\" action=$ScriptAdmAdd>";
echo "<input type=\"submit\" name=\"select\" style=\"height: 18\" class=\"buttonOrange\" value=\"добавить\">|";
echo "<a class=\"light\" href=admin. php>возврат</a>";
echo "</form>";
include "body_list_footer. php";
echo "</table></td></tr></table>";
include "buttom. php";
? >
</body>
</html>
Г.2 Листинг модуля "admin_add. php"
<html>
<head>
<title> Remote Learning Institute | Administration</title>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
</head>
<body>
<? include "header. php"? >
<?
$ScriptAdm = "admin_add_check. php";
global $t_name,$t_index;
echo "<table width=\"835\" border=\"0\" cellpadding=\"3\" background=\"#FAF1D8\" cellspacing=\"0\" >";
echo "<tr><td>";
include "body_list_header. php";
echo "Добавление данных в таблицу: ";
include "body_list_after_header. php";
require "option. php";
mysql_connect($SERVER,$USER,$PASSWD) or die(mysql_error());
mysql_select_db($DB);
$t_name= urldecode($t_name);
$ListF=mysql_list_fields($DB,$t_name);
$CounterF=0;
echo "<form name=\"FormName\" method=\"get\" margin=\"0\" action=\"$ScriptAdm\">";
while ($CounterF < mysql_num_fields($ListF)) {
$stItem=mysql_field_name($ListF,$CounterF);
$CounterF++;
$massField [$CounterF] =$stItem;
echo "<span class=\"textonlightblue\"><b>$massField [$CounterF] </b></span><br>";
echo "<input type=\"text\" name=\"". $massField [$CounterF]. "\" class=\"textblockBlue\"><br>";
}
echo "<input type=\"hidden\" name=\"t_name\" value=\"". $t_name. "\"class=\"textblockBlue\"><br>";
echo "<input type=\"button\" name=\"back\" style=\"height: 18\" class=\"buttonOrange\" value=\"возврат\" onClick=\"self. history. back(); \">|";
echo "<input type=\"submit\" name=\"select\" style=\"height: 18\" class=\"buttonOrange\" value=\"ок\">";
echo "</form>";
include "body_list_footer. php";
echo "</td></tr></table>";
include "buttom. php"? >
</body>
</html>
Г.3 Листинг модуля "admin_del. php"
<html>
<head>
<title> Remote Learning Institute | Administration</title>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
</head>
<body>
<? include "header. php";
$ScriptAdm ="admin_edit. php";
global $t_name,$t_index;
echo "<table width=\"835\" border=\"0\" cellpadding=\"3\" background=\"#FAF1D8\" cellspacing=\"0\" >";
echo "<tr><td>";
include "body_list_header. php";
echo "удаление данных из таблицы: ";
include "body_list_after_header. php";
require "option. php";
mysql_connect($SERVER,$USER,$PASSWD) or die(mysql_error());
mysql_select_db($DB);
$ListF=mysql_list_fields($DB,$t_name);
$CounterF=0;
$ScriptAdm = $ScriptAdm. "? SelectT=". urlencode($t_name);
while ($CounterF < mysql_num_fields($ListF)) {
$stItem=mysql_field_name($ListF,$CounterF);
$massField [$CounterF] =$stItem;
$CounterF++;
}
$strSQL="DELETE FROM ". $t_name. " WHERE ". $massField [0]. "='". $t_index. "'";
mysql_query($strSQL);
echo "<form name=\"FormName\" method=\"post\" margin=\"0\" action=$ScriptAdm>";
echo "<span class=\"textonlightblue\"><b>Запись удалена</b></span><br>";
echo "<input type=\"submit\" name=\"select\" style=\"height: 18\" class=\"buttonOrange\" value=\"готово\">";
echo "</form>";
include "body_list_footer. php";
echo "</td></tr></table>";
include "buttom. php";
? >
</body>
</html>
Г.4 Листинг модуля "admin_update. php"
<html>
<head>
<title> Remote Learning Institute | Administration</title>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
</head>
<body>
<? include "header. php"? >
<?
$ScriptAdm = "admin_update_check. php";
global $t_name,$t_index;
echo "<table width=\"835\" border=\"0\" cellpadding=\"3\" background=\"#FAF1D8\" cellspacing=\"0\" >";
echo "<tr><td>";
include "body_list_header. php";
echo "Изменение данных в записи: ";
include "body_list_after_header. php";
require "option. php";
mysql_connect($SERVER,$USER,$PASSWD) or die(mysql_error());
mysql_select_db($DB);
$t_name= urldecode($t_name);
$ListF=mysql_list_fields($DB,$t_name);
$CounterF=0;
echo "<form name=\"FormName\" method=\"get\" margin=\"0\" action=\"$ScriptAdm\">";
$stItem=mysql_field_name($ListF,$CounterF);
$sqlstr = "SELECT * FROM ". $t_name. " WHERE ". $stItem. "='". $t_index. "'; ";
$res=mysql_query($sqlstr);
$Row=mysql_fetch_row($res);
echo "<input type=\"hidden\" name=\"id_tab\" value=\"". $Row [0]. "\">";
while ($CounterF < mysql_num_fields($ListF)) {
$stItem=mysql_field_name($ListF,$CounterF);
$CounterF++;
$massField [$CounterF] =$stItem;
echo "<span class=\"textonlightblue\"><b>$massField [$CounterF] </b></span><br>";
echo "<input type=\"text\" name=\"". $massField [$CounterF]. "\" class=\"textblockBlue\" value=\"". $Row [$CounterF-1]. "\"><br>";
}
echo "<input type=\"hidden\" name=\"t_name\" value=\"". $t_name. "\"class=\"textblockBlue\"><br>";
echo "<input type=\"button\" name=\"back\" style=\"height: 18\" class=\"buttonOrange\" value=\"возврат\" onClick=\"self. history. back(); \">|";
echo "<input type=\"submit\" name=\"select\" style=\"height: 18\" class=\"buttonOrange\" value=\"ок\">";
echo "</form>";
include "body_list_footer. php";
echo "</td></tr></table>";
include "buttom. php"? >
</body>
</html>