[svn r16657] integration of project dokeosla-usil into dokeos:FS#3159, also fixed bug of revision 16577, refactored code of revision 16306

skala
Daniel Perales 17 years ago
parent a6abdb402b
commit dfb5bfba3b
  1. 225
      main/exercice/exercice.php
  2. 127
      main/exercice/exercice_submit.php
  3. 96
      main/exercice/exercise.class.php
  4. 14
      main/exercice/exercise_result.php
  5. 25
      main/inc/lib/add_course.lib.inc.php
  6. 4
      main/inc/lib/database.lib.php
  7. 43
      main/inc/lib/events.lib.inc.php
  8. 15
      main/install/dokeos_stats.sql
  9. 16
      main/install/migrate-db-1.8.5-1.8.6-pre.sql
  10. 153
      main/work/work.lib.php
  11. 330
      main/work/work.php

@ -927,100 +927,26 @@ if($_configuration['tracking_enabled'])
echo '<br /><br />';
}
switch ($_GET['column']) {
case 'username':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=1';
}
else
{
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
}
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
break;
case 'exercisename':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=1';
}
else
{
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
}
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
break;
case 'date':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=1';
}
else
{
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
}
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
break;
case '':
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
break;
}
switch ($_GET['column']) {
case 'username':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=1';
}
else
{
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
}
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
break;
case 'exercisename':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=1';
}
else
{
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
}
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
break;
case 'date':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=1';
}
else
{
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
}
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
break;
case '':
$urlusername = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=username&direction=0';
$urlexercisename = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=exercisename&direction=0';
$urldate = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&column=date&direction=0';
break;
}
?>
$order_like = (int)$_GET['direction'];
if($order_like != 0 && $order_like != 1) $order_like = 0;
$new_orientation = $order_like ^ 1;
$orientation = array();
$orientation[0] = 'ASC'; // default order
$orientation[1] = 'DESC';
$ordering = $orientation[$order_like];
$main_url = $_SESSION['checkDokeosURL'].'main/exercice/exercice.php?'.api_get_cidreq().'&show=result&';
$urlusername = $main_url.'column=username&direction='.(($_GET['column']=='username') ? $new_orientation : 0);
$urlexercisename = $main_url.'column=exercisename&direction='.(($_GET['column']=='exercisename') ? $new_orientation : 0);
$urldate = $main_url.'column=date&direction='.(($_GET['column']=='date') ? $new_orientation : 0);
?>
<table class="data_table">
<tr class="row_odd">
<?php if($is_allowedToEdit || $is_tutor): ?>
<th><a href="<?php echo $urlusername; ?>"><?php echo get_lang("User"); ?></a></th><?php endif; ?>
<th><a href="<?php echo $urlusername; ?>"><?php echo get_lang("User"); ?></a></th>
<th><?php echo get_lang('Duration'); ?></th>
<?php endif; ?>
<th><a href="<?php echo $urlexercisename; ?>"><?php echo get_lang("Exercice"); ?></a></th>
<th><a href="<?php echo $urldate; ?>"><?php echo get_lang("Date"); ?></a></th>
<th><?php echo get_lang("Result"); ?></th>
@ -1030,49 +956,29 @@ if($_configuration['tracking_enabled'])
</tr>
<?php
if($is_allowedToEdit)
{
//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
te.exe_weighting, UNIX_TIMESTAMP(te.exe_date),te.exe_Id,email, UNIX_TIMESTAMP(te.start_date)
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user
WHERE te.exe_exo_id = ce.id 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']) {
case 'username':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$sql .= " order by lastname ASC, firstname ASC,ce.title ASC, te.exe_date ASC";
}
else
{
$sql .= " order by lastname DESC, firstname ASC, ce.title ASC, te.exe_date ASC";
}
$sql .= ' order by lastname '.$ordering.', firstname ASC, ce.title ASC, te.exe_date ASC';
break;
case 'exercisename':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$sql .= " order by ce.title ASC, te.exe_date ASC, lastname ASC, firstname ASC";
}
else
{
$sql .= " order by ce.title DESC, te.exe_date ASC, lastname ASC, firstname ASC";
}
$sql .= ' order by ce.title '.$ordering.', te.exe_date ASC, lastname ASC, firstname ASC';
break;
case 'date':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$sql .= " order by te.exe_date ASC,ce.title ASC, lastname ASC, firstname ASC";
}
else
{
$sql .= " order by te.exe_date DESC,ce.title ASC, lastname ASC, firstname ASC";
}
$sql .= ' order by te.exe_date '.$ordering.',ce.title ASC, lastname ASC, firstname ASC';
break;
case '':
$sql .= " ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_dateASC";
$sql .= ' ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC';
break;
}
$hpsql="SELECT CONCAT(tu.lastname,' ',tu.firstname), tth.exe_name,
@ -1081,37 +987,16 @@ if($_configuration['tracking_enabled'])
WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '".$_cid."'";
switch ($_GET['column']) {
case 'username':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$hpsql .= " order by tu.lastname ASC, tu.firstname ASC,tth.exe_date ASC,tth.exe_name ASC";
}
else
{
$hpsql .= " order by tu.lastname DESC, tu.firstname ASC, tth.exe_date ASC,tth.exe_name ASC";
}
$hpsql .= ' order by tu.lastname '.$ordering.', tu.firstname ASC,tth.exe_date ASC,tth.exe_name ASC';
break;
case 'exercisename':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$hpsql .= " order by tth.exe_name ASC, tth.exe_date ASC, tu.lastname ASC, tu.firstname ASC";
}
else
{
$hpsql .= " order by tth.exe_name DESC, tth.exe_date ASC, tu.lastname ASC, tu.firstname ASC";
}
$hpsql .= ' order by tth.exe_name '.$ordering.', tth.exe_date ASC, tu.lastname ASC, tu.firstname ASC';
break;
case 'date':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$hpsql .= " order by tth.exe_date ASC,tth.exe_name ASC, tu.lastname ASC, tu.firstname ASC";
}
else
{
$hpsql .= " order by tth.exe_date DESC,tth.exe_name ASC, tu.lastname ASC, tu.firstname ASC";
}
$hpsql .= ' order by tth.exe_date '.$ordering.',tth.exe_name ASC, tu.lastname ASC, tu.firstname ASC';
break;
case '':
$hpsql .= " ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
$hpsql .= ' ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC';
break;
}
}
@ -1120,27 +1005,13 @@ if($_configuration['tracking_enabled'])
$_uid = api_get_user_id();
$sql="SELECT '',ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date),te.exe_id
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te
WHERE te.exe_exo_id = ce.id AND te.exe_user_id='".$_uid."' AND te.exe_cours_id='$_cid'";
WHERE te.exe_exo_id = ce.id AND te.exe_user_id='".$_uid."'AND te.status != 'incomplete' AND te.exe_cours_id='$_cid'";
switch ($_GET['column']) {
case 'exercisename':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$sql .= " order by ce.title ASC, te.exe_date ASC";
}
else
{
$sql .= " order by ce.title DESC, te.exe_date ASC";
}
$sql .= " order by ce.title $ordering, te.exe_date ASC";
break;
case 'date':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$sql .= " order by te.exe_date ASC,ce.title ASC";
}
else
{
$sql .= " order by te.exe_date DESC,ce.title ASC";
}
$sql .= " order by te.exe_date $ordering,ce.title ASC";
break;
case '':
$sql .= " ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC";
@ -1151,24 +1022,10 @@ if($_configuration['tracking_enabled'])
WHERE exe_user_id = '".$_uid."' AND exe_cours_id = '".$_cid."'";
switch ($_GET['column']) {
case 'exercisename':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$hpsql .= " order by exe_name ASC, exe_date ASC";
}
else
{
$hpsql .= " order by exe_name DESC, exe_date ASC";
}
$hpsql .= " order by exe_name $ordering, exe_date ASC";
break;
case 'date':
if ($_GET['direction'] == '' || $_GET['direction'] == 0)
{
$hpsql .= " order by exe_date ASC,exe_name ASC";
}
else
{
$hpsql .= " order by exe_date DESC,exe_name ASC";
}
$hpsql .= " order by exe_date $ordering,exe_name ASC";
break;
case '':
$hpsql .= " ORDER BY exe_cours_id ASC, exe_date ASC";
@ -1176,7 +1033,7 @@ if($_configuration['tracking_enabled'])
}
//echo $sql;
}
$results=getManyResultsXCol($sql,7);
$results=getManyResultsXCol($sql,8);
$hpresults=getManyResultsXCol($hpsql,5);
$NoTestRes = 0;
@ -1199,12 +1056,20 @@ if($_configuration['tracking_enabled'])
if($is_allowedToEdit || $is_tutor)
{
$user = $results[$i][0];
echo '<td>'.$user.'</td>';
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>'.$test.'</td>';
echo '<td>'.format_locale_date(get_lang('dateTimeFormatLong'),$results[$i][4]).'</td>';
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='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show').'</a>').'</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='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 16633 2008-10-27 22:58:34Z yannoo $
* @version $Id: exercice_submit.php 16657 2008-11-04 18:06:45Z dperales $
*/
@ -73,6 +73,10 @@ include_once(api_get_path(LIBRARY_PATH).'text.lib.php');
$is_allowedToEdit=api_is_allowed_to_edit();
$_configuration['live_exercise_tracking'] = true;
$stat_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$exercice_attemp_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
@ -141,6 +145,59 @@ if ($origin=='builder')
if(isset($_SESSION['exerciseResultCoordinates'])) { api_session_unregister('exerciseResultCoordinates'); unset($exerciseResultCoordinates); }
}
$condition = ' WHERE ' .
'exe_exo_id = '."'".$exerciseId."'".' AND ' .
'exe_user_id = '."'".api_get_user_id()."'".' AND ' .
'exe_cours_id = '."'".$_course['id']."'".' AND ' .
'status = '."'incomplete'".' AND '.
'session_id = '."'".api_get_session_id()."'";
if(empty($exerciseType)){
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$result=api_sql_query("SELECT type FROM $TBL_EXERCICES WHERE id='$exerciseId'",__FILE__,__LINE__);
$exercise_row = mysql_fetch_array($result);
$exerciseType = $exercise_row['type'];
}
//search for a 'incomplete' exercise of this user for this exercise for this course and session
//if exist, try to build and array of answers from the track_e_attempt
// 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(mysql_num_rows($sql) > 0 ){
if($exerciseType == 2){
$getIncomplete = mysql_fetch_array($sql);
$exe_id = $getIncomplete['exe_id'];
if($_SERVER['REQUEST_METHOD']!='POST'){
$recorded['questionList'] = explode(',',$getIncomplete['data_tracking']);
//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)){
if(array_key_exists($row['question_id'],$recorded['exerciseResult'])){
if(!is_array($recorded['exerciseResult'][$row['question_id']])){
$last_value = $recorded['exerciseResult'][$row['question_id']];
$recorded['exerciseResult'][$row['question_id']] = array();
$recorded['exerciseResult'][$row['question_id']][$last_value] = 1;
}
$recorded['exerciseResult'][$row['question_id']][$row['answer']] = 1;
} else {
$recorded['exerciseResult'][$row['question_id']] = $row['answer'];
}
}
$_SESSION['exerciseResult'] = $recorded['exerciseResult'];
$exerciseType = 2;
$questionNum = count($recorded['exerciseResult']);
$questionNum++;
$questionList = $_SESSION['questionList'] = $recorded['questionList'];
}
}
}else{
$table_recorded_not_exist = true;
}
}
// if the user has submitted the form
if($formSent)
{
@ -180,6 +237,23 @@ if($formSent)
// stores the user answer into the array
$exerciseResult[$key]=$choice[$key];
//saving each question
if($_configuration['live_exercise_tracking'] == true && $exerciseType == 2):
$nro_question = $questionNum;// - 1;
// for multiple answers
if(is_array($choice[$key])){
foreach ($choice[$key] as $key_array => $value){
api_sql_query('INSERT INTO '.$exercice_attemp_table.' (exe_id,user_id,question_id,answer,marks,course_code,position,tms)'.
' VALUES '.
'('."'".(int)$exe_id."','".api_get_user_id()."','".$questionList[$nro_question]."','".Database::escape_string($key_array)."','','".$_course['id']."','".$position."','".date('Y-m-d H:i:s')."'".')');
}
} else {
api_sql_query('INSERT INTO '.$exercice_attemp_table.' (exe_id,user_id,question_id,answer,marks,course_code,position,tms)'.
' VALUES '.
'('."'".(int)$exe_id."','".api_get_user_id()."','".$questionList[$nro_question]."','".Database::escape_string($choice[$key])."','','".$_course['id']."','".$position."','".date('Y-m-d H:i:s')."'".')');
}
endif;
if (isset($_POST['hotspot']))
{
$exerciseResultCoordinates[$key] = $_POST['hotspot'][$key];
@ -198,7 +272,7 @@ if($formSent)
{
if($debug>0){echo str_repeat('&nbsp;',0).'Redirecting to exercise_result.php - Remove debug option to let this happen'."<br />\n";}
// goes to the script that will show the result of the exercise
header("Location: exercise_result.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
header("Location: exercise_result.php?exerciseType=$exerciseType&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
exit();
}
if($debug>0){echo str_repeat('&nbsp;',0).'$formSent was set - end'."<br />\n";}
@ -235,6 +309,9 @@ if(!is_object($objExercise))
header('Location: exercice.php');
exit();
}
$Exe_starttime = $objExercise->start_time;
$Exe_endtime = $objExercise->end_time;
$quizID = $objExercise->selectId();
$exerciseAttempts=$objExercise->selectAttempts();
$exerciseTitle=$objExercise->selectTitle();
@ -456,7 +533,35 @@ if( $exerciseAttempts > 0){
}
if(!function_exists('convert_date_to_number')){
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);
}
}
$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);
$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(!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));
Display::display_footer();
exit;
} else {
$message_warning = ($permission_to_start == false)? get_lang('ExerciseNoStartedAdmin') : get_lang('ReachedTimeLimitAdmin') ;
Display::display_warning_message(sprintf($message_warning,$exerciseTitle,$exerciseAttempts));
}
}
}
if(!empty($error))
@ -612,6 +717,24 @@ else
echo $s;
}
//creating empty exercise if incomplete not exist
if($_configuration['live_exercise_tracking'] == true):
//if($questionNum < 2){
if($table_recorded_not_exist){
if($exerciseType == 2){
api_sql_query('INSERT INTO '.$stat_table.' ' .
'(exe_exo_id,exe_user_id,exe_cours_id,status,session_id,data_tracking,start_date) ' .
'VALUES ' .
'('."'$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".implode(',',$questionList)."','".date('Y-m-d H:i:s')."'".') ',__FILE__,__LINE__);
} else {
api_sql_query('INSERT INTO '.$stat_table.' ' .
'(exe_exo_id,exe_user_id,exe_cours_id,status,session_id,start_date) ' .
'VALUES ' .
'('."'$exerciseId','".api_get_user_id()."','".$_course['id']."','incomplete','".api_get_session_id()."','".date('Y-m-d H:i:s')."'".') ',__FILE__,__LINE__);
}
}
endif;
if ($origin != 'learnpath') { //so we are not in learnpath tool
Display::display_footer();
}

@ -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 16072 2008-08-26 18:11:13Z juliomontoya $
* @version $Id: exercise.class.php 16657 2008-11-04 18:06:45Z dperales $
*/
@ -42,6 +42,8 @@ class Exercise
var $active;
var $timeLimit;
var $attempts;
var $end_time;
var $start_time;
var $questionList; // array with the list of this exercise's questions
@ -79,7 +81,7 @@ class Exercise
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
#$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$sql="SELECT title,description,sound,type,random,active, results_disabled, max_attempt FROM $TBL_EXERCICES WHERE id='".Database::escape_string($id)."'";
$sql="SELECT title,description,sound,type,random,active, results_disabled, max_attempt,start_time,end_time FROM $TBL_EXERCICES WHERE id='".Database::escape_string($id)."'";
$result=api_sql_query($sql,__FILE__,__LINE__);
// if the exercise has been found
@ -94,6 +96,8 @@ class Exercise
$this->active=$object->active;
$this->results_disabled =$object->results_disabled;
$this->attempts = $object->max_attempt;
$this->end_time = $object->end_time;
$this->start_time = $object->start_time;
$sql="SELECT question_id, question_order FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS WHERE question_id=id AND exercice_id='".Database::escape_string($id)."' ORDER BY question_order";
$result=api_sql_query($sql,__FILE__,__LINE__);
@ -109,6 +113,21 @@ class Exercise
$this->questionList[$object->question_order]=$object->question_id;
}
if($this->random==1){
shuffle($this->questionList);
}
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(!empty($_SESSION['questionList']))$this->questionList = $questionList;
}
return true;
}
@ -253,6 +272,7 @@ class Exercise
*/
function selectRandomList()
{
return $this->questionList;
$nbQuestions = $this->selectNbrQuestions();
//Not a random exercise, or if there are not at least 2 questions
@ -260,7 +280,7 @@ class Exercise
{
return $this->questionList;
}
$randQuestionList = array();
$alreadyChosen = array();
@ -448,11 +468,13 @@ class Exercise
$random=$this->random;
$active=$this->active;
$results_disabled = intval($this->results_disabled);
$start_time = Database::escape_string($this->start_time);
$end_time = Database::escape_string($this->end_time);
// exercise already exists
if($id)
{
$sql="UPDATE $TBL_EXERCICES SET
start_time='$start_time',end_time='$end_time',
title='".Database::escape_string($exercise)."',
description='".Database::escape_string($description)."',
sound='".Database::escape_string($sound)."',
@ -467,8 +489,9 @@ class Exercise
// creates a new exercise
else
{
$sql="INSERT INTO $TBL_EXERCICES(title,description,sound,type,random,active, results_disabled, max_attempt)
$sql="INSERT INTO $TBL_EXERCICES(start_time,end_time,title,description,sound,type,random,active, results_disabled, max_attempt)
VALUES(
'$start_time','$end_time',
'".Database::escape_string($exercise)."',
'".Database::escape_string($description)."',
'".Database::escape_string($sound)."',
@ -760,36 +783,27 @@ class Exercise
$form -> addElement('html','<div id="options" style="display: none;">');
$random = array();
$option=array();
$max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
$option = range(0,$max);
$option[0]=get_lang('DoNotRandomize');
$count_list=10;
if ($this->id>0)
{
$count_list = $this->selectNbrQuestions();
}
for($i=1 ; $i<=$count_list; ++$i)
{
$option[$i] = $i; // fill the array with A, B, C.....
}
$attempt_option=array();
$attempt_option[0]=get_lang('Infinite');
for($i=1 ; $i<=10; ++$i)
{
$attempt_option[$i] = $i; // fill the array with A, B, C.....
}
$random[] = FormValidator :: createElement ('static', 'help','help','<span style="font-style: italic;">'.get_lang('RandomQuestionsHelp').'</span>');
$random[] = FormValidator :: createElement ('select', 'randomQuestions',null,$option);
//$random[] = FormValidator :: createElement ('text', 'randomQuestions', null,null,'0');
$form -> addGroup($random,null,get_lang('RandomQuestions').' : ','<br />');
$attempt_option=range(0,10);
$attempt_option[0]=get_lang('Infinite');
$form -> addElement('select', 'exerciseAttempts',get_lang('ExerciseAttempts').' : ',$attempt_option);
$form -> addElement('checkbox', 'enabletimelimit',null ,get_lang('EnableTimeLimits'));
$form -> addElement('date', 'start_time', get_lang('ExeStartTime'), array('language'=>'es','format' => 'dMYHi'));
$form -> addElement('date', 'end_time', get_lang('ExeEndTime'), array('language'=>'es','format' => 'dMYHi'));
// Exercise attempts
//$form -> addElement('text', 'exerciseAttempts', get_lang('ExerciseAttempts').' : ',array('size'=>'2'));
$form -> addElement('select', 'exerciseAttempts',get_lang('ExerciseAttempts').' : ',$attempt_option);
$form -> addElement('html','</div>');
@ -799,6 +813,9 @@ class Exercise
// rules
$form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required');
$form -> addRule ('exerciseAttempts', get_lang('Numeric'), 'numeric');
$form -> addRule (array('start_time','end_time'), get_lang('DateValidation'), 'comparedate');
$form -> addRule ('start_time', get_lang('Dateinconsistent'), 'errordate');
$form -> addRule ('end_time', get_lang('Dateinconsistent'), 'errordate');
// defaults
$defaults = array();
@ -816,7 +833,13 @@ class Exercise
$defaults['exerciseType'] = $this -> selectType();
$defaults['exerciseTitle'] = $this -> selectTitle();
$defaults['exerciseDescription'] = $this -> selectDescription();
$defaults['exerciseAttempts'] = $this->selectAttempts();
$defaults['exerciseAttempts'] = $this->selectAttempts();
if(($this -> start_time!='0000-00-00 00:00:00')||($this -> end_time!='0000-00-00 00:00:00'))
$defaults['enabletimelimit'] = 1;
$defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00')? $this -> start_time : date('Y-m-d 12:00:00');
$defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00')?$this -> end_time : date('Y-m-d 12:00:00');
}
else
{
@ -824,6 +847,9 @@ class Exercise
$defaults['exerciseAttempts'] = 0;
$defaults['randomQuestions'] = 0;
$defaults['exerciseDescription'] = '';
$defaults['start_time'] = date('Y-m-d 12:00:00');
$defaults['end_time'] = date('Y-m-d 12:00:00');
}
$form -> setDefaults($defaults);
}
@ -840,8 +866,22 @@ class Exercise
$this -> updateDescription($form -> getSubmitValue('exerciseDescription'));
$this -> updateType($form -> getSubmitValue('exerciseType'));
$this -> setRandom($form -> getSubmitValue('randomQuestions'));
$this -> save();
if($form -> getSubmitValue('enabletimelimit')==1)
{
$start_time = $form -> getSubmitValue('start_time');
$start_time = $start_time['Y'].'-'.$start_time['M'].'-'.$start_time['d'].' '.$start_time['H'].':'.$start_time['i'].':00';
$end_time = $form -> getSubmitValue('end_time');
$end_time = $end_time['Y'].'-'.$end_time['M'].'-'.$end_time['d'].' '.$end_time['H'].':'.$end_time['i'].':00';
$this -> start_time = $start_time;
$this -> end_time = $end_time;
}
else
{
$this -> start_time = '0000-00-00 00:00:00';
$this -> end_time = '0000-00-00 00:00:00';
}
$this -> save();
}
}

@ -29,7 +29,7 @@
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @author Julio Montoya Armas switchable fill in blank option added
* @version $Id: exercise_result.php 16633 2008-10-27 22:58:34Z yannoo $
* @version $Id: exercise_result.php 16657 2008-11-04 18:06:45Z dperales $
*
* @todo split more code up in functions, move functions to library?
*/
@ -125,6 +125,16 @@ if ( empty ( $questionList ) ) {
if ( empty ( $objExercise ) ) {
$objExercise = $_SESSION['objExercise'];
}
if ( empty ( $exerciseType ) ) {
$exerciseType = $_REQUEST['exerciseType'];
}
$_configuration['live_exercise_tracking'] = true;
if($_configuration['live_exercise_tracking']) define('ENABLED_LIVE_EXERCISE_TRACKING',1);
if($_configuration['live_exercise_tracking'] == true && $exerciseType == 1){
$_configuration['live_exercise_tracking'] = false;
}
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
$main_admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
$courseName = $_SESSION['_course']['name'];
@ -453,7 +463,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
if($_configuration['tracking_enabled'])
{
// Create an empty exercise
$exeId= create_event_exercice();
$exeId= create_event_exercice($objExercise->selectId());
}
$counter=0;

@ -308,7 +308,8 @@ function update_Db_course($courseDbName)
// Student Publication
$TABLETOOLWORKS = $courseDbName . 'student_publication';
$TABLETOOLWORKSASS = $courseDbName . 'student_publication_assignment';
// Document
$TABLETOOLDOCUMENT = $courseDbName . 'document';
@ -610,6 +611,8 @@ function update_Db_course($courseDbName)
results_disabled TINYINT UNSIGNED NOT NULL DEFAULT 0,
access_condition TEXT DEFAULT NULL,
max_attempt int NOT NULL default 0,
start_time datetime NOT NULL default '0000-00-00 00:00:00',
end_time datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id)
)";
api_sql_query($sql, __FILE__, __LINE__);
@ -764,10 +767,28 @@ function update_Db_course($courseDbName)
post_group_id int DEFAULT 0 NOT NULL,
sent_date datetime NOT NULL default '0000-00-00 00:00:00',
filetype set('file','folder') NOT NULL default 'file',
session_id SMALLINT UNSIGNED NOT NULL default 0,
has_properties int,
view_properties tinyint,
qualification INT UNSIGNED NOT NULL,
date_of_qualification datetime NOT NULL default '0000-00-00 00:00:00',
parent_id INT UNSIGNED NOT NULL,
qualificator_id INT UNSIGNED NOT NULL,
session_id INT UNSIGNED NOT NULL default 0,
PRIMARY KEY (id)
)";
api_sql_query($sql, __FILE__, __LINE__);
$sql = "
CREATE TABLE `".$TABLETOOLWORKSASS."` (
id int NOT NULL auto_increment,
expires_on datetime NOT NULL default '0000-00-00 00:00:00',
ends_on datetime NOT NULL default '0000-00-00 00:00:00',
add_to_calendar tinyint NOT NULL,
enable_qualification tinyint NOT NULL,
publication_id int NOT NULL,
PRIMARY KEY (id)" .
")";
api_sql_query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TABLETOOLWORKS . "` ADD INDEX ( session_id )" ;
/*

@ -1,4 +1,4 @@
<?php // $Id: database.lib.php 16432 2008-10-03 12:05:39Z herodoto $
<?php // $Id: database.lib.php 16657 2008-11-04 18:06:45Z dperales $
/* See license terms in /dokeos_license.txt */
/**
==============================================================================
@ -64,6 +64,7 @@ define('TABLE_STATISTIC_TRACK_E_HOTPOTATOES', 'track_e_hotpotatoes');
define('TABLE_STATISTIC_TRACK_E_COURSE_ACCESS', 'track_e_course_access');
define('TABLE_STATISTIC_TRACK_E_EXERCICES', 'track_e_exercices');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT', 'track_e_attempt');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING', 'track_e_attempt_recording');
define('TABLE_STATISTIC_TRACK_E_DEFAULT', 'track_e_default');
define('TABLE_STATISTIC_TRACK_E_UPLOADS','track_e_uploads');
define('TABLE_STATISTIC_TRACK_E_HOTSPOT','track_e_hotspot');
@ -87,6 +88,7 @@ define('TABLE_TOOL_LIST', 'tool');
define('TABLE_TOOL_INTRO', 'tool_intro');
define('TABLE_SCORMDOC', 'scormdocument');
define('TABLE_STUDENT_PUBLICATION', 'student_publication');
define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT', 'student_publication_assignment');
define('CHAT_CONNECTED_TABLE', 'chat_connected');
//course forum tables

@ -1,4 +1,4 @@
<?php // $Id: events.lib.inc.php 16025 2008-08-19 18:29:30Z juliomontoya $
<?php // $Id: events.lib.inc.php 16657 2008-11-04 18:06:45Z dperales $
/* See license terms in /dokeos_license.txt */
/**
==============================================================================
@ -431,7 +431,7 @@ function update_event_exercice($exeid,$exo_id, $score, $weighting)
exe_exo_id = '".$exo_id."',
exe_result = '".$score."',
exe_weighting = '".$weighting."',
exe_date= FROM_UNIXTIME(".$reallyNow.")
exe_date= FROM_UNIXTIME(".$reallyNow."),status = '', data_tracking=''
WHERE exe_id = '".$exeid."'";
$res = @api_sql_query($sql,__FILE__,__LINE__);
return $res;
@ -447,9 +447,9 @@ function update_event_exercice($exeid,$exo_id, $score, $weighting)
* @author Julio Montoya <gugli100@gmail.com>
* @desc Record result of user when an exercice was done
*/
function create_event_exercice()
function create_event_exercice($exo_id)
{
global $_user, $_cid;
global $_user, $_cid, $_configuration;
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$reallyNow = time();
if ($_user['user_id'])
@ -460,6 +460,19 @@ function create_event_exercice()
{
$user_id = "NULL";
}
if(defined('ENABLED_LIVE_EXERCISE_TRACKING')){
$condition = ' WHERE ' .
'exe_exo_id = '."'".$exo_id."'".' AND ' .
'exe_user_id = '."'".api_get_user_id()."'".' AND ' .
'exe_cours_id = '."'".$_cid."'".' AND ' .
'status = '."'incomplete'".' AND '.
'session_id = '."'".api_get_session_id()."'";
$sql = api_sql_query('SELECT exe_id FROM '.$TABLETRACK_EXERCICES.$condition,__FILE__,__LINE__);
$row = mysql_fetch_array($sql);
return $row['exe_id'];
}
$sql = "INSERT INTO $TABLETRACK_EXERCICES
(
exe_user_id,
@ -506,6 +519,13 @@ function exercise_attempt($score,$answer,$quesId,$exeId,$j)
{
$user_id = "NULL";
}
if($_configuration['live_exercise_tracking']==true){
$sql = "UPDATE $TBL_TRACK_ATTEMPT
SET marks = '".$score."'
WHERE exe_id = '".$exeId."' AND question_id = '".$quesId."'".' AND answer ='."'".$answer."'";
} else {
$sql = "INSERT INTO $TBL_TRACK_ATTEMPT
(
exe_id,
@ -528,6 +548,21 @@ function exercise_attempt($score,$answer,$quesId,$exeId,$j)
'".$j."',
FROM_UNIXTIME(".$reallyNow.")
)";
}
if(defined('ENABLED_LIVE_EXERCISE_TRACKING')){
$TBL_RECORDING = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$recording_changes = 'INSERT INTO '.$TBL_RECORDING.' ' .
'(exe_id,
question_id,
marks,
insert_date,
author)
VALUES
('."'$exeId','".$quesId."','$score','".date('Y-m-d H:i:s')."',''".')';
api_sql_query($recording_changes,__FILE__,__LINE__);
}
$res = @api_sql_query($sql,__FILE__,__LINE__);
return $res;
}

@ -104,6 +104,12 @@ CREATE TABLE track_e_exercices (
KEY exe_cours_id (exe_cours_id)
);
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 session_id SMALLINT UNSIGNED NOT NULL default 0;
ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;
CREATE TABLE track_e_attempt (
exe_id int default NULL,
user_id int NOT NULL default 0,
@ -119,6 +125,15 @@ ALTER TABLE track_e_attempt ADD INDEX (exe_id);
ALTER TABLE track_e_attempt ADD INDEX (user_id);
ALTER TABLE track_e_attempt ADD INDEX (question_id);
CREATE TABLE track_e_attempt_recording (
exe_id int unsigned NOT NULL,
question_id int unsigned NOT NULL,
marks int NOT NULL,
insert_date datetime NOT NULL default '0000-00-00 00:00:00',
author int unsigned NOT NULL,
teacher_comment text NOT NULL);
ALTER TABLE track_e_attempt_recording ADD INDEX (exe_id);
CREATE TABLE track_e_hotpotatoes (
exe_name VARCHAR( 255 ) NOT NULL ,
exe_user_id int unsigned DEFAULT NULL ,

@ -34,7 +34,13 @@ INSERT INTO settings_options (variable, value, display_text) VALUES ('show_sessi
INSERT INTO course_module (name, link, image, `row`, `column`, position) VALUES ('wiki','wiki/index.php','wiki.gif',2,3,'basic');
-- 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 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 ) ;
CREATE TABLE track_e_attempt_recording (exe_id int unsigned NOT NULL, question_id int unsigned NOT NULL, marks int NOT NULL, insert_date datetime NOT NULL default '0000-00-00 00:00:00', author int unsigned NOT NULL, teacher_comment text NOT NULL);
ALTER TABLE track_e_attempt_recording ADD INDEX (exe_id);
-- xxUSERxx
-- xxCOURSExx
@ -57,6 +63,8 @@ UPDATE tool SET category = 'interaction' WHERE name = 'forum';
ALTER TABLE survey ADD show_form_profile int NOT NULL default 0;
ALTER TABLE survey ADD form_fields TEXT NOT NULL;
ALTER TABLE quiz_answer CHANGE hotspot_type hotspot_type ENUM( 'square', 'circle', 'poly', 'delineation' ) NULL DEFAULT NULL;
ALTER TABLE quiz ADD start_time datetime NOT NULL default '0000-00-00 00:00:00';
ALTER TABLE quiz ADD end_time datetime NOT NULL default '0000-00-00 00:00:00';
ALTER TABLE forum_forum ADD forum_image varchar(255) NOT NULL default '';
ALTER TABLE lp ADD preview_image varchar(255) NOT NULL default '';
ALTER TABLE lp ADD author varchar(255) NOT NULL default '';
@ -70,6 +78,12 @@ ALTER TABLE announcement ADD session_id SMALLINT UNSIGNED NOT NULL;
ALTER TABLE announcement ADD INDEX ( session_id ) ;
ALTER TABLE forum_category ADD session_id SMALLINT UNSIGNED NOT NULL ;
ALTER TABLE forum_category ADD INDEX ( session_id ) ;
CREATE TABLE student_publication_assignment (id int NOT NULL auto_increment, expires_on datetime NOT NULL default '0000-00-00 00:00:00', ends_on datetime NOT NULL default '0000-00-00 00:00:00', add_to_calendar tinyint NOT NULL, enable_qualification tinyint NOT NULL, publication_id int NOT NULL, PRIMARY KEY (id));
ALTER TABLE student_publication ADD has_properties INT UNSIGNED NOT NULL;
ALTER TABLE student_publication ADD qualification INT UNSIGNED NOT NULL;
ALTER TABLE student_publication ADD date_of_qualification datetime NOT NULL default '0000-00-00 00:00:00';
ALTER TABLE student_publication ADD parent_id INT UNSIGNED NOT NULL;
ALTER TABLE student_publication ADD qualificator_id INT UNSIGNED NOT NULL;
ALTER TABLE student_publication ADD session_id SMALLINT UNSIGNED NOT NULL default 0 ;
ALTER TABLE student_publication ADD INDEX ( session_id ) ;
ALTER TABLE calendar_event ADD session_id SMALLINT UNSIGNED NOT NULL default 0 ;

@ -229,7 +229,7 @@ function display_user_link($user_id, $name='')
* @param $dateFormatLong - date format
* @param $origin - typically empty or 'learnpath'
*/
function display_student_publications_list($work_dir,$sub_course_dir,$currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin)
function display_student_publications_list($work_dir,$sub_course_dir,$currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin,$add_in_where_query='')
{
global $charset;
// Database table names
@ -277,13 +277,13 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$sql_get_publications_list = "SELECT * " .
"FROM ".$work_table." " .
"WHERE url LIKE BINARY '$sub_course_dir%' " .
"AND url NOT LIKE BINARY '$sub_course_dir%/%' " .
"AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query.
$session_condition.
"ORDER BY id";
$sql_get_publications_num = "SELECT count(*) " .
"FROM ".$work_table." " .
"WHERE url LIKE BINARY '$sub_course_dir%' " .
"WHERE url LIKE BINARY '$sub_course_dir%' " .$add_in_where_query.
"AND url NOT LIKE BINARY '$sub_course_dir%/%' " .
$session_condition.
"ORDER BY id";
@ -303,12 +303,12 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
}
$sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query AND session_id IN (0,".intval($_SESSION['id_session']).") ORDER BY id";
$sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query ".$add_in_where_query." AND session_id IN (0,".intval($_SESSION['id_session']).") ORDER BY id";
$sql_get_publications_num = "SELECT count(url) " .
"FROM ".$work_table." " .
"WHERE url LIKE BINARY '$sub_course_dir%' " .
"AND url NOT LIKE BINARY '$sub_course_dir%/%' " .
"AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query.
$session_condition.
"ORDER BY id";
@ -400,8 +400,8 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
*/
$session_condition = intval($_SESSION['id_session'])!=0 ?"AND work.session_id IN (0,".intval($_SESSION['id_session']).")" : "";
$sql_select_directory= "SELECT prop.lastedit_date, author, work.session_id FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id) WHERE " .
"work.url LIKE BINARY '".$mydir_temp."' AND work.filetype = 'folder' AND prop.tool='work' $session_condition";
$sql_select_directory= "SELECT prop.lastedit_date, id, author, has_properties, view_properties, description, qualification,id FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id) WHERE " .
"work.url LIKE BINARY '".$mydir_temp."' AND work.filetype = 'folder' AND prop.tool='work' $session_condition";
$result=api_sql_query($sql_select_directory,__FILE__,__LINE__);
$row=Database::fetch_array($result);
@ -411,35 +411,145 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$direc_date= $row['lastedit_date']; //directory's date
$author= $row['author']; //directory's author
$folder_session_id = $row['session_id'];
$view_properties=$row['view_properties'];
$is_assignment = $row['has_properties'];
$id2=$row['id'];
$mydir = $my_sub_dir.$dir;
if ($is_allowed_to_edit)
{
{
$clean_edit_dir=Security :: remove_XSS(Database::escape_string($_GET['edit_dir']));
// form edit directory
if(isset($clean_edit_dir) && $clean_edit_dir==$mydir)
{
if(!empty($row['has_properties'])){
$sql = api_sql_query('SELECT * FROM '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT).' WHERE id = '."'".$row['has_properties']."'".' LIMIT 1',__FILE__,__LINE__);
$homework = mysql_fetch_array($sql);
}
$form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?curdirpath='.$my_sub_dir.'&origin='.$origin.'&edit_dir='.$mydir);
//echo $row['view_properties'];
//echo $row['has_properties'];
$group_name[] = FormValidator :: createElement('text','dir_name');
$form_folder-> addElement('textarea','description',get_lang('Description'),array('rows'=>5,'cols'=>50));
$qualification_input[] = FormValidator :: createElement('text','qualification');
$form_folder -> addGroup($qualification_input,'qualification',get_lang('Qualification'),'size="10"');
if($row['view_properties']=='1'){
if($homework['expires_on']!='0000-00-00 00:00:00'){
$there_is_a_expire_date = true;
$form_folder -> addGroup(create_group_date_select(),'expires',get_lang('Expires_At'));
}
if($homework['ends_on']!='0000-00-00 00:00:00'){
$there_is_a_end_date = true;
$form_folder -> addGroup(create_group_date_select(),'ends',get_lang('Ends_At'));
}
$form_folder -> addRule (array('expires','ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
}
else
{
//$form_folder -> addElement('checkbox', 'enableRandom', null, get_lang('MakeRandom'),'1');
$form_folder -> addElement('html','<div class="row">
<div class="label">&nbsp;</div>
<div class="formw">
<a href="javascript://" onclick="if(document.getElementById(\'options\').style.display == \'none\'){document.getElementById(\'options\').style.display = \'block\';}else{document.getElementById(\'options\').style.display = \'none\';}"><img src="../img/add_na.gif" alt="" />'.get_lang('AdvancedParameters').'</a>
</div>
</div> ');
$form_folder -> addElement('html','<div id="options" style="display: none;">');
if(empty($default)) $default = date('Y-m-d 12:00:00');
$parts = split(' ',$default);
list($d_year,$d_month,$d_day) = split('-',$parts[0]);
list($d_hour,$d_minute) = split(':',$parts[1]);
if($homework['expires_on']='0000-00-00 00:00:00'){
$homework['expires_on']=date("Y-m-d h:i:s");
$there_is_a_expire_date = true;
$form_folder -> addElement('checkbox', 'enableRandomExpires', null, get_lang('MakeRandomExpires'),'1');
$form_folder -> addGroup(create_group_date_select(),'expires',get_lang('Expires_At'));
}
if($homework['ends_on']='0000-00-00 00:00:00'){
$homework['ends_on']=date("Y-m-d h:i:s");
$there_is_a_end_date = true;
$form_folder -> addElement('checkbox', 'enableRandomEnds', null, get_lang('MakeRandomEnd'),'1');
$form_folder -> addGroup(create_group_date_select(),'ends',get_lang('Ends_At'));
}
//$form_folder -> addRule ('expires', get_lang('Dateinconsistent'), 'errordate');
//$form_folder -> addRule ('ends', get_lang('Dateinconsistent'), 'errordate');
$form_folder -> addRule (array('expires','ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
$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');
$form_folder -> setDefaults(array('my_group[dir_name]'=>$dir));
$defaults = array('my_group[dir_name]'=>$dir,'description'=>$row['description']);
if($there_is_a_end_date == true)
$defaults = array_merge($defaults,convert_date_to_array($homework['ends_on'],'ends'));
if($there_is_a_expire_date == true)
$defaults = array_merge($defaults,convert_date_to_array($homework['expires_on'],'expires'));
if(!empty($row['qualification']))
$defaults = array_merge($defaults,array('qualification[qualification]'=>$row['qualification']));
$form_folder -> setDefaults($defaults);
$display_edit_form=true;
if($form_folder -> validate())
{
if($there_is_a_end_date == true || $there_is_a_expire_date == true)
{
if($row['view_properties']=='1')
{
$sql_add_publication = "UPDATE ".Database :: get_course_table(TABLE_STUDENT_PUBLICATION)." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
api_sql_query($sql_add_publication, __FILE__, __LINE__);
$expires_query= ' SET expires_on = '."'".(($there_is_a_expire_date == true)?get_date_from_group('expires'):'0000-00-00 00:00:00')."'".',';
$ends_query = ' ends_on = '."'".(($there_is_a_end_date == true) ? get_date_from_group('ends') : '0000-00-00 00:00:00')."'";
api_sql_query('UPDATE '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT).$expires_query.$ends_query.' WHERE id = '."'".$row['has_properties']."'",__FILE__,__LINE__);
}
else if($row['view_properties']=='0')
{
if ($_POST['enableRandomExpires']=='1')
{
$expires_query= ' SET expires_on = '."'".(($there_is_a_expire_date == true)?get_date_from_group('expires'):'0000-00-00 00:00:00')."'";
//$ends_query = ' ends_on = '."'".(($there_is_a_end_date == true) ? get_date_from_group('ends') : '0000-00-00 00:00:00')."'";
api_sql_query('UPDATE '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT).$expires_query.' WHERE id = '."'".$row['has_properties']."'",__FILE__,__LINE__);
$sql_add_publication = "UPDATE ".Database :: get_course_table(TABLE_STUDENT_PUBLICATION)." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
api_sql_query($sql_add_publication, __FILE__, __LINE__);
}
if ($_POST['enableRandomEnds']=='1')
{
//$expires_query= ' SET expires_on = '."'".(($there_is_a_expire_date == true)?get_date_from_group('expires'):'0000-00-00 00:00:00')."'".',';
$ends_query = ' SET ends_on = '."'".(($there_is_a_end_date == true) ? get_date_from_group('ends') : '0000-00-00 00:00:00')."'";
api_sql_query('UPDATE '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT).$ends_query.' WHERE id = '."'".$row['has_properties']."'",__FILE__,__LINE__);
$sql_add_publication = "UPDATE ".Database :: get_course_table(TABLE_STUDENT_PUBLICATION)." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
api_sql_query($sql_add_publication, __FILE__, __LINE__);
}
}
}
//if($_POST['qualification']['qualification']!='')
api_sql_query('UPDATE '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION).' SET description = '."'".Database::escape_string($_POST['description'])."'".', qualification = '."'".Database::escape_string($_POST['qualification']['qualification'])."'".' WHERE id = '."'".$row['id']."'",__FILE__,__LINE__);
$values = $form_folder -> exportValues();
$values = $values['my_group'];
update_dir_name($mydir,$values['dir_name']);
$mydir = $my_sub_dir.$values['dir_name'];
$dir = $values['dir_name'];
$display_edit_form=false;
}
}
}
@ -479,7 +589,9 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
}
else
{
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&curdirpath='.$mydir.'"'.$class.'>'.$dir.'</a><br>'.$cant_files.' '.$text_file.$dirtext;
$add_to_name = '';
if($view_properties==1) $add_to_name = ' / <span style="color:blue">'.get_lang('Assignment').'</span>';
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&curdirpath='.$mydir.'"'.$class.'>'.$dir.'</a>'.$add_to_name.'<br>'.$cant_files.' '.$text_file.$dirtext;
}
if ($count_files!=0)
@ -499,7 +611,7 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
{
$action .= '<a href="'.api_get_self().'?cidReq='.api_get_course_id().
'&curdirpath='.$my_sub_dir.'&origin='.$origin.'&edit_dir='.$mydir.'"><img src="../img/edit.gif" alt="'.get_lang('Modify').'"></a>';
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&delete_dir='.$mydir.'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."'".')) return false;" title="'.get_lang('DirDelete').'" ><img src="'.api_get_path(WEB_IMG_PATH).'delete.gif" alt="'.get_lang('DirDelete').'"></a>';
$action .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&delete_dir='.$mydir.'&delete2='.$id2.'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."'".')) return false;" title="'.get_lang('DirDelete').'" ><img src="'.api_get_path(WEB_IMG_PATH).'delete.gif" alt="'.get_lang('DirDelete').'"></a>';
$row[] = $action;
}
else
@ -534,6 +646,19 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$class='';
}
if(defined('IS_ASSIGNMENT')):
$add_string = '';
if($work->qualification=='')
$qualification_string = ' / <b style="color:orange">'.get_lang('NotRevised').'<b>';
else
$qualification_string = ' / <b style="color:blue">'.get_lang('Qualification').': '.$work->qualification.'<b>';
if(defined('ASSIGNMENT_EXPIRES') && (ASSIGNMENT_EXPIRES < convert_date_to_number($work->sent_date))){
$add_string = ' <b style="color:red">'.get_lang('Expired').'</b>';
}
endif;
$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;

@ -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 16503 2008-10-13 07:39:37Z elixir_inter $
* @version $Id: work.php 16657 2008-11-04 18:06:45Z dperales $
*
* @todo refactor more code into functions, use quickforms, coding standards, ...
*/
@ -115,6 +115,116 @@ function updateDocumentTitle(value){
</script>
';
$htmlHeadXtra[] = '<script>
function checkDate(month, day, year)
{
var monthLength =
new Array(31,28,31,30,31,30,31,31,30,31,30,31);
if (!day || !month || !year)
return false;
// check for bisestile year
if (year/4 == parseInt(year/4))
monthLength[1] = 29;
if (month < 1 || month > 12)
return false;
if (day > monthLength[month-1])
return false;
return true;
}
function mktime() {
var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length;
d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972);
var dateManip = {
0: function(tt){ return d.setHours(tt); },
1: function(tt){ return d.setMinutes(tt); },
2: function(tt){ set = d.setSeconds(tt); mb = d.getDate() - 1; return set; },
3: function(tt){ set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; },
4: function(tt){ return d.setDate(tt+mb); },
5: function(tt){ return d.setYear(tt+ma); }
};
for( i = 0; i < argc; i++ ){
no = parseInt(argv[i]*1);
if (isNaN(no)) {
return false;
} else {
// arg is number, lets manipulate date object
if(!dateManip[i](no)){
// failed
return false;
}
}
}
return Math.floor(d.getTime()/1000);
}
function validate(){
var expires_day = document.form1.expires_day.value;
var expires_month = document.form1.expires_month.value;
var expires_year = document.form1.expires_year.value;
var expires_hour = document.form1.expires_hour.value;
var expires_minute = document.form1.expires_minute.value;
var expires_date = mktime(expires_hour,expires_minute,0,expires_month,expires_day,expires_year)
var ends_day = document.form1.ends_day.value;
var ends_month = document.form1.ends_month.value;
var ends_year = document.form1.ends_year.value;
var ends_hour = document.form1.ends_hour.value;
var ends_minute = document.form1.ends_minute.value;
var ends_date = mktime(ends_hour,ends_minute,0,ends_month,ends_day,ends_year)
var new_dir = document.form1.new_dir.value;
msg_id1 = document.getElementById("msg_error1");
msg_id2 = document.getElementById("msg_error2");
msg_id3 = document.getElementById("msg_error3");
msg_id4 = document.getElementById("msg_error4");
if(new_dir==""){
msg_id1.style.display ="block";
msg_id1.innerHTML="Este campo no debe estar vacio";
msg_id2.innerHTML="";msg_id3.innerHTML="";msg_id4.innerHTML="";
}
else if(expires_date > ends_date)
{
msg_id2.style.display ="block";
msg_id2.innerHTML="La fecha de vencimiento no debe ser mayor que la fecha l&iacute;mite";
msg_id1.innerHTML="";msg_id3.innerHTML="";msg_id4.innerHTML="";
}
else if (checkDate(expires_month,expires_day,expires_year) == false)
{
msg_id3.style.display ="block";
msg_id3.innerHTML="Fecha Invalida";
msg_id1.innerHTML="";msg_id2.innerHTML="";msg_id4.innerHTML="";
}
else if (checkDate(ends_month,ends_day,ends_year) == false)
{
msg_id4.style.display ="block";
msg_id4.innerHTML="Fecha Invalida";
msg_id1.innerHTML="";msg_id2.innerHTML="";msg_id3.innerHTML="";
}
else{
document.form1.action = "work.php?origin=<?php echo $origin ?>";
document.form1.submit();
}
}
</script>
';
/*
-----------------------------------------------------------
Including necessary files
@ -133,6 +243,14 @@ require_once (api_get_path(LIBRARY_PATH) . "security.lib.php");
require_once(api_get_path(LIBRARY_PATH) . "formvalidator/FormValidator.class.php");
require_once ('work.lib.php');
function make_select($name,$values,$checked=''){
$output .= '<select name="'.$name.'" >';
foreach($values as $key => $value)
$output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>';
$output .= '</select>';
return $output;
}
/*
-----------------------------------------------------------
Table definitions
@ -141,6 +259,7 @@ require_once ('work.lib.php');
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$iprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$student_pub_ass = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
/*
-----------------------------------------------------------
Constants and variables
@ -426,6 +545,7 @@ if (api_is_allowed_to_edit(false,true))
$workAuthor = $row['author'];
$workDescription = $row['description'];
$workUrl = $row['url'];
$qualification_number = $row['qualification'];
}
}
@ -515,6 +635,14 @@ if (api_is_allowed_to_edit(false,true))
---------------------*/
if (!empty ($_REQUEST['create_dir']) && !empty ($_REQUEST['new_dir']))
{
function get_date_from_select($prefix){
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');
//create the directory
//needed for directory creation
include_once (api_get_path(LIBRARY_PATH) . "fileUpload.lib.php");
@ -538,21 +666,78 @@ if (api_is_allowed_to_edit(false,true))
$sql_add_publication = "INSERT INTO " . $work_table . " SET " .
"url = '" . $dir_name_sql . "',
title = '',
description = '',
description = '".Database::escape_string($_POST['description'])."',
author = '',
active = '0',
accepted = '1',
filetype = 'folder',
post_group_id = '0',
sent_date = NOW(),
session_id = ".intval($_SESSION['id_session']);
qualification = '".(($_POST['qualification_value']!='') ? Database::escape_string($_POST['qualification_value']) : '') ."',
parent_id = '',
qualificator_id = '',
date_of_qualification = '0000-00-00 00:00:00',
session_id = ".intval($_SESSION['id_session']);
api_sql_query($sql_add_publication, __FILE__, __LINE__);
// add the directory
$id = mysql_insert_id();
//Folder created
api_item_property_update($_course, 'work', $id, 'DirectoryCreated', $user_id);
api_item_property_update($_course, 'work', $id, 'DirectoryCreated', $user_id);
//----------------inser into student_publication_assignment-------------------//
//return something like this: 2008-02-45 00:00:00
if(($_POST['type1'])==1 || ($_POST['type2']==1))
{
$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')."',
add_to_calendar = '".(int)$_POST['add_to_calendar']."',
enable_qualification = '".(int)$_POST['enable_calification']."',
publication_id = '".$id."'";
api_sql_query($sql_add_homework, __FILE__, __LINE__);
//api_sql_query($sql_add_publication, __FILE__, __LINE__);
$sql_add_publication = "UPDATE ".$work_table." SET "."has_properties = ".mysql_insert_id().", view_properties = 1 ".' where id = '.$id;
api_sql_query($sql_add_publication, __FILE__, __LINE__);
}
else
{
$TSTDPUBASG=Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$sql_add_homework = "INSERT INTO ".$TSTDPUBASG." SET " .
"expires_on = '0000-00-00 00:00:00',
ends_on = '0000-00-00 00:00:00',
add_to_calendar = '".(int)$_POST['add_to_calendar']."',
enable_qualification = '".(int)$_POST['enable_calification']."',
publication_id = '".$id."'";
api_sql_query($sql_add_homework, __FILE__, __LINE__);
//api_sql_query($sql_add_publication, __FILE__, __LINE__);
$sql_add_publication = "UPDATE ".$work_table." SET "."has_properties = ".mysql_insert_id().", view_properties = 0 ".' where id = '.$id;
api_sql_query($sql_add_publication, __FILE__, __LINE__);
}
if($_POST['make_calification']==1)
{
require_once('../gradebook/lib/be/gradebookitem.class.php');
require_once('../gradebook/lib/be/evaluation.class.php');
require_once('../gradebook/lib/be/abstractlink.class.php');
require_once('../gradebook/lib/gradebook_functions.inc.php');
$resource_name = (empty($_POST['qualification_name'])) ? $_POST['new_dir'] : $_POST['qualification_name'];
add_resource_to_course_gradebook(api_get_course_id(), 3, $id, Database::escape_string($resource_name), 0, $_POST['qualification_value'], Database::escape_string($_POST['description']), "'".date('Y-m-d H:i:s')."'", 1,api_get_session_id());
}
//----------------inser into agenda----------------------//
if(!empty($_POST['type1']) && $_POST['add_to_calendar']==1):
include_once('../calendar/agenda.inc.php');
include_once('../resourcelinker/resourcelinker.inc.php');
agenda_add_item($course_info,$_POST['new_dir'],$_POST['new_dir'],date('Y-m-d H:i:s'),get_date_from_select('expires'));
endif;
//-----------------end feature---------------------------//
// update all the parents in the table item propery
$list_id=get_parent_directories($my_cur_dir_path);
@ -582,6 +767,15 @@ if (api_is_allowed_to_edit(false,true))
del_dir($base_work_dir . '/', $delete_directory);
Display :: display_normal_message($delete_directory . ' ' . get_lang('DirDeleted'));
}
if (!empty ($_REQUEST['delete2']))
{
$delete_2=$_REQUEST['delete2'];
$sql2="DELETE FROM ". Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT)." WHERE publication_id ='".$delete_2."'";
$result2 = api_sql_query($sql2, __FILE__, __LINE__);
//Display :: display_normal_message($delete_directory . ' ' . get_lang('DirDeleted'));
$sql3="DELETE FROM ".Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK)." WHERE course_code='".$course_code."' AND ref_id='".$delete_2."'";
$result3 = api_sql_query($sql3, __FILE__, __LINE__);
}
/* ----------------------
* Move file form request
----------------------- */
@ -707,6 +901,7 @@ else
$workAuthor = $row['author'];
$workDescription = $row['description'];
$workUrl = $row['url'];
$qualification_number = $row['qualification'];
}
}
}
@ -780,6 +975,13 @@ if ($_POST['submitWork'] && $is_course_member && $check)
api_sql_query("ALTER TABLE " . $work_table . " ADD sent_date DATETIME NOT NULL");
}
$current_date = date('Y-m-d H:i:s');
$parent_id = '';
$sql = api_sql_query('SELECT id FROM '.Database::get_course_table(TABLE_STUDENT_PUBLICATION).' WHERE url = '."'/".Database::escape_string($_GET['curdirpath'])."' AND filetype='folder' LIMIT 1");
if(mysql_num_rows($sql) > 0 ){
$dir_row = mysql_fetch_array($sql);
$parent_id = $dir_row['id'];
}
$sql_add_publication = "INSERT INTO " . $work_table . " SET " .
"url = '" . $url . "',
@ -790,6 +992,7 @@ if ($_POST['submitWork'] && $is_course_member && $check)
accepted = '" . (!$uploadvisibledisabled) . "',
post_group_id = '" . $post_group_id . "',
sent_date = ' ".$current_date ."',
parent_id = '".$parent_id ."' ,
session_id=".intval($_SESSION['id_session']);
api_sql_query($sql_add_publication, __FILE__, __LINE__);
@ -867,11 +1070,17 @@ if ($_POST['submitWork'] && $is_course_member && $check)
{
$title = basename($newWorkUrl);
}
if($is_allowed_to_edit && ($_POST['qualification']!='')){
$add_to_update = ',qualificator_id ='."'".api_get_user_id()."',";
$add_to_update .= 'qualification ='."'".Database::escape_string($_POST['qualification'])."',";
$add_to_update .= 'date_of_qualification ='."'".date('Y-m-d H:i:s')."'";
}
$sql = "UPDATE " . $work_table . "
SET title = '" . $title . "',
description = '" . $description . "',
author = '" . $authors . "'
author = '" . $authors . "'".$add_to_update."
WHERE id = '" . $id . "'";
api_sql_query($sql, __FILE__, __LINE__);
@ -979,8 +1188,45 @@ if ($_POST['submitWork'] && $succeed && !$id) //last value is to check this is n
Display links to upload form and tool options
=======================================
*/
display_action_links($cur_dir_path, $always_show_tool_options, $always_show_upload_form);
$has_expired = false;
$sql = api_sql_query('SELECT description,id FROM '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION).' WHERE filetype = '."'folder'".' and has_properties != '."''".' and url = '."'/".Database::escape_string($_GET['curdirpath'])."'".' LIMIT 1',__FILE__,__LINE__);
$is_special = mysql_num_rows($sql);
if($is_special > 0):
$is_special = true;
define('IS_ASSIGNMENT',1);
$publication = mysql_fetch_array($sql);
$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($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']);
$time_ends = convert_date_to_number($homework['ends_on']);
$difference = $time_expires - $time_now;
$difference2 = $time_ends - $time_now;
if($homework['expires_on']!='0000-00-00 00:00:00' && $difference < 0) $has_expired = true;
if($homework['ends_on']!='0000-00-00 00:00:00' && $difference2 < 0) $has_ended = true;
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);
}elseif($has_expired) {
Display :: display_warning_message(get_lang('ExpiryDateAlreadyPassed').' '.$homework['expires_on']);
display_action_links($cur_dir_path, $always_show_tool_options,$always_show_upload_form);
} else {
Display :: display_normal_message(get_lang('ExpiryDateToSendWorkIs').' '.$homework['expires_on']);
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);
endif;
/*=======================================
Display form to upload document
@ -988,7 +1234,7 @@ display_action_links($cur_dir_path, $always_show_tool_options, $always_show_uplo
if ($is_course_member)
{
if ($display_upload_form || $edit)
if (($display_upload_form || $edit)&&!$has_ended)
{
$token = Security :: get_token(); //generate token to be used to check validity of request
if ($edit)
@ -1005,7 +1251,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 :: remove_XSS($cur_dir_path) . "&origin=$origin", '', 'enctype="multipart/form-data"');
$form = new FormValidator('form', 'POST', api_get_self() . "?curdirpath=" . Security :: rtrim(remove_XSS($cur_dir_path),'/') . "&origin=$origin", '', 'enctype="multipart/form-data"');
if (!empty ($error_message))
Display :: display_error_message($error_message);
@ -1053,6 +1299,9 @@ if ($is_course_member)
$titleAuthors = $form->addElement('textarea', 'description', get_lang("Description"), 'style="width: 350px; height: 60px;"');
$defaults["description"] = ($edit ? stripslashes($workDescription) : stripslashes($description));
if($is_allowed_to_edit && $edit )$form->addElement('text', 'qualification', get_lang('Qualification'),'size="10"');
$defaults['qualification'] = $qualification_number;//($edit ? stripslashes($qualification_number) : stripslashes($qualification_number));
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
$form->addElement('hidden', 'sec_token', $token);
@ -1085,6 +1334,42 @@ if ($is_course_member)
//show them the form for the directory name
if (isset ($_REQUEST['createdir']) && $is_allowed_to_edit)
{
require_once (api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php');
$form = new FormValidator('form1', 'POST', api_get_self() . "?curdirpath=" . Security :: remove_XSS($cur_dir_path) . "&origin=$origin");
$form->addElement('hidden', 'curdirpath', Security :: remove_XSS($cur_dir_path));
$form->addElement('text', 'new_dir', get_lang('NewDir'), '');
$form->addElement('textarea', 'description', get_lang('Description'), 'style="width: 350px; height: 60px;"');
$form -> addElement('html','<div class="row">
<div class="label">&nbsp;</div>
<div class="formw">
<a href="javascript://" onclick="if(document.getElementById(\'options\').style.display == \'none\'){document.getElementById(\'options\').style.display = \'block\';}else{document.getElementById(\'options\').style.display = \'none\';}"><img src="../img/add_na.gif" alt="" />'.get_lang('AdvancedParameters').'</a>
</div>
</div>');
$form -> addElement('html','<div id="options" style="display: none;">');
$form->addElement('checkbox', 'make_calification',null ,get_lang('MakeQualifiable'));
$form->addElement('text', 'qualification_value', get_lang('QualificationNumberOver'), ' size="5" ');
$form->addElement('checkbox', 'type1',null ,get_lang('EnableExpireDate'));
$form->addElement('date', 'expires_on', get_lang('ExeStartTime'), array('language'=>'es','format' => 'dMYHi'));
$form->addElement('checkbox', 'add_to_calendar',null ,get_lang('AddEventToCalendar'));
$form->addElement('checkbox', 'type2',null ,get_lang('EnableEndDate'));
$form->addElement('date', 'ends_on', get_lang('ExeEndTime'), array('language'=>'es','format' => 'dMYHi'));
$form -> addElement('html','</div>');
$form->addElement('submit', 'create_dir', get_lang('Ok'),'onClick="validate();"');
$defaults['expires_on'] = date('Y-m-d 12:00:00');
$defaults['ends_on'] = date('Y-m-d 12:00:00');
$form->setDefaults($defaults);
echo '<br /><br />';
$form->display();
/*
//create the form that asks for the directory name
$new_folder_text = '<br /><br /><form action="' . api_get_self() . '?origin='.$origin.'" method="POST">';
$new_folder_text .= '<input type="hidden" name="curdirpath" value="' . Security :: remove_XSS($cur_dir_path) . '"/>';
@ -1094,6 +1379,7 @@ if ($is_course_member)
$new_folder_text .= '</form>';
//show the form
echo $new_folder_text;
*/
}
}
else
@ -1127,7 +1413,31 @@ else
}
if (!$display_upload_form && !$display_tool_options) {
display_student_publications_list($base_work_dir . '/' . $my_cur_dir_path, 'work/' . $my_cur_dir_path, $currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin);
if(!$is_allowed_to_edit && $is_special==true){
$add_query = ' AND author = '."'".$_user['firstName'].' '.$_user['lastName']."' ";
}
if($is_allowed_to_edit && $is_special==true){
switch($_REQUEST['filter']){
case 1:
$add_query = ' AND qualification = '."''";
break;
case 2:
$add_query = ' AND qualification != '."''";
break;
case 3:
$add_query = ' AND sent_date < '."'".$homework['expires_on']."'";
break;
default:
$add_query = '';
}
$form_filter = '<form method="post" action="'.api_get_self().'?cidReq='.Security::Remove_XSS($_GET['cidreq']).'&curdirpath='.Security::Remove_XSS($_GET['curdirpath']).'">';
$form_filter .= make_select('filter',array(0=>get_lang('SelectAFilter'),1=>get_lang('FilterByNotRevised'),2=>get_lang('FilterByRevised'),3=>get_lang('FilterByNotExpired')),(int)$_REQUEST['filter']);
$form_filter .= '<input type="submit" value="'.get_lang('FilterAssigments').'"</form>';
echo $form_filter;
}
display_student_publications_list($base_work_dir . '/' . $my_cur_dir_path, 'work/' . $my_cur_dir_path, $currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin,$add_query);
}
/*

Loading…
Cancel
Save