Смекни!
smekni.com

Исследование использования программ дистанционного обучения для подготовки учебно-методической документации (стр. 27 из 27)

$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=&bsol;"#FFDFBF&bsol;" size=&bsol;"1&bsol;" style=&bsol;"border-style: dotted&bsol;"></hr>";

echo "<a class=&bsol;"light&bsol;" href=&bsol;"training. php&bsol;">на личную страницу<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=&bsol;"form_test&bsol;" action=&bsol;"$TestScript&bsol;" metod=&bsol;"get&bsol;" style=&bsol;"margin: 0px&bsol;">";

$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=&bsol;"a_". $answer_count. "&bsol;" type=&bsol;"checkbox&bsol;">". $row_answer [2] ;

//echo "<input name=&bsol;"id_a_". $answer_count. "&bsol;" type=&bsol;"hidden&bsol;" 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=&bsol;"a_". $i. "&bsol;" type=&bsol;"checkbox&bsol;">". $row_answer [2] ;

echo "<input name=&bsol;"id_a_". $i. "&bsol;" type=&bsol;"hidden&bsol;" value=". $row_answer [0]. "><br>";

}

echo "<input name=&bsol;"id_course&bsol;" type=&bsol;"hidden&bsol;" value=". $id_course. ">";

echo "<input name=&bsol;"id_part&bsol;" type=&bsol;"hidden&bsol;" value=". $id_part. ">";

echo "<input name=&bsol;"q_1&bsol;" type=&bsol;"hidden&bsol;" value=". $q_1. ">";

echo "<input name=&bsol;"q_2&bsol;" type=&bsol;"hidden&bsol;" value=". $q_2. ">";

echo "<input name=&bsol;"q_3&bsol;" type=&bsol;"hidden&bsol;" value=". $q_3. ">";

echo "<input name=&bsol;"q_4&bsol;" type=&bsol;"hidden&bsol;" value=". $q_4. ">";

echo "<input name=&bsol;"q_5&bsol;" type=&bsol;"hidden&bsol;" value=". $q_5. ">";

echo "<input name=&bsol;"q_count&bsol;" type=&bsol;"hidden&bsol;" value=". ++$q_count. ">";

echo "<input name=&bsol;"r_count&bsol;" type=&bsol;"hidden&bsol;" value=". $r_count. ">";

echo "<hr color=&bsol;"#FFDFBF&bsol;" size=&bsol;"1&bsol;" style=&bsol;"border-style: dotted&bsol;"></hr>";

echo "<input type=&bsol;"submit&bsol;" name=&bsol;"test_ok&bsol;" style=&bsol;"height: 18; width: 41&bsol;" class=&bsol;"buttonOrange&bsol;" value=&bsol;"ОК&bsol;">";

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=&bsol;"835&bsol;" border=&bsol;"0&bsol;" cellpadding=&bsol;"3&bsol;" background=&bsol;"#FAF1D8&bsol;" cellspacing=&bsol;"0&bsol;" >";

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=&bsol;"textblockBlue&bsol;">$massField [$CounterF] </td>";

}

echo "<td bgcolor=#ffcc00 class=&bsol;"textblockBlue&bsol;">редактировать</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=&bsol;"textblockBlue&bsol;">$Row [$CounterF] </td>";

}

echo "<td class=&bsol;"table_admin&bsol;" align=&bsol;"center&bsol;">";

echo "<a href=&bsol;"$ScriptAdmMdf". "? t_name=". urlencode($SelectT). "&t_index=". urlencode($Row [0]). "&bsol;">изменить<a>|";

echo "<a href=&bsol;"$ScriptAdmDel". "? t_name=". urlencode($SelectT). "&t_index=". urlencode($Row [0]). "&bsol;">удалить<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=&bsol;"FormName&bsol;" method=&bsol;"post&bsol;" margin=&bsol;"0&bsol;" action=$ScriptAdmAdd>";

echo "<input type=&bsol;"submit&bsol;" name=&bsol;"select&bsol;" style=&bsol;"height: 18&bsol;" class=&bsol;"buttonOrange&bsol;" value=&bsol;"добавить&bsol;">|";

echo "<a class=&bsol;"light&bsol;" 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=&bsol;"835&bsol;" border=&bsol;"0&bsol;" cellpadding=&bsol;"3&bsol;" background=&bsol;"#FAF1D8&bsol;" cellspacing=&bsol;"0&bsol;" >";

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=&bsol;"FormName&bsol;" method=&bsol;"get&bsol;" margin=&bsol;"0&bsol;" action=&bsol;"$ScriptAdm&bsol;">";

while ($CounterF < mysql_num_fields($ListF)) {

$stItem=mysql_field_name($ListF,$CounterF);

$CounterF++;

$massField [$CounterF] =$stItem;

echo "<span class=&bsol;"textonlightblue&bsol;"><b>$massField [$CounterF] </b></span><br>";

echo "<input type=&bsol;"text&bsol;" name=&bsol;"". $massField [$CounterF]. "&bsol;" class=&bsol;"textblockBlue&bsol;"><br>";

}

echo "<input type=&bsol;"hidden&bsol;" name=&bsol;"t_name&bsol;" value=&bsol;"". $t_name. "&bsol;"class=&bsol;"textblockBlue&bsol;"><br>";

echo "<input type=&bsol;"button&bsol;" name=&bsol;"back&bsol;" style=&bsol;"height: 18&bsol;" class=&bsol;"buttonOrange&bsol;" value=&bsol;"возврат&bsol;" onClick=&bsol;"self. history. back(); &bsol;">|";

echo "<input type=&bsol;"submit&bsol;" name=&bsol;"select&bsol;" style=&bsol;"height: 18&bsol;" class=&bsol;"buttonOrange&bsol;" value=&bsol;"ок&bsol;">";

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=&bsol;"835&bsol;" border=&bsol;"0&bsol;" cellpadding=&bsol;"3&bsol;" background=&bsol;"#FAF1D8&bsol;" cellspacing=&bsol;"0&bsol;" >";

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=&bsol;"FormName&bsol;" method=&bsol;"post&bsol;" margin=&bsol;"0&bsol;" action=$ScriptAdm>";

echo "<span class=&bsol;"textonlightblue&bsol;"><b>Запись удалена</b></span><br>";

echo "<input type=&bsol;"submit&bsol;" name=&bsol;"select&bsol;" style=&bsol;"height: 18&bsol;" class=&bsol;"buttonOrange&bsol;" value=&bsol;"готово&bsol;">";

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=&bsol;"835&bsol;" border=&bsol;"0&bsol;" cellpadding=&bsol;"3&bsol;" background=&bsol;"#FAF1D8&bsol;" cellspacing=&bsol;"0&bsol;" >";

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=&bsol;"FormName&bsol;" method=&bsol;"get&bsol;" margin=&bsol;"0&bsol;" action=&bsol;"$ScriptAdm&bsol;">";

$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=&bsol;"hidden&bsol;" name=&bsol;"id_tab&bsol;" value=&bsol;"". $Row [0]. "&bsol;">";

while ($CounterF < mysql_num_fields($ListF)) {

$stItem=mysql_field_name($ListF,$CounterF);

$CounterF++;

$massField [$CounterF] =$stItem;

echo "<span class=&bsol;"textonlightblue&bsol;"><b>$massField [$CounterF] </b></span><br>";

echo "<input type=&bsol;"text&bsol;" name=&bsol;"". $massField [$CounterF]. "&bsol;" class=&bsol;"textblockBlue&bsol;" value=&bsol;"". $Row [$CounterF-1]. "&bsol;"><br>";

}

echo "<input type=&bsol;"hidden&bsol;" name=&bsol;"t_name&bsol;" value=&bsol;"". $t_name. "&bsol;"class=&bsol;"textblockBlue&bsol;"><br>";

echo "<input type=&bsol;"button&bsol;" name=&bsol;"back&bsol;" style=&bsol;"height: 18&bsol;" class=&bsol;"buttonOrange&bsol;" value=&bsol;"возврат&bsol;" onClick=&bsol;"self. history. back(); &bsol;">|";

echo "<input type=&bsol;"submit&bsol;" name=&bsol;"select&bsol;" style=&bsol;"height: 18&bsol;" class=&bsol;"buttonOrange&bsol;" value=&bsol;"ок&bsol;">";

echo "</form>";

include "body_list_footer. php";

echo "</td></tr></table>";

include "buttom. php"? >

</body>

</html>