Some more cleaning

skala
Julio Montoya 16 years ago
parent 74f90fb13d
commit a9ac9bd86f
  1. 17
      main/exercice/addlimits.php
  2. 42
      main/exercice/exercice.php
  3. 20
      main/exercice/exercise_show.php

@ -46,11 +46,11 @@ api_protect_course_script();
Table definitions Table definitions
@todo: use the Database :: get_course_table functions @todo: use the Database :: get_course_table functions
*/ */
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_REPONSES = Database::get_course_table('quiz_answer'); $TBL_REPONSES = Database::get_course_table('quiz_answer');
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER); $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
$main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
@ -123,13 +123,10 @@ $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')
Display::display_header($nameTools,"Exercise"); Display::display_header($nameTools,"Exercise");
/* /*
-----------------------------------------------------------
Action handling Action handling
-----------------------------------------------------------
*/ */
include('../inc/global.inc.php'); require_once '../inc/global.inc.php';
if (isset($_POST['ok'])) if (isset($_POST['ok'])) {
{
$message = get_lang('TestLimitsAdded'); $message = get_lang('TestLimitsAdded');
Display::display_normal_message($message); Display::display_normal_message($message);
} }

@ -38,9 +38,7 @@ require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'usermanager.lib.php';
/* /*
-----------------------------------------------------------
Constants and variables Constants and variables
-----------------------------------------------------------
*/ */
$is_allowedToEdit = api_is_allowed_to_edit(null,true); $is_allowedToEdit = api_is_allowed_to_edit(null,true);
$is_tutor = api_is_allowed_to_edit(true); $is_tutor = api_is_allowed_to_edit(true);
@ -130,7 +128,7 @@ if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !emp
} }
if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) { if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) {
$id = $_GET['exeid']; //filtered by post-condition $id = intval($_GET['exeid']); //filtered by post-condition
$emailid = $_GET['emailid']; $emailid = $_GET['emailid'];
$test = $_GET['test']; $test = $_GET['test'];
$from = $_SESSION['_user']['mail']; $from = $_SESSION['_user']['mail'];
@ -181,16 +179,15 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
Database::query($query); Database::query($query);
$qry = 'SELECT sum(marks) as tot $qry = 'SELECT sum(marks) as tot
FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.intval($id).' FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.$id.'
GROUP BY question_id'; GROUP BY question_id';
$res = Database::query($qry); $res = Database::query($qry);
$tot = Database::result($res,0,'tot'); $tot = Database::result($res,0,'tot');
//updating also the total weight //updating also the total weight
$totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".Database::escape_string($tot)."', exe_weighting = '".Database::escape_string($total_weighting)."' $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".Database::escape_string($tot)."', exe_weighting = '".Database::escape_string($total_weighting)."'
WHERE exe_Id='".Database::escape_string($id)."'"; WHERE exe_Id='".$id."'";
Database::query($totquery); Database::query($totquery);
$recording_changes = 'INSERT INTO '.$TBL_RECORDING.' ' . $recording_changes = 'INSERT INTO '.$TBL_RECORDING.' ' .
'(exe_id, '(exe_id,
@ -341,10 +338,8 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
//mail($emailid, $subject, $mess,$headers); //mail($emailid, $subject, $mess,$headers);
@api_mail_html($emailid, $emailid, $subject, $mess, $from_name, $from); @api_mail_html($emailid, $emailid, $subject, $mess, $from_name, $from);
if (in_array($origin, array ( if (in_array($origin, array ('tracking_course','user_course'))) {
'tracking_course',
'user_course'
))) {
if (isset ($_POST['lp_item_id']) && isset ($_POST['lp_item_view_id']) && isset ($_POST['student_id']) && isset ($_POST['total_score']) && isset ($_POST['total_time']) && isset ($_POST['totalWeighting'])) { if (isset ($_POST['lp_item_id']) && isset ($_POST['lp_item_view_id']) && isset ($_POST['student_id']) && isset ($_POST['total_score']) && isset ($_POST['total_time']) && isset ($_POST['totalWeighting'])) {
$lp_item_id = $_POST['lp_item_id']; $lp_item_id = $_POST['lp_item_id'];
$lp_item_view_id = $_POST['lp_item_view_id']; $lp_item_view_id = $_POST['lp_item_view_id'];
@ -362,10 +357,10 @@ if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit
//$my_real_lp_item_view_id = Database :: escape_string($_POST['real_lp_item_view_id']); //$my_real_lp_item_view_id = Database :: escape_string($_POST['real_lp_item_view_id']);
$lp_item_id = Database :: escape_string($lp_item_id); $lp_item_id = Database :: escape_string($lp_item_id);
$lp_item_view_id = Database :: escape_string($lp_item_view_id); $lp_item_view_id = Database :: escape_string($lp_item_view_id);
$student_id = Database :: escape_string($student_id); $student_id = Database :: escape_string($student_id);
$totalWeighting = Database :: escape_string($totalWeighting); $totalWeighting = Database :: escape_string($totalWeighting);
/* /*
$sql = "SELECT (view_count) FROM $TBL_LP_ITEM_VIEW $sql = "SELECT (view_count) FROM $TBL_LP_ITEM_VIEW
@ -984,13 +979,12 @@ if ($show == 'test') {
<a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=enable&sec_token=<?php echo$token; ?>&amp;page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" title="<?php echo get_lang('Activate'); ?>" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a> <a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=enable&sec_token=<?php echo$token; ?>&amp;page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" title="<?php echo get_lang('Activate'); ?>" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
<?php <?php
} }
// export qti ... // export qti ...
echo '<a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export.png" border="0" title="IMS/QTI" /></a>'; echo '<a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export.png" border="0" title="IMS/QTI" /></a>';
echo "</td>"; echo "</td>";
echo "</tr>\n"; echo "</tr>";
} else { // student only } else { // student only
?> ?>
<tr> <tr>
@ -1043,10 +1037,7 @@ if ($show == 'test') {
} else { } else {
echo get_lang('CantShowResults'); echo get_lang('CantShowResults');
} }
?></td> echo '</td></tr>';
</tr>
<?php
} }
// skips the last exercise, that is only used to know if we have or not to create a link "Next page" // skips the last exercise, that is only used to know if we have or not to create a link "Next page"
if ($i == $limitExPage) { if ($i == $limitExPage) {
@ -1105,7 +1096,6 @@ if ($show == 'test') {
} }
// prof only // prof only
if ($is_allowedToEdit) { if ($is_allowedToEdit) {
/************/
?> ?>
<tr> <tr>
@ -1151,9 +1141,6 @@ if ($show == 'test') {
} }
} }
?>
<?php
if ($ind == $limitExPage) { if ($ind == $limitExPage) {
break; break;
} }
@ -1168,15 +1155,10 @@ if ($show == 'test') {
} }
} //end if ($origin != 'learnpath') { } //end if ($origin != 'learnpath') {
?> echo '</table>';
</table>
<?php
} }
/*****************************************/
/* Exercise Results (uses tracking tool) */ /* Exercise Results (uses tracking tool) */
/*****************************************/
// if tracking is enabled // if tracking is enabled
if ($_configuration['tracking_enabled'] && ($show == 'result')) { if ($_configuration['tracking_enabled'] && ($show == 'result')) {

@ -1,13 +1,11 @@
<?php //$id: $ <?php //$id: $
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* ** @package chamilo.exercise
* @package chamilo.exercise
* @author Julio Montoya Armas Added switchable fill in blank option added * @author Julio Montoya Armas Added switchable fill in blank option added
* @version $Id: exercise_show.php 22256 2009-07-20 17:40:20Z ivantcholakov $ * @version $Id: exercise_show.php 22256 2009-07-20 17:40:20Z ivantcholakov $
* @package chamilo.exercise * @package chamilo.exercise
* @todo remove the debug code and use the general debug library * @todo remove the debug code and use the general debug library
* @todo use the Database:: functions
* @todo small letters for table variables * @todo small letters for table variables
*/ */
@ -228,16 +226,8 @@ function getFCK(vals,marksid)
</script> </script>
<?php <?php
/* /*
==============================================================================
MAIN CODE MAIN CODE
==============================================================================
*/ */
// Email configuration settings // Email configuration settings
@ -330,14 +320,14 @@ if ($show_results == true ) {
<td style="font-weight:bold" width="10%"><div class="actions-message"><?php echo '&nbsp;'.get_lang('User')?> : </div></td> <td style="font-weight:bold" width="10%"><div class="actions-message"><?php echo '&nbsp;'.get_lang('User')?> : </div></td>
<td><div class="actions-message" width="90%"><?php <td><div class="actions-message" width="90%"><?php
if (isset($_GET['cidReq'])) { if (isset($_GET['cidReq'])) {
$course_code=Security::remove_XSS($_GET['cidReq']); $course_code = Security::remove_XSS($_GET['cidReq']);
} else { } else {
$course_code=api_get_course_id(); $course_code = api_get_course_id();
} }
if (isset($_GET['student'])) { if (isset($_GET['student'])) {
$user_id=Security::remove_XSS($_GET['student']); $user_id = Security::remove_XSS($_GET['student']);
}else { }else {
$user_id=api_get_user_id(); $user_id = api_get_user_id();
} }
$status_info=CourseManager::get_user_in_course_status($user_id,$course_code); $status_info=CourseManager::get_user_in_course_status($user_id,$course_code);

Loading…
Cancel
Save