Skip to content

Commit

Permalink
12.0.006 (2013-04-08)
Browse files Browse the repository at this point in the history
- Fixing some SQL queries and result values.
  • Loading branch information
Nicola Asuni committed Apr 8, 2013
1 parent 71f898a commit 3385360
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.TXT
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
12.0.006 (2013-04-08)
- Fixing some SQL queries and result values.

12.0.005 (2013-04-05)
- Some SQL queries were fixed for PostgreSQL compatibility.
- TCPDF Library was updated.
Expand Down
4 changes: 2 additions & 2 deletions README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ FOR ANY COMMERCIAL USAGE PLEASE CONTACT: [email protected]

Name: TCExam

Version: 12.0.005
Version: 12.0.006

Release date: 2013-04-05
Release date: 2013-04-08

Author:
Nicola Asuni
Expand Down
41 changes: 20 additions & 21 deletions admin/code/tce_show_result_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//============================================================+
// File name : tce_show_result_user.php
// Begin : 2004-06-10
// Last Update : 2012-12-18
// Last Update : 2013-04-08
//
// Description : Display test results for specified user.
//
Expand All @@ -18,7 +18,7 @@
// [email protected]
//
// License:
// Copyright (C) 2004-2012 Nicola Asuni - Tecnick.com LTD
// Copyright (C) 2004-2013 Nicola Asuni - Tecnick.com LTD
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -97,11 +97,11 @@
$changecategory = 1;
}

if(isset($_POST['lock'])) {
if (isset($_POST['lock'])) {
$menu_mode = 'lock';
} elseif(isset($_POST['unlock'])) {
} elseif (isset($_POST['unlock'])) {
$menu_mode = 'unlock';
} elseif(isset($_POST['extendtime'])) {
} elseif (isset($_POST['extendtime'])) {
$menu_mode = 'extendtime';
}

Expand All @@ -125,10 +125,10 @@

case 'forcedelete':{
F_stripslashes_formfields(); // Delete
if($forcedelete == $l['w_delete']) { //check if delete button has been pushed (redundant check)
if ($forcedelete == $l['w_delete']) { //check if delete button has been pushed (redundant check)
$sql = 'DELETE FROM '.K_TABLE_TEST_USER.'
WHERE testuser_id='.$testuser_id.'';
if(!$r = F_db_query($sql, $db)) {
if (!$r = F_db_query($sql, $db)) {
F_display_db_error();
} else {
$testuser_id = false;
Expand All @@ -144,7 +144,7 @@
$sqlu = 'UPDATE '.K_TABLE_TEST_USER.'
SET testuser_creation_time=\''.date(K_TIMESTAMP_FORMAT, F_getTestStartTime($testuser_id) + (K_EXTEND_TIME_MINUTES * K_SECONDS_IN_MINUTE)).'\'
WHERE testuser_id='.$testuser_id.'';
if(!$ru = F_db_query($sqlu, $db)) {
if (!$ru = F_db_query($sqlu, $db)) {
F_display_db_error();
} else {
F_print_error('MESSAGE', $l['m_updated']);
Expand All @@ -157,7 +157,7 @@
$sqlu = 'UPDATE '.K_TABLE_TEST_USER.'
SET testuser_status=4
WHERE testuser_id='.$testuser_id.'';
if(!$ru = F_db_query($sqlu, $db)) {
if (!$ru = F_db_query($sqlu, $db)) {
F_display_db_error();
} else {
F_print_error('MESSAGE', $l['m_updated']);
Expand All @@ -170,7 +170,7 @@
$sqlu = 'UPDATE '.K_TABLE_TEST_USER.'
SET testuser_status=1
WHERE testuser_id='.$testuser_id.'';
if(!$ru = F_db_query($sqlu, $db)) {
if (!$ru = F_db_query($sqlu, $db)) {
F_display_db_error();
} else {
F_print_error('MESSAGE', $l['m_updated']);
Expand All @@ -189,16 +189,16 @@
if (($test_id == 0) AND ($testuser_id == 0)) {
// select default test ID
$sql = F_select_executed_tests_sql().' LIMIT 1';
if($r = F_db_query($sql, $db)) {
if($m = F_db_fetch_array($r)) {
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
$test_id = $m['test_id'];
}
} else {
F_display_db_error();
}
}

if($formstatus) {
if ($formstatus) {
if ((isset($changecategory) AND ($changecategory > 0)) OR empty($testuser_id)) {
$sql = 'SELECT testuser_id, testuser_test_id, testuser_user_id, testuser_creation_time, testuser_status, SUM(testlog_score) AS test_score, MAX(testlog_change_time) AS test_end_time
FROM '.K_TABLE_TEST_USER.', '.K_TABLE_TESTS_LOGS.'
Expand Down Expand Up @@ -242,8 +242,8 @@
// get test basic score
$test_basic_score = 1;
$sql = 'SELECT test_score_right, test_duration_time FROM '.K_TABLE_TESTS.' WHERE test_id='.intval($test_id).'';
if($r = F_db_query($sql, $db)) {
if($m = F_db_fetch_array($r)) {
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
$test_basic_score = $m['test_score_right'];
$test_duration_time = $m['test_duration_time'];
}
Expand All @@ -265,10 +265,10 @@
echo '<input type="hidden" name="changecategory" id="changecategory" value="" />'.K_NEWLINE;
echo '<select name="test_id" id="test_id" size="0" onchange="document.getElementById(\'form_resultuser\').changecategory.value=1;document.getElementById(\'form_resultuser\').submit()" title="'.$l['h_test'].'">'.K_NEWLINE;
$sql = F_select_executed_tests_sql();
if($r = F_db_query($sql, $db)) {
if ($r = F_db_query($sql, $db)) {
while($m = F_db_fetch_array($r)) {
echo '<option value="'.$m['test_id'].'"';
if($m['test_id'] == $test_id) {
if ($m['test_id'] == $test_id) {
echo ' selected="selected"';
}
echo '>'.substr($m['test_begin_time'], 0, 10).' '.htmlspecialchars($m['test_name'], ENT_NOQUOTES, $l['a_meta_charset']).'</option>'.K_NEWLINE;
Expand Down Expand Up @@ -345,16 +345,15 @@
}
$time_diff = gmdate('H:i:s', $time_diff);
echo getFormDescriptionLine($l['w_test_time'].':', $l['w_test_time'], $time_diff);

$passmsg = '';
if ($teststat['testinfo']['test_score_threshold'] > 0) {
if ($teststat['user_score'] >= $teststat['testinfo']['test_score_threshold']) {
if (isset($teststat['testinfo']['user_score']) AND ($teststat['testinfo']['user_score'] >= $teststat['testinfo']['test_score_threshold'])) {
$passmsg = ' - '.$l['w_passed'];
} else {
$passmsg = ' - '.$l['w_not_passed'];
}
}
$score_all = $teststat['qstats']['average_score'].' / '.$teststat['testinfo']['test_max_score'].' ('.round(100 * $teststat['qstats']['average_score'] / $teststat['testinfo']['test_max_score']).'%)'.$passmsg;
$score_all = $teststat['testinfo']['user_score'].' / '.$teststat['testinfo']['test_max_score'].' ('.round(100 * $teststat['testinfo']['user_score'] / $teststat['testinfo']['test_max_score']).'%)'.$passmsg;
echo getFormDescriptionLine($l['w_score'].':', $l['h_score_total'], $score_all);

$score_right_all = $teststat['qstats']['right'].' / '.$teststat['qstats']['recurrence'].' ('.$teststat['qstats']['right_perc'].'%)';
Expand All @@ -381,7 +380,7 @@
if (($test_id > 0) AND ($user_id > 0) AND ($testuser_id > 0)) {
F_submit_button('delete', $l['w_delete'], $l['h_delete']);

if($testuser_status < 4) {
if ($testuser_status < 4) {
// lock test button
F_submit_button('lock', $l['w_lock'], $l['w_lock']);
} else {
Expand Down
10 changes: 5 additions & 5 deletions public/code/tce_show_result_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//============================================================+
// File name : tce_show_result_user.php
// Begin : 2004-06-10
// Last Update : 2012-12-30
// Last Update : 2013-04-08
//
// Description : Display test results to the current user.
//
Expand All @@ -18,7 +18,7 @@
// [email protected]
//
// License:
// Copyright (C) 2004-2012 Nicola Asuni - Tecnick.com LTD
// Copyright (C) 2004-2013 Nicola Asuni - Tecnick.com LTD
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -87,7 +87,7 @@
} else {
F_display_db_error();
}
if ($user_id != $checkid) {echo "HUUUU DEBUG"; exit;//DEBUG
if ($user_id != $checkid) {
header('Location: index.php'); //redirect browser to public main page
exit;
}
Expand Down Expand Up @@ -129,13 +129,13 @@

$passmsg = '';
if ($teststat['testinfo']['test_score_threshold'] > 0) {
if (isset($teststat['user_score']) AND ($teststat['user_score'] >= $teststat['testinfo']['test_score_threshold'])) {
if (isset($teststat['testinfo']['user_score']) AND ($teststat['testinfo']['user_score'] >= $teststat['testinfo']['test_score_threshold'])) {
$passmsg = ' - '.$l['w_passed'];
} else {
$passmsg = ' - '.$l['w_not_passed'];
}
}
$score_all = $teststat['qstats']['average_score'].' / '.$teststat['testinfo']['test_max_score'].' ('.round(100 * $teststat['qstats']['average_score'] / $teststat['testinfo']['test_max_score']).'%)'.$passmsg;
$score_all = $teststat['testinfo']['user_score'].' / '.$teststat['testinfo']['test_max_score'].' ('.round(100 * $teststat['testinfo']['user_score'] / $teststat['testinfo']['test_max_score']).'%)'.$passmsg;
echo getFormDescriptionLine($l['w_score'].':', $l['h_score_total'], $score_all);

$score_right_all = $teststat['qstats']['right'].' / '.$teststat['qstats']['recurrence'].' ('.$teststat['qstats']['right_perc'].'%)';
Expand Down
2 changes: 1 addition & 1 deletion shared/code/tce_functions_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//============================================================+
// File name : tce_functions_test.php
// Begin : 2004-05-28
// Last Update : 2013-04-03
// Last Update : 2013-04-08
//
// Description : Functions to handle test generation, status
// and user access.
Expand Down
31 changes: 13 additions & 18 deletions shared/code/tce_functions_test_stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//============================================================+
// File name : tce_functions_test_stats.php
// Begin : 2004-06-10
// Last Update : 2013-04-05
// Last Update : 2013-04-08
//
// Description : Statistical functions for test results.
//
Expand Down Expand Up @@ -93,11 +93,9 @@ function F_getUserTestTotals($test_id, $user_id=0, $testuser_id=0) {
AND testuser_test_id='.$test_id.'
AND testuser_user_id='.$user_id.'
AND testuser_status>0
GROUP BY testlog_id, testuser_id, testuser_creation_time, testuser_status, testuser_comment
ORDER BY testlog_id
LIMIT 1';
if($ru = F_db_query($sqlu, $db)) {
if($mu = F_db_fetch_array($ru)) {
GROUP BY testuser_id, testuser_creation_time, testuser_status, testuser_comment';
if ($ru = F_db_query($sqlu, $db)) {
if ($mu = F_db_fetch_array($ru)) {
$data['testuser_id'] = $mu['testuser_id'];
$data['user_score'] = $mu['total_score'];
$data['user_test_start_time'] = $mu['testuser_creation_time'];
Expand Down Expand Up @@ -283,8 +281,7 @@ function F_getRawTestStat($test_id, $group_id=0, $user_id=0, $startdate=0, $endd
}
$sql .= ' GROUP BY module_id, subject_id, question_id, module_name, subject_name, subject_description, question_description';
if (($user_id > 0) AND ($testuser_id > 0)) {
$sql .= ', testlog_score, testlog_user_ip, testlog_display_time, testlog_change_time, testlog_reaction_time, testlog_answer_text, question_type, question_explanation, testlog_id';
$sql .= ' ORDER BY testlog_id';
$sql .= ', testlog_score, testlog_user_ip, testlog_display_time, testlog_change_time, testlog_reaction_time, testlog_answer_text, question_type, question_explanation';
} else {
$sql .= ' ORDER BY module_name, subject_name, question_description';
}
Expand Down Expand Up @@ -797,9 +794,10 @@ function F_printTestResultStat($data, $nextorderdir, $order_field, $filter, $pub
$ret .= '<td style="text-align:center;">'.$tu['testuser_creation_time'].'</td>'.K_NEWLINE;
//$ret .= '<td style="text-align:center;">'.$tu['testuser_end_time'].'</td>'.K_NEWLINE;
$ret .= '<td style="text-align:center;">'.$tu['time_diff'].'</td>'.K_NEWLINE;
if($tu['passmsg']) {
$passmsg = '';
if ($tu['passmsg'] === true) {
$passmsg = ' title="'.$l['w_passed'].'" style="background-color:#BBFFBB;"';
} else {
} elseif ($tu['passmsg'] === false) {
$passmsg = ' title="'.$l['w_not_passed'].'" style="background-color:#FFBBBB;"';
}
if ($pubmode) {
Expand Down Expand Up @@ -902,7 +900,7 @@ function F_printUserTestStat($testuser_id) {
AND question_subject_id=subject_id
AND subject_module_id=module_id
ORDER BY testlog_id';
if($r = F_db_query($sql, $db)) {
if ($r = F_db_query($sql, $db)) {
$ret .= '<ol class="question">'.K_NEWLINE;
while($m = F_db_fetch_array($r)) {
$ret .= '<li>'.K_NEWLINE;
Expand Down Expand Up @@ -950,7 +948,7 @@ function F_printUserTestStat($testuser_id) {
WHERE logansw_answer_id=answer_id
AND logansw_testlog_id=\''.$m['testlog_id'].'\'
ORDER BY logansw_order';
if($ra = F_db_query($sqla, $db)) {
if ($ra = F_db_query($sqla, $db)) {
while($ma = F_db_fetch_array($ra)) {
$ret .= '<li>';
if ($m['question_type'] == 4) {
Expand Down Expand Up @@ -1113,14 +1111,11 @@ function F_getAllUsersTestStat($test_id, $group_id=0, $user_id=0, $startdate=0,
$time_diff = strtotime($mr['testuser_end_time']) - strtotime($mr['testuser_creation_time']); //sec
}
$data['testuser']['\''.$mr['testuser_id'].'\'']['time_diff'] = gmdate('H:i:s', $time_diff);

$passmsg = '';
$passmsg = false;
if ($usrtestdata['test_score_threshold'] > 0) {
if ($usrtestdata['user_score'] >= $usrtestdata['test_score_threshold']) {
$passmsg = true;
$passed++;
} else {
$passmsg = false;
}
} elseif ($usrtestdata['user_score'] > $halfscore) {
$passmsg = true;
Expand Down Expand Up @@ -1200,7 +1195,7 @@ function F_lockUserTest($test_id, $user_id) {
WHERE testuser_test_id='.$test_id.'
AND testuser_user_id='.$user_id.'
AND testuser_status<4';
if(!$r = F_db_query($sql, $db)) {
if (!$r = F_db_query($sql, $db)) {
F_display_db_error();
}
}
Expand Down Expand Up @@ -1235,7 +1230,7 @@ function F_getTestIDs($test_id, $user_id, $filter='test_results_to_users') {
$test_id = intval($test_id);
$user_id = intval($user_id);
$sql = 'SELECT test_id FROM '.K_TABLE_TESTS.' WHERE test_id IN (SELECT DISTINCT testuser_test_id FROM '.K_TABLE_TEST_USER.' WHERE testuser_user_id='.intval($user_id).' AND testuser_status>0) AND '.$filter.'=1';
if($r = F_db_query($sql, $db)) {
if ($r = F_db_query($sql, $db)) {
while($m = F_db_fetch_assoc($r)) {
$str .= ','.$m['test_id'];
}
Expand Down
2 changes: 1 addition & 1 deletion shared/config/tce_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/**
* TCExam version (do not change).
*/
define ('K_TCEXAM_VERSION', '12.0.005');
define ('K_TCEXAM_VERSION', '12.0.006');

/**
* 2-letters code for default language.
Expand Down

0 comments on commit 3385360

Please sign in to comment.