[svn r14786] add the "disabled results" feature in exercises (FS#2127)

skala
Eric Marguin 17 years ago
parent aab7b17d1f
commit 9e2c632356
  1. 22
      main/exercice/exercice.php
  2. 20
      main/exercice/exercise.class.php
  3. 14
      main/exercice/exercise_result.php
  4. BIN
      main/img/lp_quiz_na.gif
  5. 1
      main/inc/lib/add_course.lib.inc.php
  6. 1
      main/install/migrate-db-1.8.4-1.8.5-pre.sql

@ -373,6 +373,16 @@ if($is_allowedToEdit)
$objExerciseTmp->save();
Display::display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable_results' : //disable the results for the learners
$objExerciseTmp->disable_results();
$objExerciseTmp->save();
Display::display_confirmation_message(get_lang('ResultsDisabled'));
break;
case 'enable_results' : //disable the results for the learners
$objExerciseTmp->enable_results();
$objExerciseTmp->save();
Display::display_confirmation_message(get_lang('ResultsEnabled'));
break;
}
}
@ -431,14 +441,14 @@ if($is_allowedToEdit)
if($show == 'test')
{
$sql="SELECT id,title,type,active,description FROM $TBL_EXERCICES WHERE active<>'-1' ORDER BY title LIMIT $from,".($limitExPage+1);
$sql="SELECT id,title,type,active,description, results_disabled FROM $TBL_EXERCICES WHERE active<>'-1' ORDER BY title LIMIT $from,".($limitExPage+1);
$result=api_sql_query($sql,__FILE__,__LINE__);
}
}
// only for students
elseif($show == 'test')
{
$sql="SELECT id,title,type,description FROM $TBL_EXERCICES WHERE active='1' ORDER BY title LIMIT $from,".($limitExPage+1);
$sql="SELECT id,title,type,description, results_disabled FROM $TBL_EXERCICES WHERE active='1' ORDER BY title LIMIT $from,".($limitExPage+1);
$result=api_sql_query($sql,__FILE__,__LINE__);
}
@ -606,6 +616,12 @@ if($show == 'test'){
<a href="exercice.php?choice=enable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" alt="<?php echo htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
<?php
}
if($row['results_disabled'])
echo '<a href="exercice.php?choice=enable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('EnableResults').'" alt="'.get_lang('EnableResults').'"><img src="../img/lp_quiz_na.gif" border="0" alt="'.htmlentities(get_lang('EnableResults'),ENT_QUOTES,$charset).'" /></a>';
else
echo '<a href="exercice.php?choice=disable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('DisableResults').'" alt="'.get_lang('DisableResults').'"><img src="../img/lp_quiz.gif" border="0" alt="'.htmlentities(get_lang('DisableResults'),ENT_QUOTES,$charset).'" /></a>';
echo "</td>";
echo "</tr>\n";
@ -862,7 +878,7 @@ if($_configuration['tracking_enabled'])
{ // get only this user's results
$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='".$_user['user_id']."' AND te.exe_cours_id='$_cid'
WHERE te.exe_exo_id = ce.id AND te.exe_user_id='".$_user['user_id']."' AND te.exe_cours_id='$_cid' AND results_disabled=0
ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC";
$hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)

@ -22,7 +22,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: exercise.class.php 13184 2007-09-22 05:30:47Z yannoo $
* @version $Id: exercise.class.php 14786 2008-04-08 14:11:46Z elixir_inter $
*/
@ -75,7 +75,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 FROM $TBL_EXERCICES WHERE id='$id'";
$sql="SELECT title,description,sound,type,random,active, results_disabled FROM $TBL_EXERCICES WHERE id='$id'";
$result=api_sql_query($sql,__FILE__,__LINE__);
// if the exercise has been found
@ -88,6 +88,7 @@ class Exercise
$this->type=$object->type;
$this->random=$object->random;
$this->active=$object->active;
$this->results_disabled =$object->results_disabled;
$sql="SELECT question_id,position FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS WHERE question_id=id AND exercice_id='$id' ORDER BY position";
$result=api_sql_query($sql,__FILE__,__LINE__);
@ -411,6 +412,16 @@ class Exercise
{
$this->active=0;
}
function disable_results()
{
$this->results_disabled = true;
}
function enable_results()
{
$this->results_disabled = false;
}
/**
* updates the exercise in the data base
@ -429,17 +440,18 @@ class Exercise
$type=$this->type;
$random=$this->random;
$active=$this->active;
$results_disabled = intval($this->results_disabled);
// exercise already exists
if($id)
{
$sql="UPDATE $TBL_EXERCICES SET title='$exercise',description='$description',sound='$sound',type='$type',random='$random',active='$active' WHERE id='$id'";
$sql="UPDATE $TBL_EXERCICES SET title='$exercise',description='$description',sound='$sound',type='$type',random='$random',active='$active',results_disabled='$results_disabled' WHERE id='$id'";
api_sql_query($sql,__FILE__,__LINE__);
}
// creates a new exercise
else
{
$sql="INSERT INTO $TBL_EXERCICES(title,description,sound,type,random,active) VALUES('$exercise','$description','$sound','$type','$random','$active')";
$sql="INSERT INTO $TBL_EXERCICES(title,description,sound,type,random,active, results_disabled) VALUES('$exercise','$description','$sound','$type','$random','$active',$results_disabled)";
api_sql_query($sql,__FILE__,__LINE__);
$this->id=mysql_insert_id();

@ -25,7 +25,7 @@
* @package dokeos.exercise
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @version $Id: exercise_result.php 14588 2008-03-13 11:17:02Z vanwayenbergh $
* @version $Id: exercise_result.php 14786 2008-04-08 14:11:46Z elixir_inter $
*
* @todo split more code up in functions, move functions to library?
*/
@ -145,6 +145,7 @@ $exerciseTitle=$objExercise->selectTitle();
$exerciseDescription=$objExercise->selectDescription();
$exerciseDescription=stripslashes($exerciseDescription);
$nameTools=get_lang('Exercice');
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
@ -191,6 +192,11 @@ else
}
if($objExercise->results_disabled)
{
ob_start();
}
/*
==============================================================================
FUNCTIONS
@ -853,6 +859,12 @@ if($_configuration['tracking_enabled'])
}
if($objExercise->results_disabled)
{
ob_end_clean();
Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><a href="exercice.php" />'.get_lang('Back').'</a>',false);
}
if ($origin != 'learnpath')
{
//we are not in learnpath tool

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -552,6 +552,7 @@ function update_Db_course($courseDbName)
type tinyint unsigned NOT NULL default 1,
random smallint(6) NOT NULL default 0,
active tinyint NOT NULL default 0,
results_disabled TINYINT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
api_sql_query($sql, __FILE__, __LINE__);

@ -111,3 +111,4 @@ ALTER TABLE forum_post ADD INDEX idx_forum_post_visible (visible);
ALTER TABLE forum_thread ADD INDEX idx_forum_thread_forum_id (forum_id);
ALTER TABLE student_publication ADD COLUMN filetype SET('file','folder') NOT NULL DEFAULT 'file' AFTER sent_date;
ALTER TABLE document ADD readonly TINYINT UNSIGNED NOT NULL ;
ALTER TABLE quiz ADD results_disabled TINYINT UNSIGNED NOT NULL DEFAULT 0;

Loading…
Cancel
Save