[svn r10691] test update

skala
Eric Marguin 18 years ago
parent 8dc1244927
commit 158af8b15f
  1. 16
      main/exercice/admin.php
  2. 11
      main/exercice/exercice.php
  3. 63
      main/exercice/exercise.class.php
  4. 237
      main/exercice/exercise_admin.inc.php
  5. 104
      main/exercice/exercise_admin.php
  6. 2
      main/exercice/fill_blanks.class.php
  7. 2
      main/exercice/freeanswer.class.php
  8. 4
      main/exercice/hotspot.class.php
  9. 6
      main/exercice/matching.class.php
  10. 1
      main/exercice/multiple_answer.class.php
  11. 8
      main/exercice/question_admin.inc.php
  12. 6
      main/exercice/question_list_admin.inc.php
  13. 2
      main/exercice/unique_answer.class.php

@ -1,4 +1,4 @@
<?php // $Id: admin.php 10594 2007-01-05 13:54:24Z elixir_inter $
<?php // $Id: admin.php 10691 2007-01-12 12:16:28Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -134,7 +134,6 @@ if ( empty ( $modifyExercise ) ) {
$modifyExercise = $_GET['modifyExercise'];
}
// get from session
$objExercise = $_SESSION['objExercise'];
$objQuestion = $_SESSION['objQuestion'];
@ -437,19 +436,14 @@ if(isset($_GET['hotspotadmin']))
{
include('hotspot_admin.inc.php');
}
if(!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspotadmin']))
{
// exercise management
include('exercise_admin.inc.php');
if(!$modifyExercise)
{
// question list management
include('question_list_admin.inc.php');
}
// question list management
include('question_list_admin.inc.php');
}
api_session_register('objExercise');
api_session_register('objQuestion');
api_session_register('objAnswer');

@ -315,10 +315,10 @@ if($show == 'test'){
{
//error_log('is_allowedToEdit and origin<> learnpath',0);
echo "<td width=\"50%\" nowrap=\"nowrap\">",
"<img src=\"../img/quiz.gif\" alt=\"new test\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"admin.php\">".get_lang("NewEx")."</a> | ",
"<img src=\"../img/quiz.gif\" alt=\"new test\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"exercise_admin.php\">".get_lang("NewEx")."</a>",
//"<img src=\"../img/quiz_na.gif\" alt=\"new test\" valign=\"ABSMIDDLE\"><a href=\"question_pool.php\">".get_lang("QuestionPool")."</a> | ",
"<img src=\"../img/jqz.jpg\" alt=\"HotPotatoes\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"hotpotatoes.php\">".get_lang("ImportHotPotatoesQuiz")."</a>",
//" | <img src=\"../img/jqz.jpg\" alt=\"HotPotatoes\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"hotpotatoes.php\">".get_lang("ImportHotPotatoesQuiz")."</a>",
"</td>",
"<td width=\"50%\" align=\"right\">";
}
@ -388,8 +388,6 @@ if($show == 'test'){
<tr bgcolor="#e6e6e6">
<td align="center"><?php echo get_lang("ExerciseName");?></td>
<td align="center"><?php echo get_lang("Description");?></td>
<td width="13%" align="center"><b><?php echo get_lang('Addlimits'); ?> </b><br />
(time,attempts)</td>
<td align="center"><?php echo get_lang("Modify");?></td>
</tr>
@ -445,8 +443,7 @@ if($show == 'test'){
$sqlresult =mysql_query($sqlquery);
$rowi = mysql_result($sqlresult,0);
echo $rowi.' Questions'; ?> </td>
<td width="13%" align="center"><a href="addlimits.php?exercise_id=<?php echo $exid; ?>"> <img src="../img/test_prop.gif" border="0" align="absmiddle" alt="<?php echo get_lang('Addlimits'); ?>" /></a>&nbsp;<img src="../img/test_add_limit.gif" align="absbottom"> </td>
<td width="12%" align="center"><a href="admin.php?exerciseId=<?php echo $row[id]; ?>"> <img src="../img/edit.gif" border="0" alt="<?php echo htmlentities(get_lang('Modify')); ?>" /></a>
<td width="12%" align="center"><a href="admin.php?exerciseId=<?php echo $row[id]; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo htmlentities(get_lang('Build')); ?>" alt="<?php echo htmlentities(get_lang('Build')); ?>" /></a><a href="exercise_admin.php?modifyExercise=yes&exerciseId=<?php echo $row[id]; ?>"> <img src="../img/edit.gif" border="0" title="<?php echo htmlentities(get_lang('Modify')); ?>" alt="<?php echo htmlentities(get_lang('Modify')); ?>" /></a>
<a href="exercice.php?choice=delete&exerciseId=<?php echo $row[id]; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('areYouSure'))); echo $row['title']; echo "?"; ?>')) return false;"> <img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete')); ?>" /></a>
<?php
// if active
@ -782,7 +779,7 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
$headers .= "Content-Transfer-Encoding: 7bit";
$headers .= 'From: '.$from_name.' <'.$from.'>' . "\r\n";
$headers="From:$from_name\r\nReply-to: $to\r\nContent-type: text/html; charset=iso-8859-15";
echo 'envoi d\'un mail à '.$emailid;
echo 'envoi d\'un mail <EFBFBD> '.$emailid;
//mail($emailid, $subject, $mess,$headers);

@ -1,4 +1,4 @@
<?php // $Id: exercise.class.php 10197 2006-11-26 18:45:33Z pcool $
<?php // $Id: exercise.class.php 10691 2007-01-12 12:16:28Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -60,7 +60,6 @@ class Exercise
$this->type=1;
$this->random=0;
$this->active=1;
$this->questionList=array();
}
@ -608,6 +607,66 @@ class Exercise
$sql="DELETE FROM $TBL_EXERCICES WHERE id='$id'";
api_sql_query($sql,__FILE__,__LINE__);
}
/**
* Creates the form to create / edit an exercise
* @param FormValidator $form the formvalidator instance (by reference)
*/
function createForm ($form)
{
// title
$form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName').' : ');
// fck editor
global $fck_attribute;
$fck_attribute = array();
$fck_attribute['Height'] = '250';
$fck_attribute['Width'] = '100%';
$fck_attribute['ToolbarSet'] = 'NewTest';
$form -> addElement ('html_editor', 'exerciseDescription', get_lang('ExerciseDescription').' : ');
// type
$radios = array();
$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SimpleExercise'),'1');
$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
$form -> addGroup($radios, null, get_lang('ExerciseType').' : ', '<br />');
// submit
$form -> addElement('submit', 'submitExercise', get_lang('Ok'));
// rules
$form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required');
// defaults
$defaults = array();
if($this -> id > 0)
{
$defaults['exerciseType'] = $this -> selectType();
$defaults['exerciseTitle'] = $this -> selectTitle();
$defaults['exerciseDescription'] = $this -> selectDescription();
}
$defaults['exerciseType'] = '1';
$form -> setDefaults($defaults);
}
/**
* function which process the creation of exercises
* @param FormValidator $form the formvalidator instance
*/
function processCreation($form)
{
$this -> updateTitle($form -> getSubmitValue('exerciseTitle'));
$this -> updateDescription($form -> getSubmitValue('exerciseDescription'));
$this -> updateType($form -> getSubmitValue('exerciseType'));
$this -> save();
}
}
endif;

@ -1,237 +0,0 @@
<?php // $Id: exercise_admin.inc.php 10556 2006-12-26 15:35:00Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Olivier Brouckaert
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* EXERCISE ADMINISTRATION
*
* This script allows to manage an exercise.
* It is included from the script admin.php
*
* @author Olivier Brouckaert
* @package dokeos.exercise
==============================================================================
*/
// ALLOWED_TO_INCLUDE is defined in admin.php
if(!defined('ALLOWED_TO_INCLUDE'))
{
exit();
}
// the exercise form has been submitted
if($submitExercise)
{
$exerciseTitle=trim($exerciseTitle);
$exerciseDescription=trim($exerciseDescription);
$randomQuestions=$randomQuestions?$questionDrawn:0;
$deleteSound=$deleteSound?true:false;
// no title given
if(empty($exerciseTitle))
{
$msgErr=get_lang('GiveExerciseName');
}
else
{
$objExercise->updateTitle($exerciseTitle);
$objExercise->updateDescription($exerciseDescription);
$objExercise->updateSound($_FILES['exerciseSound'],$deleteSound);
$objExercise->updateType($exerciseType);
$objExercise->setRandom($randomQuestions);
$objExercise->save();
if($deleteSound)
{
$exerciseSound='';
}
else
{
$exerciseSound=$objExercise->selectSound();
}
// reads the exercise ID (only usefull for a new exercise)
$exerciseId=$objExercise->selectId();
unset($modifyExercise);
}
}
else
{
$exerciseTitle=$objExercise->selectTitle();
$exerciseDescription=$objExercise->selectDescription();
$exerciseSound=$objExercise->selectSound();
$exerciseType=$objExercise->selectType();
$randomQuestions=$objExercise->isRandom();
}
// shows the form to modify the exercise
if($modifyExercise)
{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyExercise=<?php echo $modifyExercise; ?>" style="margin:0px;" enctype="multipart/form-data">
<table border="0" cellpadding="5" width="75%">
<?php
if(!empty($msgErr))
{
?>
<tr>
<td colspan="2">
<?php
Display::display_normal_message($msgErr); //main API
?>
</td>
</tr>
<?php
}
?>
<tr>
<td><?php echo get_lang('ExerciseName'); ?> :</td>
<td><input type="text" name="exerciseTitle" size="50" maxlength="200" value="<?php echo htmlentities($exerciseTitle); ?>" style="width:400px;"></td>
</tr>
<tr>
<td valign="top"><?php echo get_lang('ExerciseDescription'); ?> :</td>
<td>
<?php
$oFCKeditor = new FCKeditor('exerciseDescription');
$oFCKeditor->BasePath = api_get_path(WEB_PATH) . 'main/inc/lib/fckeditor/' ;
$oFCKeditor->Height = '250';
$oFCKeditor->Width = '100%';
$oFCKeditor->Value = $exerciseDescription;
$oFCKeditor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH)."main/inc/lib/fckeditor/myconfig.js";
$oFCKeditor->Config['IMUploadPath'] = "/upload/test/";
$oFCKeditor->ToolbarSet = "NewTest";
$TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$sql="SELECT isocode FROM ".$TBL_LANGUAGES." WHERE english_name='".$_SESSION["_course"]["language"]."'";
$result_sql=api_sql_query($sql);
$isocode_language=mysql_result($result_sql,0,0);
$oFCKeditor->Config['DefaultLanguage'] = $isocode_language;
$oFCKeditor->Create() ;
?>
</td>
</tr>
<!--
<tr>
<td valign="top"><?php echo get_lang('Sound'); ?> :
<?php if(!empty($exerciseSound)): ?>
<a href="../document/download.php?doc_url=%2Faudio%2F<?php echo $exerciseSound; ?>" target="_blank"><img src="../img/wav.gif" border="0" align="absmiddle" alt="<?php echo get_lang('Sound'); ?>"></a>
<?php endif; ?>
</td>
<td><input type="file" name="exerciseSound" size="50" style="width:400px;">
<?php if(!empty($exerciseSound)): ?>
<br>
<input class="checkbox" type="checkbox" name="deleteSound" value="1"> <?php echo get_lang('DeleteSound'); ?>
<?php endif; ?>
</td>
</tr>
//-->
<tr>
<td valign="top"><?php echo get_lang('ExerciseType'); ?> :</td>
<td><input class="checkbox" type="radio" name="exerciseType" value="1" <?php if($exerciseType <= 1) echo 'checked="checked"'; ?>> <?php echo get_lang('SimpleExercise'); ?><br>
<input class="checkbox" type="radio" name="exerciseType" value="2" <?php if($exerciseType >= 2) echo 'checked="checked"'; ?>> <?php echo get_lang('SequentialExercise'); ?></td>
</tr>
<?php
if($exerciseId && $nbrQuestions)
{
?>
<tr>
<td valign="top"><?php echo get_lang('RandomQuestions'); ?> :</td>
<td><input class="checkbox" type="checkbox" name="randomQuestions" value="1" <?php if($randomQuestions) echo 'checked="checked"'; ?>> <?php echo get_lang('Yes'); ?>, <?php echo get_lang('Take'); ?>
<select name="questionDrawn">
<?php
for($i=1;$i <= $nbrQuestions;$i++)
{
?>
<option value="<?php echo $i; ?>" <?php if(($formSent && $questionDrawn == $i) || (!$formSent && ($randomQuestions == $i || ($randomQuestions <= 0 && $i == $nbrQuestions)))) echo 'selected="selected"'; ?>><?php echo $i; ?></option>
<?php
}
?>
</select> <?php echo strtolower(get_lang('Questions')).' '.get_lang('Among').' '.$nbrQuestions; ?>
</td>
</tr>
<?php
}
?>
<tr>
<td>&nbsp;</td>
<td>
<input type="hidden" name="myid" value="1"><?php //added?>
<input type="submit" name="submitExercise" value="<?php echo get_lang('Ok'); ?>">
<!-- &nbsp;&nbsp;<input type="submit" name="cancelExercise" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;"> //-->
</td>
</tr>
</table>
</form>
<?php
}
else
{
?>
<h3>
<?php
$exerciseTitle = api_parse_tex($exerciseTitle);
echo $exerciseTitle; ?>
<?php if(!empty($exerciseSound)): ?>
<a href="../document/download.php?doc_url=%2Faudio%2F<?php echo $exerciseSound; ?>" target="_blank"><img src="../img/wav.gif" border="0" align="absmiddle" alt="<?php echo get_lang('Sound'); ?>"></a>
<?php endif; ?>
</h3>
<blockquote>
<?php
$exerciseDescription = api_parse_tex($exerciseDescription);
echo $exerciseDescription; ?>
</blockquote>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?modifyExercise=yes"><img src="../img/edit.gif" border="0" align="absmiddle" alt="<?php echo get_lang('Modify'); ?>"></a>
<?php
}
?>

@ -0,0 +1,104 @@
<?php // $Id$
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Olivier Brouckaert
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* EXERCISE ADMINISTRATION
*
* This script allows to manage an exercise.
* It is included from the script admin.php
*
* @author Olivier Brouckaert
* @package dokeos.exercise
==============================================================================
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
// name of the language file that needs to be included
$language_file='exercice';
include('../inc/global.inc.php');
include('exercise.lib.php');
$this_section=SECTION_COURSES;
include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
if(!api_is_allowed_to_edit())
{
api_not_allowed();
}
/*********************
* INIT EXERCISE
*********************/
$objExercise = new Exercise();
/*********************
* INIT FORM
*********************/
$form = new FormValidator('exercise_admin');
if(isset($_GET['exerciseId']))
{
$objExercise -> read (intval($_GET['exerciseId']));
$form -> addElement ('hidden','edit','true');
}else
{
$form -> addElement ('hidden','edit','false');
}
$objExercise -> createForm ($form);
/*********************
* VALIDATE FORM
*********************/
if($form -> validate())
{
$objExercise -> processCreation($form);
if($form -> getSubmitValue('edit') == 'true')
{
header('Location:exercice.php');
}
else
{
header('Location:admin.php?exerciseId='.$objExercise->id);
}
}
else
{
/*********************
* DISPLAY FORM
*********************/
$nameTools=get_lang('ExerciseManagement');
$interbreadcrumb[] = array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
Display::display_header($nameTools,"Exercise");
$form -> display ();
}

@ -158,8 +158,6 @@ class FillBlanks extends Question {
$objAnswer->createAnswer($answer,0,'',0,'');
$objAnswer->save();
echo '<script type="text/javascript">window.location.href="admin.php"</script>';
}
}

@ -80,8 +80,6 @@ class FreeAnswer extends Question {
$this->save();
echo '<script type="text/javascript">window.location.href="admin.php"</script>';
}
}

@ -69,9 +69,9 @@ class HotSpot extends Question {
if(!empty($file_info['tmp_name']))
{
$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
$this->resizePicture('any',350);
$this->save();
}
echo '<script type="text/javascript">window.location.href="admin.php?hotspotadmin='.$this->id.'"</script>';
}
}
function createAnswersForm ($form) {

@ -135,7 +135,7 @@ class Matching extends Question {
<table cellpadding="0" cellspacing="5">
<tr bgcolor="#e6e6e6">
<td>
N°
N<EFBFBD>
</td>
<td>
'.get_lang('Answer').'
@ -188,7 +188,7 @@ class Matching extends Question {
<table cellpadding="0" cellspacing="5">
<tr bgcolor="#e6e6e6">
<td>
N°
N<EFBFBD>
</td>
<td>
'.get_lang('Answer').'
@ -262,8 +262,6 @@ class Matching extends Question {
$objAnswer->save();
$this->save();
echo '<script type="text/javascript">window.location.href="admin.php"</script>';
}
}

@ -192,7 +192,6 @@ class MultipleAnswer extends Question {
$this -> updateWeighting($questionWeighting);
$this -> save();
echo '<script type="text/javascript">window.location.href="admin.php"</script>';
}
}

@ -1,4 +1,4 @@
<? // $Id: question_admin.inc.php 10597 2007-01-05 14:14:29Z elixir_inter $
<? // $Id: question_admin.inc.php 10691 2007-01-12 12:16:28Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -108,6 +108,12 @@ if(is_object($objQuestion))
// answers
$objQuestion -> processAnswersCreation($form,$nb_answers);
// redirect
if($objQuestion -> type != HOT_SPOT)
echo '<script type="text/javascript">window.location.href="admin.php"</script>';
else
echo '<script type="text/javascript">window.location.href="admin.php?hotspotadmin='.$objQuestion->id.'"</script>';
}
else
{

@ -1,4 +1,4 @@
<?php // $Id: question_list_admin.inc.php 10594 2007-01-05 13:54:24Z elixir_inter $
<?php // $Id: question_list_admin.inc.php 10691 2007-01-12 12:16:28Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -39,6 +39,7 @@ if(!defined('ALLOWED_TO_INCLUDE'))
exit();
}
// moves a question up in the list
if($moveUp)
{
@ -74,8 +75,7 @@ if($deleteQuestion)
}
?>
<hr size="1" noshade="noshade">
<a href="question_pool.php?fromExercise=<?php echo $exerciseId; ?>"><?php echo get_lang('GetExistingQuestion'); ?></a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <!--<a href="exercice.php?<?php echo api_get_cidreq(); ?>"><?php echo get_lang('backtoTesthome'); ?></a>--><br />
<a href="question_pool.php?fromExercise=<?php echo $exerciseId; ?>"><?php echo get_lang('GetExistingQuestion'); ?></a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <!--<a href="exercice.php?<?php echo api_get_cidreq(); ?>"><?php echo get_lang('backtoTesthome'); ?></a>--><br />
<br /><?php echo get_lang('NewQu').' : ';?><a href="admin.php?newQuestion=yes&answerType=1"><?php echo get_lang('UniqueSelect'); ?></a> | <a href="admin.php?newQuestion=yes&answerType=2"><?php echo get_lang('MultipleSelect'); ?></a> | <a href="admin.php?newQuestion=yes&answerType=3"><?php echo get_lang('FillBlanks'); ?></a> | <a href="admin.php?newQuestion=yes&answerType=4"><?php echo get_lang('Matching'); ?></a> | <a href="admin.php?newQuestion=yes&answerType=5"><?php echo get_lang('freeAnswer'); ?></a> | <a href="admin.php?newQuestion=yes&answerType=6"><?php echo get_lang('Hotspot'); ?></a>
&nbsp;&nbsp;
<br /><br />

@ -198,7 +198,7 @@ class UniqueAnswer extends Question {
// sets the total weighting of the question
$this -> updateWeighting($questionWeighting);
$this -> save();
echo '<script type="text/javascript">window.location.href="admin.php"</script>';
}
}

Loading…
Cancel
Save