[svn r16674] fixed revision 16657

skala
Daniel Perales 16 years ago
parent 4c1bac193c
commit 5f5e6411cb
  1. 41
      main/exercice/exercice.php
  2. 27
      main/exercice/exercice_submit.php
  3. 22
      main/exercice/exercise.class.php
  4. 1
      main/install/dokeos_stats.sql
  5. 1
      main/install/migrate-db-1.8.5-1.8.6-pre.sql
  6. 56
      main/work/work.lib.php
  7. 25
      main/work/work.php

@ -896,6 +896,19 @@ if($show == 'test'){
if($_configuration['tracking_enabled'])
{
function convert_date_to_number($default){
// 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp)
$parts = split(' ',$default);
list($d_year,$d_month,$d_day) = split('-',$parts[0]);
list($d_hour,$d_minute,$d_second) = split(':',$parts[1]);
return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year);
}
function format_date_result($date){
if($date == '0000-00-00 00:00:00') return getlang('NoDate');
return substr($date,8,2).'-'.substr($date,5,2).'-'.substr($date,0,4).' '.substr($date,11,2).':'.substr($date,14,4);
}
if($show == 'result')
{
// the form
@ -962,9 +975,9 @@ if($_configuration['tracking_enabled'])
//get all results (ourself and the others) as an admin should see them
//AND exe_user_id <> $_user['user_id'] clause has been removed
$sql="SELECT CONCAT(lastname,' ',firstname),ce.title, te.exe_result ,
te.exe_weighting, UNIX_TIMESTAMP(te.exe_date),te.exe_Id,email, UNIX_TIMESTAMP(te.start_date)
te.exe_weighting, UNIX_TIMESTAMP(te.exe_date),te.exe_Id,email, UNIX_TIMESTAMP(te.start_date),steps_counter
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user
WHERE te.exe_exo_id = ce.id AND te.status != 'incomplete' AND user_id=te.exe_user_id AND te.exe_cours_id='$_cid'";
WHERE te.exe_exo_id = ce.id AND te.status != 'incomplete' AND user_id=te.exe_user_id AND te.exe_cours_id='$_cid' ";
switch ($_GET['column']) {
@ -1031,14 +1044,15 @@ if($_configuration['tracking_enabled'])
$hpsql .= " ORDER BY exe_cours_id ASC, exe_date ASC";
break;
}
//echo $sql;
}
$results=getManyResultsXCol($sql,8);
$results=getManyResultsXCol($sql,9);
$hpresults=getManyResultsXCol($hpsql,5);
$NoTestRes = 0;
$NoHPTestRes = 0;
//Print the results of tests
$lang_nostartdate = get_lang('NoStartDate').' / ';
if(is_array($results))
{
$sizeof = sizeof($results);
@ -1053,21 +1067,32 @@ if($_configuration['tracking_enabled'])
echo '<tr';
if($i%2==0) echo 'class="row_odd"'; else echo 'class="row_even"';
echo '>';
$add_start_date = $lang_nostartdate;
if($is_allowedToEdit || $is_tutor)
{
$user = $results[$i][0];
echo '<td>'.$user.' '.$duration.'</td>';
if($results[$i][7] > 1)
echo '<td>'.ceil((($results[$i][4] - $results[$i][7])/60)).' '.get_lang('min').'</td>';
echo '<td>';
if($results[$i][7] > 1){
echo ceil((($results[$i][4] - $results[$i][7])/60)).' '.get_lang('min');
if($results[$i][8] > 0)echo ' ( '.$results[$i][8].' '.get_lang('Steps').' )';
$add_start_date = format_locale_date('%b %d, %Y %H:%M',$results[$i][7]).' / ';
} else {
echo get_lang('NoLogOfDuration');
}
echo '</td>';
}
echo '<td>'.$test.'</td>';
echo '<td>'.format_locale_date(get_lang('dateTimeFormatLong'),$results[$i][4]).'</td>';
echo '<td>'.$add_start_date.format_locale_date('%b %d, %Y %H:%M',$results[$i][4]).'</td>';//get_lang('dateTimeFormatLong')
echo '<td>'.round(($res/($results[$i][3]!=0?$results[$i][3]:1))*100).'% ('.$res.' / '.$results[$i][3].')</td>';
echo '<td>'.
(($is_allowedToEdit||$is_tutor)?
"<a href='exercise_show.php?user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".get_lang('Edit').'</a>'.' - '.'<a href="exercice.php?cidReq='.htmlentities($_GET['cidReq']).'&show=result&delete=delete&did='.$id.'" onclick="javascript:if(!confirm(\''.sprintf(get_lang('DeleteAttempt'),$user,$dt).'\')) return false;">'.get_lang('Delete').'</a>'
.' - <a href="exercice_history.php?cidReq='.htmlentities($_GET['cidReq']).'&exe_id='.$id.'">'.get_lang('ViewHistory').'</a>'
.' - <a href="exercice_history.php?cidReq='.htmlentities($_GET['cidReq']).'&exe_id='.$id.'">'.get_lang('ViewScoreChangeHistory').'</a>'
:
"<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show').'</a>').'</td>';
echo '</tr>';

@ -37,7 +37,7 @@
* @package dokeos.exercise
* @author Olivier Brouckaert
* @author Julio Montoya multiple fill in blank option added
* @version $Id: exercice_submit.php 16657 2008-11-04 18:06:45Z dperales $
* @version $Id: exercice_submit.php 16674 2008-11-05 23:19:46Z dperales $
*/
@ -164,13 +164,18 @@ if(empty($exerciseType)){
// and load the question list saved too.
if($_configuration['live_exercise_tracking'] == true){
$sql = api_sql_query('SELECT * FROM '.$stat_table.$condition,__FILE__,__LINE__);
// if exist log of entry to this exercise
if(mysql_num_rows($sql) > 0 ){
if($exerciseType == 2){
$getIncomplete = mysql_fetch_array($sql);
$exe_id = $getIncomplete['exe_id'];
if($_SERVER['REQUEST_METHOD']!='POST'){
define('QUESTION_LIST_ALREADY_LOGGED',1);
api_sql_query('UPDATE '.$stat_table.' SET steps_counter = steps_counter + 1'.$condition,__FILE__,__LINE__);
$recorded['questionList'] = explode(',',$getIncomplete['data_tracking']);
//selecting all the answered question from database for
//building the answers array, taking care of handling "multiple answers" behavior.
$sql = api_sql_query('SELECT * FROM '.$exercice_attemp_table.' WHERE exe_id = '.$getIncomplete['exe_id'].' ORDER BY tms ASC',__FILE__,__LINE__);
while($row = mysql_fetch_array($sql)){
@ -189,8 +194,8 @@ if($_configuration['live_exercise_tracking'] == true){
$_SESSION['exerciseResult'] = $recorded['exerciseResult'];
$exerciseType = 2;
$questionNum = count($recorded['exerciseResult']);
$questionNum++;
$questionList = $_SESSION['questionList'] = $recorded['questionList'];
//$questionNum = $questionList[$questionNum];
$questionList = $_SESSION['questionList'] = array_combine(range(1,count($recorded['questionList'])),$recorded['questionList']);
}
}
}else{
@ -318,14 +323,14 @@ $exerciseTitle=$objExercise->selectTitle();
$exerciseDescription=$objExercise->selectDescription();
$exerciseDescription=stripslashes($exerciseDescription);
$exerciseSound=$objExercise->selectSound();
$randomQuestions=$objExercise->isRandom();
//$randomQuestions=$objExercise->isRandom();
$exerciseType=$objExercise->selectType();
if(!isset($_SESSION['questionList']) || $origin == 'learnpath')
{
if($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset'."<br />\n";}
// selects the list of question ID
$questionList = ($randomQuestions?$objExercise->selectRandomList():$objExercise->selectQuestionList());
$questionList = $objExercise->questionList;//($randomQuestions?$objExercise->selectRandomList():$objExercise->selectQuestionList());
// saves the question list into the session
api_session_register('questionList');
if($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";}
@ -515,6 +520,7 @@ if( $exerciseAttempts > 0){
$sql = 'SELECT count(*)
FROM '.Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES).'
WHERE exe_exo_id = '.$quizID.' '.
"and status != 'incomplete' ".
'and exe_user_id = '.$user_id.' '.
"and exe_cours_id = '$course_code'";
$aquery = api_sql_query($sql, __FILE__, __LINE__);
@ -546,14 +552,14 @@ function convert_date_to_number($default){
$limit_time_exists = (($Exe_starttime!='0000-00-00 00:00:00')||($Exe_endtime!='0000-00-00 00:00:00'))? true : false;
if($limit_time_exists){
$exercise_start_time = convert_date_to_number($Exe_starttime);
//$exercise_end_time = convert_date_to_number($Exe_endtime);
$exercise_end_time = convert_date_to_number($Exe_endtime);
$time_now = convert_date_to_number(date('Y-m-d H:i:s'));
$permission_to_start = (($time_now - $exercise_start_time)>0)?true:false;
//if($_SERVER['REQUEST_METHOD']!='POST')$exercise_timeover = (($time_now - $exercise_end_time)>0)?true:false;
if($permission_to_start == false ){ //|| $exercise_timeover == true
if($_SERVER['REQUEST_METHOD']!='POST')$exercise_timeover = (($time_now - $exercise_end_time)>0)?true:false;
if($permission_to_start == false || $exercise_timeover = true){ //
if(!api_is_allowed_to_edit()){
$message_warning = ($permission_to_start == false)? get_lang('ExerciseNoStartedYet') : get_lang('ReachedTimeLimit') ;
Display::display_warning_message(sprintf($message_warning,$exerciseTitle,$exerciseAttempts));
$message_warning = ($permission_to_start == false)? get_lang('ExerciseNoStartedYet').' %s' : get_lang('ReachedTimeLimit') ;
Display::display_warning_message(sprintf($message_warning,(($permission_to_start == false)?$Exe_starttime:$Exe_endttime)));
Display::display_footer();
exit;
} else {
@ -738,4 +744,5 @@ else
if ($origin != 'learnpath') { //so we are not in learnpath tool
Display::display_footer();
}
//var_dump($questionList);
?>

@ -25,7 +25,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: exercise.class.php 16657 2008-11-04 18:06:45Z dperales $
* @version $Id: exercise.class.php 16674 2008-11-05 23:19:46Z dperales $
*/
@ -75,6 +75,8 @@ class Exercise
function read($id)
{
global $_course;
global $_configuration;
global $questionList;
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -114,20 +116,18 @@ class Exercise
$this->questionList[$object->question_order]=$object->question_id;
}
if($this->random==1){
shuffle($this->questionList);
if($this->random > 0){
$this->questionList = $this->selectRandomList();
}
global $_configuration;
global $questionList;
//overload questions list with recorded questions list
//load questions only for exercises of type 'one question per page'
//this is needed only is there is no questions
//
if($this->type == 2 && $_configuration['live_exercise_tracking']==true && $_SERVER['REQUEST_METHOD']!='POST')
if($this->type == 2 && $_configuration['live_exercise_tracking']==true && $_SERVER['REQUEST_METHOD']!='POST' && defined('QUESTION_LIST_ALREADY_LOGGED'))
{
if(!empty($_SESSION['questionList']))$this->questionList = $questionList;
//if(empty($_SESSION['questionList']))
$this->questionList = $questionList;
}
return true;
}
@ -272,7 +272,11 @@ class Exercise
*/
function selectRandomList()
{
return $this->questionList;
$nbQuestions = $this->selectNbrQuestions();
$temp_list = $this->questionList;
shuffle($temp_list);
return array_combine(range(1,$nbQuestions),$temp_list);
$nbQuestions = $this->selectNbrQuestions();
//Not a random exercise, or if there are not at least 2 questions

@ -107,6 +107,7 @@ CREATE TABLE track_e_exercices (
ALTER TABLE track_e_exercices ADD status varchar(20) NOT NULL default '';
ALTER TABLE track_e_exercices ADD data_tracking text NOT NULL default '';
ALTER TABLE track_e_exercices ADD start_date datetime NOT NULL default '0000-00-00 00:00:00';
ALTER TABLE track_e_exercices ADD steps_counter SMALLINT UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD session_id SMALLINT UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;

@ -41,6 +41,7 @@ CREATE TABLE gradebook_linkeval_log (id int NOT NULL auto_increment,id_linkeval_
-- xxSTATSxx
ALTER TABLE track_e_exercices ADD status varchar(20) NOT NULL default '';
ALTER TABLE track_e_exercices ADD data_tracking text NOT NULL default '';
ALTER TABLE track_e_exercices ADD steps_counter SMALLINT UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD start_date datetime NOT NULL default '0000-00-00 00:00:00';
ALTER TABLE track_e_exercices ADD session_id SMALLINT UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;

@ -219,6 +219,50 @@ function display_user_link($user_id, $name='')
}
}
function convert_date_to_number($default){
// 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp)
$parts = split(' ',$default);
list($d_year,$d_month,$d_day) = split('-',$parts[0]);
list($d_hour,$d_minute,$d_second) = split(':',$parts[1]);
return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year);
}
/*
* converts 1-9 to 01-09
*/
function two_digits($number){
$number = (int)$number;
return ($number < 10) ? '0'.$number : $number;
}
/*
* converts 2008-10-06 12:45:00 to -> array($data'year'=>2008,$data'month'=>10 etc...)
*/
function convert_date_to_array($date,$group){
$parts = split(' ',$date);
list($data[$group.'[year]'],$data[$group.'[month]'],$data[$group.'[day]']) = split('-',$parts[0]);
list($data[$group.'[hour]'],$data[$group.'[minute]']) = split(':',$parts[1]);
return $data;
}
function get_date_from_group($group){
return $_POST[$group]['year'].'-'.two_digits($_POST[$group]['month']).'-'.two_digits($_POST[$group]['day']).' '.two_digits($_POST[$group]['hour']).':'.two_digits($_POST[$group]['minute']).':00';
}
function create_group_date_select($prefix=''){
$minute = range(10,59);
$d_year=date('Y');
array_unshift($minute,'00','01','02','03','04','05','06','07','08','09');
$group_name[] = FormValidator :: createElement('select',$prefix.'year','',array($d_year=>$d_year,$d_year+1=>$d_year+1));
$group_name[] = FormValidator :: createElement('select',$prefix.'month','',array_combine(range(1,12),array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre')));
$group_name[] = FormValidator :: createElement('select',$prefix.'day','',array_combine(range(1,31),range(1,31)));
$group_name[] = FormValidator :: createElement('select',$prefix.'hour','',array_combine(range(1,24),range(1,24)));
$group_name[] = FormValidator :: createElement('select',$prefix.'minute','',$minute);
return $group_name;
}
/**
@ -448,6 +492,7 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$form_folder -> addGroup(create_group_date_select(),'ends',get_lang('Ends_At'));
}
$form_folder -> addRule (array('expires','ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
}
else
{
@ -487,8 +532,6 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$form_folder -> addElement('html','</div>');
}
$group_name[] = FormValidator :: createElement('submit','submit_edit_dir',get_lang('Ok'));
$form_folder -> addGroup($group_name,'my_group');
$form_folder -> addGroupRule('my_group',get_lang('ThisFieldIsRequired'),'required');
@ -646,10 +689,9 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$class='';
}
if(defined('IS_ASSIGNMENT')):
if(true || defined('IS_ASSIGNMENT')):
$add_string = '';
if($work->qualification=='')
if($work->qualificator_id==0)
$qualification_string = ' / <b style="color:orange">'.get_lang('NotRevised').'<b>';
else
$qualification_string = ' / <b style="color:blue">'.get_lang('Qualification').': '.$work->qualification.'<b>';
@ -662,8 +704,8 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$url = implode("/", array_map("rawurlencode", explode("/", $work->url)));
$row[]= build_document_icon_tag('file',$work->url);
$row[]= '<a href="'.$currentCourseRepositoryWeb.$url.'"'.$class.'><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Save').'" />'.$work->title.'</a><br />'.$work->description;
$row[]= display_user_link($user_id,$work->author);// $work->author;
$row[]= date_to_str_ago($work->sent_date).'<br><span class="dropbox_date">'.$work->sent_date.'</span>';
$row[]= display_user_link($user_id,$work->author).$qualification_string;// $work->author;
$row[]= date_to_str_ago($work->sent_date).$add_string.'<br><span class="dropbox_date">'.$work->sent_date.'</span>';
if( $is_allowed_to_edit && !(api_is_course_coach() && $work->session_id!=$_SESSION['id_session']))
{

@ -27,7 +27,7 @@
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University - ability for course admins to specify wether uploaded documents are visible or invisible by default.
* @author Roan Embrechts, code refactoring and virtual course support
* @author Frederic Vauthier, directories management
* @version $Id: work.php 16657 2008-11-04 18:06:45Z dperales $
* @version $Id: work.php 16674 2008-11-05 23:19:46Z dperales $
*
* @todo refactor more code into functions, use quickforms, coding standards, ...
*/
@ -637,10 +637,11 @@ if (api_is_allowed_to_edit(false,true))
{
function get_date_from_select($prefix){
return $_POST[$prefix.'_year'].'-'.$_POST[$prefix.'_month'].'-'.$_POST[$prefix.'_day'].' '.$_POST[$prefix.'_hour'].':'.$_POST[$prefix.'_minute'].':00';
return $_POST[$prefix]['Y'].'-'.$_POST[$prefix]['M'].'-'.$_POST[$prefix]['d'].' '.$_POST[$prefix]['H'].':'.$_POST[$prefix]['i'].':00';
//return $_POST[$prefix.'_year'].'-'.$_POST[$prefix.'_month'].'-'.$_POST[$prefix.'_day'].' '.$_POST[$prefix.'_hour'].':'.$_POST[$prefix.'_minute'].':00';
}
$fexpire= get_date_from_select('expires');
$fend = get_date_from_select('ends');
$fexpire= get_date_from_select('expires_on');
$fend = get_date_from_select('ends_on');
//create the directory
@ -693,8 +694,8 @@ if (api_is_allowed_to_edit(false,true))
{
$TSTDPUBASG=Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$sql_add_homework = "INSERT INTO ".$TSTDPUBASG." SET " .
"expires_on = '".(($_POST['type1']==1) ? get_date_from_select('expires') : '0000-00-00 00:00:00'). "',
ends_on = '".(($_POST['type2']==1) ? get_date_from_select('ends') : '0000-00-00 00:00:00')."',
"expires_on = '".(($_POST['type1']==1) ? $fexpire : '0000-00-00 00:00:00'). "',
ends_on = '".(($_POST['type2']==1) ? $fend : '0000-00-00 00:00:00')."',
add_to_calendar = '".(int)$_POST['add_to_calendar']."',
enable_qualification = '".(int)$_POST['enable_calification']."',
publication_id = '".$id."'";
@ -1198,6 +1199,10 @@ if($is_special > 0):
$sql = api_sql_query('SELECT * FROM '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT).' WHERE publication_id = '.(string)$publication['id'].' LIMIT 1',__FILE__,__LINE__);
$homework = mysql_fetch_array($sql);
if(!empty($publication['description'])){
Display :: display_normal_message($publication['description']);
}
if($homework['expires_on']!='0000-00-00 00:00:00' || $homework['ends_on']!='0000-00-00 00:00:00'):
$time_now = convert_date_to_number(date('Y-m-d H:i:s'));
$time_expires = convert_date_to_number($homework['expires_on']);
@ -1209,10 +1214,6 @@ if($is_special > 0):
define('ASSIGNMENT_EXPIRES',$time_expires);
if(!empty($publication['description'])){
Display :: display_normal_message($publication['description']);
}
if($has_ended) {
Display :: display_error_message(get_lang('EndDateAlreadyPassed').' '.$homework['ends_on']);
display_action_links($cur_dir_path, $always_show_tool_options,true);
@ -1223,6 +1224,8 @@ if($is_special > 0):
Display :: display_normal_message(get_lang('ExpiryDateToSendWorkIs').' '.$homework['expires_on']);
display_action_links($cur_dir_path, $always_show_tool_options, $always_show_upload_form);
}
else:
display_action_links($cur_dir_path, $always_show_tool_options, $always_show_upload_form);
endif;
else:
display_action_links($cur_dir_path, $always_show_tool_options, $always_show_upload_form);
@ -1251,7 +1254,7 @@ if ($is_course_member)
require_once (api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php');
require_once (api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php');
$form = new FormValidator('form', 'POST', api_get_self() . "?curdirpath=" . Security :: rtrim(remove_XSS($cur_dir_path),'/') . "&origin=$origin", '', 'enctype="multipart/form-data"');
$form = new FormValidator('form', 'POST', api_get_self() . "?curdirpath=" . Security :: remove_XSS(rtrim($cur_dir_path,'/')) . "&origin=$origin", '', 'enctype="multipart/form-data"');
if (!empty ($error_message))
Display :: display_error_message($error_message);

Loading…
Cancel
Save