2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /***********************************************************************/
15 * Get the latest updates of this module
16 * @return list of news, [timestamp]=>
18 function tests_news() {
19 global $db, $enrolled_courses, $system_courses;
22 if ($enrolled_courses == ''){
25 $sql = "SELECT T.test_id, T.course_id, T.title, T.start_date as start_date, UNIX_TIMESTAMP(T.start_date) AS sd, UNIX_TIMESTAMP(T.end_date) AS ed
26 FROM ".TABLE_PREFIX."tests T, ".TABLE_PREFIX."tests_questions_assoc Q
27 WHERE Q.test_id=T.test_id
28 AND T.course_id IN $enrolled_courses
30 ORDER BY T.start_date DESC";
31 $result = mysql_query($sql, $db);
33 while($row = mysql_fetch_assoc($result)){
34 //show only the visible tests
35 if ( ($row['sd'] <= time()) && ($row['ed'] >= time())){
36 $news[] = array('time'=>$row['start_date'],
39 'course'=>$system_courses[$row['course_id']]['title'],
40 'thumb'=>'images/home-tests_sm.png',
41 'link'=>'<a href="bounce.php?course='.$row['course_id'].'&p='.urlencode('mods/_standard/tests/test_intro.php?tid='.$row['test_id']).'" '
42 .(strlen($row['title']) > SUBLINK_TEXT_LEN ? ' title="'.$row['title'].'"' : '') .'>'
43 .validate_length($row['title'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a> <small>('._AT('start_date').':'.AT_DATE('%F %j, %g:%i',$row['start_date']).')</small>');