[svn r10789] table constansts, cleaning header and code

skala
Patrick Cool 19 years ago
parent d7eea36e96
commit 9da7c7611f
  1. 68
      main/exercice/GC.php
  2. 89
      main/exercice/Hpdownload.php
  3. 30
      main/exercice/addlimits.php
  4. 128
      main/exercice/admin.php
  5. 41
      main/exercice/adminhp.php
  6. 47
      main/exercice/answer.class.php
  7. 46
      main/exercice/answer_admin.inc.php
  8. 41
      main/exercice/exercice.php
  9. 77
      main/exercice/exercice_submit.php
  10. 46
      main/exercice/exercise.class.php
  11. 89
      main/exercice/exercise.lib.php
  12. 54
      main/exercice/exercise_admin.php
  13. 48
      main/exercice/exercise_result.php
  14. 37
      main/exercice/exercise_show.php
  15. 29
      main/exercice/feedback.php
  16. 108
      main/exercice/fill_blanks.class.php
  17. 82
      main/exercice/freeanswer.class.php
  18. 271
      main/exercice/hotpotatoes.lib.php
  19. 93
      main/exercice/hotpotatoes.php
  20. 44
      main/exercice/hotspot.class.php
  21. 172
      main/exercice/hotspot_actionscript.as.php
  22. 155
      main/exercice/hotspot_actionscript_admin.as.php
  23. 46
      main/exercice/hotspot_admin.inc.php
  24. 180
      main/exercice/hotspot_answers.as.php
  25. 33
      main/exercice/hotspot_lang_conversion.php
  26. 111
      main/exercice/hotspot_save.inc.php
  27. 117
      main/exercice/hotspot_savescore.inc.php
  28. 131
      main/exercice/hotspot_updatescore.inc.php
  29. 44
      main/exercice/mark_free_answer.php
  30. 158
      main/exercice/matching.class.php
  31. 127
      main/exercice/multiple_answer.class.php
  32. 42
      main/exercice/question.class.php
  33. 89
      main/exercice/question_admin.inc.php
  34. 63
      main/exercice/question_list_admin.inc.php
  35. 58
      main/exercice/question_pool.php
  36. 67
      main/exercice/savescores.php
  37. 95
      main/exercice/showinframes.php
  38. 64
      main/exercice/testheaderpage.php
  39. 131
      main/exercice/unique_answer.class.php

@ -1,46 +1,42 @@
<?php // $Id: GC.php 10083 2006-11-21 19:43:29Z pcool $
<?php
/*
==============================================================================
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) Istvan Mandak
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* Code library for HotPotatoes integration.
*
* @author Istvan Mandak
* @package dokeos.exercise
==============================================================================
*/
* @author Istvan Mandak
* @version $Id: GC.php 10789 2007-01-18 19:18:27Z pcool $
*/
// usage: HotPotGC($_configuration['root_sys'],$flag);
// working recursively, flag[0,1] print or delete the HotPotatoes temp files (.t.html)
echo "Garbage Collector<BR>";
HotPotGC($_configuration['root_sys'],1,1);
// functions
// functions
function HotPotGC($root_sys,$flag,$userID)
{
{
// flag[0,1] - print or delete the HotPotatoes temp files (.t.html)
$documentPath = $root_sys."courses";
require_once(api_get_path(LIBRARY_PATH)."fileManage.lib.php");
@ -57,9 +53,9 @@
{
$full_name = $folder."/".$file;
if (is_dir($full_name))
{
{
HotPotGCt($folder."/".$file,$flag);
}
}
else
{
$filelist[] = $file;
@ -69,12 +65,12 @@
}
closedir($dir);
}
while (list ($key, $val) = each ($filelist))
while (list ($key, $val) = each ($filelist))
{
if (stristr($val,$userID.".t.html"))
{ if ($flag == 1)
{
my_delete($folder."/".$val);
my_delete($folder."/".$val);
}
else
{

@ -1,36 +1,31 @@
<?php
<?php
/*
==============================================================================
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) Istvan Mandak
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* EXERCISE LIST
*
* This script shows the list of exercises for administrators and students.
*
* @author Istvan Mandak
* @package dokeos.exercise
==============================================================================
* @author Istvan Mandak
* @version $Id: Hpdownload.php 10789 2007-01-18 19:18:27Z pcool $
*/
session_cache_limiter('public');
include('../inc/global.inc.php');
@ -38,7 +33,7 @@ $this_section=SECTION_COURSES;
include(api_get_path(LIBRARY_PATH)."events.lib.inc.php");
$tbl_document=$_course['dbNameGlu']."document";
$tbl_document = Database::get_course_table(TABLE_DOCUMENT);
$doc_url=urldecode($_GET['doc_url']);
@ -53,12 +48,12 @@ if (isset($_course['path']))
}
else
{
//$full_file_name=$_configuration['root_sys']."courses/".$cid.'/document'.$doc_url;
$full_file_name = api_get_path(SYS_COURSE_PATH).$cid.'/document'.$doc_url;
//$full_file_name=$_configuration['root_sys']."courses/".$cid.'/document'.$doc_url;
$full_file_name = api_get_path(SYS_COURSE_PATH).$cid.'/document'.$doc_url;
}
if(!is_file($full_file_name))
{
{
exit();
}
@ -102,7 +97,7 @@ if($content_type == 'text/html')
{
include (api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
$directory_name = dirname($full_file_name);
$dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
if($dir[strlen($dir)-1] != '/')
@ -110,14 +105,14 @@ if($content_type == 'text/html')
$dir.='/';
}
//Parse whole file at one
$fp = fopen($full_file_name, "r");
$file_content = fread ($fp, filesize ($full_file_name));
fclose($fp);
//$file_content = api_replace_parameter($dir, $file_content, "src");
//$file_content = api_replace_parameter($dir, $file_content, "href");
/*
//parse line per line
$file_content_array = file($full_file_name);
@ -129,14 +124,14 @@ if($content_type == 'text/html')
$file_content .= $line;
}
*/
$exercicePath = $_SERVER['PHP_SELF'];
$exfile = explode('/',$exercicePath);
$exfile = $exfile[sizeof($exfile)-1];
$exercicePath = substr($exercicePath,0,strpos($exercicePath,$exfile));
$exercicePath = $exercicePath;
$content = $file_content;
$mit = "function Finish(){";
@ -147,7 +142,7 @@ if($content_type == 'text/html')
" {\n".
" SaveScoreVariable = 1;\n".
" if (C.ie)\n".
" {\n".
" {\n".
" document.location.href = \"".$exercicePath."savescores.php?origin=$origin&time=$time&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n".
" //window.alert(Score);\n".
" }\n".
@ -159,22 +154,22 @@ if($content_type == 'text/html')
"// Must be included \n".
"function Finish(){\n".
" mySaveScore();";
$newcontent = str_replace($mit,$js_content,$content);
$newcontent = str_replace($mit,$js_content,$content);
$prehref="javascript:void(0);";
$posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
$newcontent = str_replace($prehref,$posthref,$newcontent);
$newcontent = str_replace($prehref,$posthref,$newcontent);
$prehref="class=\"GridNum\" onclick=";
$posthref="class=\"GridNum\" onMouseover=";
$newcontent = str_replace($prehref,$posthref,$newcontent);
$newcontent = str_replace($prehref,$posthref,$newcontent);
header('Content-length: '.strlen($newcontent));
// Dipsp.
echo $newcontent;
exit();
}
@ -182,7 +177,7 @@ if($content_type == 'text/html')
//header('Content-length: '.filesize($full_file_name));
$fp=fopen($full_file_name,'rb');
fpassthru($fp);
fclose($fp);

@ -1,7 +1,29 @@
<?php
/*
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
* @todo use database library
*/
* Adding limits
* @package dokeos.exercise
* @author
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/*
-----------------------------------------------------------
including the global file
@ -53,8 +75,8 @@ api_protect_course_script();
@todo: use the Database :: get_course_table functions
-----------------------------------------------------------
*/
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$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);
$TBL_REPONSES = Database::get_course_table('quiz_answer');
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);

@ -1,74 +1,68 @@
<?php // $Id: admin.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
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 (create, modify) an exercise and its questions
*
* Following scripts are includes for a best code understanding :
*
* - exercise.class.php : for the creation of an Exercise object
* - question.class.php : for the creation of a Question object
* - answer.class.php : for the creation of an Answer object
*
* - exercise.lib.php : functions used in the exercise tool
*
* - exercise_admin.inc.php : management of the exercise
* - question_admin.inc.php : management of a question (statement & answers)
* - statement_admin.inc.php : management of a statement
* - answer_admin.inc.php : management of answers
* - question_list_admin.inc.php : management of the question list
*
* Main variables used in this script :
*
* - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise
*
* - $objExercise : exercise object
* - $objQuestion : question object
* - $objAnswer : answer object
*
* - $aType : array with answer types
* - $exerciseId : the exercise ID
* - $picturePath : the path of question pictures
*
* - $newQuestion : ask to create a new question
* - $modifyQuestion : ID of the question to modify
* - $editQuestion : ID of the question to edit
* - $submitQuestion : ask to save question modifications
* - $cancelQuestion : ask to cancel question modifications
* - $deleteQuestion : ID of the question to delete
* - $moveUp : ID of the question to move up
* - $moveDown : ID of the question to move down
* - $modifyExercise : ID of the exercise to modify
* - $submitExercise : ask to save exercise modifications
* - $cancelExercise : ask to cancel exercise modifications
* - $modifyAnswers : ID of the question which we want to modify answers for
* - $cancelAnswers : ask to cancel answer modifications
* - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks"
*
* @author Olivier Brouckaert
* @package dokeos.exercise
*/
* Exercise administration
* This script allows to manage (create, modify) an exercise and its questions
*
* Following scripts are includes for a best code understanding :
*
* - exercise.class.php : for the creation of an Exercise object
* - question.class.php : for the creation of a Question object
* - answer.class.php : for the creation of an Answer object
* - exercise.lib.php : functions used in the exercise tool
* - exercise_admin.inc.php : management of the exercise
* - question_admin.inc.php : management of a question (statement & answers)
* - statement_admin.inc.php : management of a statement
* - answer_admin.inc.php : management of answers
* - question_list_admin.inc.php : management of the question list
*
* Main variables used in this script :
*
* - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise
* - $objExercise : exercise object
* - $objQuestion : question object
* - $objAnswer : answer object
* - $aType : array with answer types
* - $exerciseId : the exercise ID
* - $picturePath : the path of question pictures
* - $newQuestion : ask to create a new question
* - $modifyQuestion : ID of the question to modify
* - $editQuestion : ID of the question to edit
* - $submitQuestion : ask to save question modifications
* - $cancelQuestion : ask to cancel question modifications
* - $deleteQuestion : ID of the question to delete
* - $moveUp : ID of the question to move up
* - $moveDown : ID of the question to move down
* - $modifyExercise : ID of the exercise to modify
* - $submitExercise : ask to save exercise modifications
* - $cancelExercise : ask to cancel exercise modifications
* - $modifyAnswers : ID of the question which we want to modify answers for
* - $cancelAnswers : ask to cancel answer modifications
* - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks"
*
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: admin.php 10789 2007-01-18 19:18:27Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
@ -167,11 +161,11 @@ $audioPath=$documentPath.'/audio';
$aType=array(get_lang('UniqueSelect'),get_lang('MultipleSelect'),get_lang('FillBlanks'),get_lang('Matching'),get_lang('freeAnswer'));
// tables used in the exercise tool
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$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);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$TBL_DOCUMENT = $_course['dbNameGlu']."document";
$TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
if(!$is_allowedToEdit)
{

@ -1,31 +1,30 @@
<?php // $Id: adminhp.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
* HOTPOTATOES ADMINISTRATION
* @author Istvan Mandak
* @package dokeos.exercise
*/
* HotPotatoes administration.
* @package dokeos.exercise
* @author Istvan Mandak
* @version $Id: adminhp.php 10789 2007-01-18 19:18:27Z pcool $
*/
include('exercise.class.php');

@ -1,40 +1,35 @@
<?php // $Id: answer.class.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
/**
* This class allows to instantiate an object of type Answer
* 5 arrays are created to receive the attributes of each answer belonging to a specified question
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: answer.class.php 10789 2007-01-18 19:18:27Z pcool $
*/
if(!class_exists('Answer')):
/*>>>>>>>>>>>>>>>>>>>> CLASS ANSWER <<<<<<<<<<<<<<<<<<<<*/
/**
* This class allows to instantiate an object of type Answer
*
* 5 arrays are created to receive the attributes of each answer
* belonging to a specified question
*
* @author Olivier Brouckaert
* @package dokeos.exercise
*/
class Answer
{
var $questionId;

@ -1,36 +1,30 @@
<?php // $Id: answer_admin.inc.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/*>>>>>>>>>>>>>>>>>>>> ANSWER ADMINISTRATION <<<<<<<<<<<<<<<<<<<<*/
/**
==============================================================================
* This script allows to manage answers
*
* It is included from the script admin.php
* @author Olivier Brouckaert
* @package dokeos.exercise
==============================================================================
*/
* This script allows to manage answers. It is included from the script admin.php
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: answer_admin.inc.php 10789 2007-01-18 19:18:27Z pcool $
*/
// ALLOWED_TO_INCLUDE is defined in admin.php
if(!defined('ALLOWED_TO_INCLUDE'))

@ -1,40 +1,33 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* EXERCISE LIST
*
* This script shows the list of exercises for administrators and students.
*
* Exercise list: This script shows the list of exercises for administrators and students.
* @package dokeos.exercise
* @author Olivier Brouckaert, original author
* @author Denes Nagy, HotPotatoes integration
* @author Wolfgang Schneider, code/html cleanup
* @package dokeos.exercise
* @todo use database library
==============================================================================
* @version $Id: exercice.php 10789 2007-01-18 19:18:27Z pcool $
*/
// name of the language file that needs to be included
$language_file='exercice';

@ -1,49 +1,44 @@
<?php // $Id: exercice_submit.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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
Copyright (c) Denes Nagy
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
EXERCISE SUBMISSION
*
* This script allows to run an exercise. According to the exercise type, questions
* can be on an unique page, or one per page with a Next button.
*
* One exercise may contain different types of answers (unique or multiple selection,
* matching and fill in blanks).
*
* Questions are selected randomly or not.
*
* When the user has answered all questions and clicks on the button "Ok",
* it goes to exercise_result.php
*
* Notice : This script is also used to show a question before modifying it by
* the administrator
*
* @author Olivier Brouckaert
* @package dokeos.exercise
==============================================================================
*/
* Exercise submission
* This script allows to run an exercise. According to the exercise type, questions
* can be on an unique page, or one per page with a Next button.
*
* One exercise may contain different types of answers (unique or multiple selection,
* matching and fill in blanks).
*
* Questions are selected randomly or not.
*
* When the user has answered all questions and clicks on the button "Ok",
* it goes to exercise_result.php
*
* Notice : This script is also used to show a question before modifying it by
* the administrator
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: exercice_submit.php 10789 2007-01-18 19:18:27Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
@ -72,8 +67,8 @@ include_once(api_get_path(LIBRARY_PATH).'text.lib.php');
$is_allowedToEdit=$is_courseAdmin;
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$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);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);

@ -1,39 +1,33 @@
<?php // $Id: exercise.class.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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
==============================================================================
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
if(!class_exists('Exercise')):
/**
==============================================================================
CLASS EXERCISE
*
* This class allows to instantiate an object of type Exercise
*
* @author Olivier Brouckaert
* Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise
==============================================================================
* @author Olivier Brouckaert
* @version $Id: exercise.class.php 10789 2007-01-18 19:18:27Z pcool $
*/
if(!class_exists('Exercise')):
class Exercise
{
var $id;

@ -1,41 +1,32 @@
<?php // $Id: exercise.lib.php 10594 2007-01-05 13:54:24Z elixir_inter $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
EXERCISE TOOL LIBRARY
*
* shows a question and its answers
*
* @returns 'number of answers' if question exists, otherwise false
*
* @author Olivier Brouckaert <oli.brouckaert@skynet.be>
*
* @param integer $questionId ID of the question to show
* @param boolean $onlyAnswers set to true to show only answers
* @package dokeos.exercise
==============================================================================
*/
* Exercise library
* shows a question and its answers
* @package dokeos.exercise
* @author Olivier Brouckaert <oli.brouckaert@skynet.be>
* @version $Id: exercise.lib.php 10789 2007-01-18 19:18:27Z pcool $
*/
require("../inc/lib/fckeditor/fckeditor.php") ;
function showQuestion($questionId, $onlyAnswers=false, $origin=false)
{
@ -98,7 +89,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false)
{
#$comment = $objAnswerTmp->selectComment(1);
//
$upload_path = api_get_path(REL_COURSE_PATH).$_SESSION['_course']['path'].'/document/';
$oFCKeditor = new FCKeditor("choice[".$questionId."]") ;
$oFCKeditor->BasePath = api_get_path(WEB_PATH) . 'main/inc/lib/fckeditor/' ;
@ -108,13 +99,13 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false)
$oFCKeditor->Width = '80%';
$oFCKeditor->Height = '300';
$oFCKeditor->Value = '' ;
$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;
$s .= "<tr><td colspan='2'>".$oFCKeditor->CreateHtml()."</td></tr>";
//$s.="<tr><td colspan='2'><textarea cols='80' rows='10' name='choice[".$questionId."]'>$answer</textarea></td></tr>";
@ -312,7 +303,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false)
//$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
//echo $tes;
$s .= "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
<script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
<script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
<script language=\"JavaScript\" type=\"text/javascript\">
<!--
// -----------------------------------------------------------------------------
@ -334,7 +325,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false)
on error resume next
Dim swControl, swVersion
swVersion = 0
set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
if (IsObject(swControl)) then
swVersion = swControl.GetVariable(\"\$version\")
@ -343,7 +334,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false)
End Function
// -->
</script>
<script language=\"JavaScript1.1\" type=\"text/javascript\">
<!-- // Detect Client Browser type
var isIE = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
@ -379,48 +370,48 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false)
// older WebTV supports Flash 2
else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
// Can't detect in all other cases
else {
else
{
flashVer = -1;
}
return flashVer;
}
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
// loop backwards through the versions until we find the newest version
for (i=25;i>0;i--) {
// loop backwards through the versions until we find the newest version
for (i=25;i>0;i--) {
if (isIE && isWin && !isOpera) {
versionStr = VBGetSwfVer(i);
} else {
versionStr = JSGetSwfVer(i);
}
if (versionStr == -1 ) {
if (versionStr == -1 ) {
return false;
} else if (versionStr != 0) {
if(isIE && isWin && !isOpera) {
tempArray = versionStr.split(\" \");
tempString = tempArray[1];
versionArray = tempString .split(\",\");
versionArray = tempString .split(\",\");
} else {
versionArray = versionStr.split(\".\");
}
versionMajor = versionArray[0];
versionMinor = versionArray[1];
versionRevision = versionArray[2];
versionString = versionMajor + \".\" + versionRevision; // 7.0r24 == 7.24
versionNum = parseFloat(versionString);
// is the major.revision >= requested major.revision AND the minor version >= requested minor
if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
return true;
} else {
return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
}
}
}
}
}
// -->
</script>";

@ -1,45 +1,41 @@
<?php // $Id$
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
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
* Exercise administration
* This script allows to manage an exercise. It is included from the script admin.php
* @package dokeos.exercise
==============================================================================
* @author Olivier Brouckaert
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
// name of the language file that needs to be included
$language_file='exercice';
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');
@ -97,9 +93,9 @@ else
*********************/
$nameTools=get_lang('ExerciseManagement');
$interbreadcrumb[] = array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
Display::display_header($nameTools,"Exercise");
$form -> display ();
}

@ -1,44 +1,38 @@
<?php // $Id: exercise_result.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* EXERCISE RESULT
*
* Exercise result
* This script gets informations from the script "exercise_submit.php",
* through the session, and calculates the score of the student for
* that exercise.
*
* Then it shows the results on the screen.
*
* @package dokeos.exercise
* @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring
* @package dokeos.exercise
* @version $Id: exercise_result.php 10789 2007-01-18 19:18:27Z pcool $
*
* @todo split more code up in functions, move functions to library?
* @todo use database library
==============================================================================
*/
/*
==============================================================================
INIT SECTION
@ -67,8 +61,8 @@ include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
include(api_get_path(LIBRARY_PATH).'mail.lib.inc.php');
// Database table definitions
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$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);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$TABLETRACK_EXERCICES = $_configuration['statistics_database']."`.`track_e_exercices";

@ -1,9 +1,34 @@
<?php
/*
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
* @todo remove the debug code and use the general debug library
* @todo use the Database:: functions
* @todo small letters for table variables
*/
*
* @package dokeos.exercise
* @author
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*
* @todo remove the debug code and use the general debug library
* @todo use the Database:: functions
* @todo small letters for table variables
*/
// name of the language file that needs to be included
$language_file='exercice';
@ -32,8 +57,8 @@ api_protect_course_script();
// Database table definitions
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$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);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);

@ -1,11 +1,36 @@
<?php
<?php
/*
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
* Feedback
* @package dokeos.exercise
* @author
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('exercise.lib.php');
// name of the language file that needs to be included
// name of the language file that needs to be included
$language_file='exercice';
include("../inc/global.inc.php");

@ -1,52 +1,48 @@
<?php // $Id: uniquer_answer.class.php 10234 2006-12-26
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* File containing the FillBlanks class.
*
* @author Eric Marguin
* @package dokeos.exercise
==============================================================================
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('FillBlanks')):
/**
CLASS FillBlanks
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package dokeos.exercise
**/
class FillBlanks extends Question {
static $typePicture = 'fill_in_blanks.png';
static $explanationLangVar = 'FillBlanks';
/**
* Constructor
*/
@ -54,29 +50,29 @@ class FillBlanks extends Question {
parent::question();
$this -> type = FILL_IN_BLANKS;
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm ($form) {
$defaults = array();
if(!empty($this->id))
{
$objAnswer = new answer($this->id);
$a_answer = explode('::', $objAnswer->selectAnswer(1));
$defaults['answer'] = $a_answer[0];
$a_weightings = explode(',',$a_answer[1]);
$a_weightings = explode(',',$a_answer[1]);
}
else
{
$defaults['answer'] = get_lang('DefaultTextInBlanks');
}
// javascript
echo '
<script type="text/javascript">
@ -85,7 +81,7 @@ class FillBlanks extends Question {
field = document.getElementById("answer");
var answer = field.value;
var blanks = answer.match(/\[[^\]]*\]/g);
var fields = "<div class=\"row\"><div class=\"label\">'.get_lang('Weighting').'</div><div class=\"formw\"><table>";
if(blanks!=null){
for(i=0 ; i<blanks.length ; i++){
@ -94,20 +90,20 @@ class FillBlanks extends Question {
else
value = "1";
fields += "<tr><td>"+blanks[i]+"</td><td><input size=\"5\" value=\""+value+"\" type=\"text\" id=\"weighting["+i+"]\" name=\"weighting["+i+"]\" /></td></tr>";
}
}
document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>";
if(firstTime){
firstTime = false;
';
if(count($a_weightings)>0)
{
{
foreach($a_weightings as $i=>$weighting)
{
echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
}
}
echo '}
@ -115,33 +111,33 @@ class FillBlanks extends Question {
window.onload = updateBlanks;
</script>
';
// answer
$form -> addElement ('html', '<br /><br /><div class="row"><div class="label"></div><div class="formw">'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank').'</div></div>');
$form -> addElement ('textarea', 'answer',get_lang('Answer'),'id="answer" cols="65" rows="6" onkeyup="updateBlanks(this)"');
$form -> addRule ('answer',get_lang('GiveText'),'required');
$form -> addRule ('answer',get_lang('DefineBlanks'),'regex','/\[.*\]/');
$form -> addElement('html','<div id="blanks_weighting"></div>');
$form -> setDefaults($defaults);
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
*/
function processAnswersCreation($form) {
function processAnswersCreation($form)
{
$answer = $form -> getSubmitValue('answer');
//remove the :: eventually written by the user
$answer = str_replace('::','',$answer);
// get the blanks weightings
$nb = preg_match_all('/\[[^\]]*\]/', $answer, $blanks);
if($nb>0)
@ -154,15 +150,11 @@ class FillBlanks extends Question {
}
$answer = substr($answer,0,-1);
}
$this -> save();
$objAnswer = new answer($this->id);
$objAnswer->createAnswer($answer,0,'',0,'');
$objAnswer->save();
}
}
endif;

@ -1,52 +1,40 @@
<?php // $Id: uniquer_answer.class.php 10234 2006-12-26
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* File containing the FreeAnswer class.
*
* @author Eric Marguin
* This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question
* @package dokeos.exercise
==============================================================================
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('FreeAnswer')):
/**
CLASS FreeAnswer
*
* This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question
*
* @author Eric Marguin
* @package dokeos.exercise
**/
class FreeAnswer extends Question {
static $typePicture = 'open_answer.png';
static $explanationLangVar = 'freeAnswer';
/**
* Constructor
*/
@ -54,13 +42,13 @@ class FreeAnswer extends Question {
parent::question();
$this -> type = FREE_ANSWER;
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm ($form) {
function createAnswersForm ($form) {
$form -> addElement('text','weighting',get_lang('Weighting'),'size="5"');
if(!empty($this->id))
{
@ -69,23 +57,19 @@ class FreeAnswer extends Question {
else {
$form -> setDefaults(array('weighting' => '1'));
}
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
*/
function processAnswersCreation($form) {
function processAnswersCreation($form)
{
$this -> weighting = $form -> getSubmitValue('weighting');
$this->save();
}
}
endif;
?>

@ -1,43 +1,40 @@
<?php
/*
==============================================================================
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) Istvan Mandak
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* Code library for HotPotatoes integration.
*
* @author Istvan Mandak
* @package dokeos.exercise
==============================================================================
* @author Istvan Mandak
* @version $Id: hotpotatoes.lib.php 10789 2007-01-18 19:18:27Z pcool $
*/
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
/**
* Creates a hotpotato directory
*
* If a directory of that name already exists, don't create any. If a file of that name exists, remove it and create a directory
* @param string Wanted path
* @return boolean Always true so far
* @return boolean Always true so far
*/
function hotpotatoes_init($baseWorkDir)
{
@ -57,130 +54,130 @@ function hotpotatoes_init($baseWorkDir)
}
//why create a .htaccess here?
//if (!is_file($documentPath.".htacces"))
//{
//{
// if (!($fp = fopen($documentPath.".htaccess", "w"))) {
// }
// $str = "order deny,allow\nallow from all";
// $str = "order deny,allow\nallow from all";
// if (!fwrite($fp,$str)) { }
//}
}
/**
* Gets the title of the quizz file given as parameter
* @param string File name
* @param string File name
* @param string File path
* @return string The exercise title
*/
*/
function GetQuizName($fname,$fpath)
{
$title = "";
$title = GetComment($fname);
if($title=="")
{
{
if (!($fp = fopen($fpath.$fname, "r"))) {
//die("could not open Quiz input");
return GetFileName($fname);
}
$contents = fread($fp, filesize($fpath.$fname));
fclose($fp);
fclose($fp);
$contents = strtolower($contents);
$pattern = array ( 1 => "title>", 2 => "/title>");
$s_contents = substr($contents,0,strpos($contents,$pattern["2"])-1);
$e_contents = substr($s_contents,strpos($contents,$pattern["1"])+strlen($pattern["1"]),strlen($s_contents));
$title = $e_contents;
}
return $title;
}
/**
* Gets the comment about a file from the corresponding database record
* @param string File path
* @return string Comment from the database record
*/
*/
function GetComment($path)
{
global $dbTable;
$query = "select comment from $dbTable where path='$path'";
$query = "select comment from $dbTable where path='$path'";
$result = api_sql_query($query,__FILE__,__LINE__);
while($row = mysql_fetch_array($result))
{
return $row[0];
while($row = mysql_fetch_array($result))
{
return $row[0];
}
return "";
return "";
}
/**
* Sets the comment in the database for a particular path
* @param string File path
* @param string Comment to set
* @return string Result of the database operation (api_sql_query will output some message directly on error anyway)
*/
* @return string Result of the database operation (api_sql_query will output some message directly on error anyway)
*/
function SetComment($path,$comment)
{
global $dbTable;
$query = "update $dbTable set comment='$comment' where path='$path'";
$query = "update $dbTable set comment='$comment' where path='$path'";
$result = api_sql_query($query,__FILE__,__LINE__);
return "$result";
return "$result";
}
/**
* Get the name of the file from a path (without the extension)
*
*
* This assumes the path is made of elements split by '/', not '\' or '\\'
* @param string Path
* @return string File name
*/
* @return string File name
*/
function GetFileName($fname)
{
$name = explode('/',$fname);
$name = $name[sizeof($name)-1];
return $name;
return $name;
}
/**
* Reads the file contents into a string
* @param string Urlencoded path
* @return string The file contents
*/
* @return string The file contents
*/
function ReadFileCont($full_file_path)
{
if (!($fp = fopen(urldecode($full_file_path), "r"))) {
// if (!($fp = fopen($full_file_path, "r"))) {
if (!($fp = fopen(urldecode($full_file_path), "r"))) {
// if (!($fp = fopen($full_file_path, "r"))) {
return "";
}
$contents = fread($fp, filesize($full_file_path));
fclose($fp);
fclose($fp);
return $contents;
}
}
/**
* Writes the file contents into the file given
* @param string Urlencoded path
* @param string The file contents
*/
* @param string The file contents
*/
function WriteFileCont($full_file_path,$content)
{
if (!($fp = fopen(urldecode($full_file_path), "w"))) {
if (!($fp = fopen(urldecode($full_file_path), "w"))) {
//die("could not open Quiz input");
}
fwrite($fp,$content);
fclose($fp);
}
fclose($fp);
}
/**
* Gets the name of an img whose path is given (without directories or extensions)
* @param string An image tag (<img src="...." ...>)
* @return string The image file name or an empty string
* @return string The image file name or an empty string
* @uses GetFileName No comment
*/
*/
function GetImgName($imgtag)
{ // select src tag from img tag
$match = array();
@ -190,21 +187,24 @@ function GetImgName($imgtag)
$src=$match[3];
//$src = substr($srctag,5,(strlen($srctag)-7));
if (stristr($src,"http")===false) // valid or invalid image name
{
{
if($src=="")
{ return ""; }
{
return "";
}
else
{
{
$tmp_src = GetFileName($src) ;
if ($tmp_src == "")
{
return $src;
} else {
return $src;
}
else
{
return $tmp_src;
}
}
}
}
else //the img tag contained "http", which means it is probably external. Ignore it.
{
return "";
@ -214,8 +214,8 @@ function GetImgName($imgtag)
/**
* Gets the source path of an image tag
* @param string An image tag
* @return string The image source or ""
*/
* @return string The image source or ""
*/
function GetSrcName($imgtag)
{ // select src tag from img tag
$match = array();
@ -223,11 +223,14 @@ function GetSrcName($imgtag)
list($key,$srctag)=each($match);
$src = substr($srctag,5,(strlen($srctag)-7));
if (stristr($src,"http")==false) // valid or invalid image name
{
{
return $src;
}
}
else
{ return ""; }
{
return '';
}
}
/**
@ -236,44 +239,44 @@ function GetSrcName($imgtag)
* @param string File path
* @param reference Reference to a list of image parameters (emptied, then used to return results)
* @param reference Reference to a counter of images (emptied, then used to return results)
*/
*/
function GetImgParams($fname,$fpath,&$imgparams,&$imgcount)
{ //select img tags from context
$imgparams = array();
//phpinfo();
//phpinfo();
$contents = ReadFileCont("$fpath"."$fname");
$matches = array();
preg_match_all("(<img .*>)",$contents,$matches);
$imgcount = 0;
preg_match_all("(<img .*>)",$contents,$matches);
$imgcount = 0;
while (list($int,$match)=each($matches))
{
//each match consists of a key and a value
while(list($key,$imgtag)=each($match))
{
$imgname = GetImgName($imgtag);
$imgname = GetImgName($imgtag);
if ($imgname!="" && !in_array($imgname,$imgparams)){
array_push($imgparams,$imgname); // name (+ type) of the images in the html test
$imgcount = $imgcount + 1; // number of images in the html test
}
}
}
}
}
/**
* Generates a list of hidden fields with the image params given as parameter to this function
* @param array List of image parameters
* @return string String containing the hidden parameters built from the list given
*/
* @return string String containing the hidden parameters built from the list given
*/
function GenerateHiddenList($imgparams)
{
$list = "";
if(is_array($imgparams)){
while (list($int,$string)=each($imgparams))
{
$list .= "<input type=\"hidden\" name=\"imgparams[]\" value=\"$string\" />\n";
$list .= "<input type=\"hidden\" name=\"imgparams[]\" value=\"$string\" />\n";
}
}
return $list;
return $list;
}
/**
@ -281,20 +284,20 @@ function GenerateHiddenList($imgparams)
* @param reference Reference to the array to search
* @param string Node we are looking for in the array
* @return mixed Node name or false if not found
*/
*/
function myarraysearch(&$array,$node)
{
$match = FALSE;
$tmp_array = array();
for($i=0;$i<count($array);$i++)
{
{
if (!strcmp($array[$i],$node))
{
{
$match = $node;
}
else
else
{ array_push($tmp_array,$array[$i]); }
}
}
$array = $tmp_array;
return $match;
}
@ -303,9 +306,9 @@ function myarraysearch(&$array,$node)
* Look for the image name into an array
* @param reference Reference to an array to search
* @param string String to look for
* @return mixed String given if found, false otherwise
* @return mixed String given if found, false otherwise
* @uses myarraysearch This function is just an additional layer on the myarraysearch() function
*/
*/
function CheckImageName(&$imgparams,$string)
{
$checked = myarraysearch($imgparams,$string);
@ -316,36 +319,36 @@ function CheckImageName(&$imgparams,$string)
* Replaces an image tag by ???
* @param string The content to replace
* @return string The modified content
*/
*/
function ReplaceImgTag($content)
{
{
$newcontent = $content;
$matches = array();
preg_match_all("(<img .*>)",$content,$matches);
$imgcount = 0;
preg_match_all("(<img .*>)",$content,$matches);
$imgcount = 0;
while (list($int,$match)=each($matches))
{
while(list($key,$imgtag)=each($match))
{
$imgname = GetSrcName($imgtag);
$imgname = GetSrcName($imgtag);
if ($imgname=="") {} // valid or invalid image name
else {
$prehref = $imgname;
$posthref = GetFileName($imgname);
$newcontent = str_replace($prehref,$posthref,$newcontent);
$newcontent = str_replace($prehref,$posthref,$newcontent);
}
}
}
}
return $newcontent;
return $newcontent;
}
/**
* Fills the folder name up to a certain length with "0"
* @param string Original folder name
* @param integer Length to reach
* @return string Modified folder name
*/
* @return string Modified folder name
*/
function FillFolderName($name,$nsize)
{
$str = "";
@ -360,8 +363,8 @@ function FillFolderName($name,$nsize)
/**
* Generates the HotPotato folder tree
* @param string Folder path
* @return string Folder name (modified)
*/
* @return string Folder name (modified)
*/
function GenerateHpFolder($folder)
{
$filelist = array();
@ -372,46 +375,46 @@ function GenerateHpFolder($folder)
{
$full_name = $folder."/".$file;
if (is_dir($full_name))
{
{
$filelist[] = $file;
}
}
}
}
}
}
$w = 0;
do {
$name = FillFolderName(mt_rand(1,99999),6);
$checked = myarraysearch($filelist,$name);
$name = FillFolderName(mt_rand(1,99999),6);
$checked = myarraysearch($filelist,$name);
//as long as we find the name in the array, continue looping. As soon as we have a new element, quit
if ($checked) { $w = 1; }
else { $w = 0; }
} while ($w==1);
return $name;
}
/**
* Gets the folder name (strip down path)
* @param string Path
* @return string Folder name stripped down
*/
* @return string Folder name stripped down
*/
function GetFolderName($fname)
{
{
$name = explode('/',$fname);
$name = $name[sizeof($name)-2];
$name = $name[sizeof($name)-2];
return $name;
}
/**
* Gets the folder path (withouth the name of the folder itself) ?
* @param string Path
* @return string Path stripped down
*/
* @return string Path stripped down
*/
function GetFolderPath($fname)
{
$str = "";
$name = explode('/',$fname);
{
$str = "";
$name = explode('/',$fname);
for($i=0;$i < sizeof($name)-1; $i++)
{ $str = $str.$name[$i]."/"; }
return $str;
@ -421,19 +424,19 @@ function GetFolderPath($fname)
* Checks if there are subfolders
* @param string Path
* @return integer 1 if a subfolder was found, 0 otherwise
*/
*/
function CheckSubFolder($path)
{
$folder = GetFolderPath($path);
$folder = GetFolderPath($path);
$dflag = 0;
if ($dir = @opendir($folder)) {
while (($file = readdir($dir)) !== false) {
if ( $file != ".") {
if ($file != "..") {
$full_name = $folder."/".$file;
if (is_dir($full_name)) {
if (is_dir($full_name)) {
$dflag = 1; // first directory
}
}
}
}
}
@ -443,11 +446,11 @@ function CheckSubFolder($path)
/**
* Hotpotato Garbage Collector
* @param string Path
* @param string Path
* @param integer Flag
* @param integer User id
* @return void No return value, but echoes results
*/
*/
function HotPotGCt($folder,$flag,$userID)
{ // Garbage Collector
$filelist = array();
@ -458,9 +461,9 @@ function HotPotGCt($folder,$flag,$userID)
{
$full_name = $folder."/".$file;
if (is_dir($full_name))
{
{
HotPotGCt($folder."/".$file,$flag,$userID);
}
}
else
{
$filelist[] = $file;
@ -470,16 +473,16 @@ function HotPotGCt($folder,$flag,$userID)
}
closedir($dir);
}
while (list ($key, $val) = each ($filelist))
while (list ($key, $val) = each ($filelist))
{
if (stristr($val,$userID.".t.html"))
{
{
if ($flag == 1)
{
my_delete($folder."/".$val);
my_delete($folder."/".$val);
}
else
{
{
echo $folder."/".$val."<br />";
}
}

@ -1,50 +1,49 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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) Istvan Mandak
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* Code for Hotpotatoes integration.
*
* @author Istvan Mandak
* @package dokeos.exercise
==============================================================================
* @author Istvan Mandak
* @version $Id: hotpotatoes.php 10789 2007-01-18 19:18:27Z pcool $
*/
$finish = (!empty($_POST['finish'])?$_POST['finish']:0);
$imgcount = (!empty($_POST['imgcount'])?$_POST['imgcount']:null);
$fld = (!empty($_POST['fld'])?$_POST['fld']:null);
// name of the language file that needs to be included
// name of the language file that needs to be included
$language_file ='exercice';
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
$finish = (!empty($_POST['finish'])?$_POST['finish']:0);
$imgcount = (!empty($_POST['imgcount'])?$_POST['imgcount']:null);
$fld = (!empty($_POST['fld'])?$_POST['fld']:null);
include_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
include_once(api_get_path(LIBRARY_PATH).'document.lib.php');
$interbreadcrumb[]= array ("url"=>"./exercice.php", "name"=> get_lang('Exercices'));
$is_allowedToEdit=(!empty($is_courseAdmin)?$is_courseAdmin:false);
//$dbTable = '`'.$_course['dbNameGlu']."document`";
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
$baseServDir = $_configuration['root_sys'];
$baseServUrl = $_configuration['url_append']."/";
@ -57,7 +56,7 @@ if ($is_allowedToEdit)
include("hotpotatoes.lib.php");
//disable document parsing(?) - obviously deprecated
$enableDocumentParsing=false;
if(hotpotatoes_init($document_sys_path.$uploadPath))
{//if the directory doesn't exist
//create the "HotPotatoes" directory
@ -82,7 +81,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
//check that the submit button was pressed when the button had the "Download" value
//This should be updated to "upload" here and on the button, and it would be better to
// check something else than a string displayd on a button
if (strcmp($_POST['submit'],get_lang('Download'))===0)
if (strcmp($_POST['submit'],get_lang('Download'))===0)
{
/** el kell tarolni <- english please */
include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
@ -90,13 +89,13 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
FILEMANAGER BASIC VARIABLES DEFINITION
======================================*/
include_once(api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
//@todo: this value should be moved to the platform admin section
$maxFilledSpace = 100000000;
//initialise $finish
if (!isset($finish)) {$finish = 0;}
//if the size is not defined, it's probably because there has been an error or no file was submitted
if(!$_FILES['userFile']['size'])
{
@ -118,7 +117,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
}
if ($finish==0)
{ //generate new test folder if on first step of file upload
$filename = replace_dangerous_char(trim($_FILES['userFile']['name']),'strict');
$filename = replace_dangerous_char(trim($_FILES['userFile']['name']),'strict');
$fld = GenerateHpFolder($document_sys_path.$uploadPath."/");
@mkdir($document_sys_path.$uploadPath."/".$fld);
$doc_id = add_document($_course, '/HotPotatoes_files/'.$fld,'folder',0,$fld);
@ -126,22 +125,22 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
}
else
{ //it is not the first step... get the filename directly from the system params
$filename = $_FILES['userFile']['name'];
}
$filename = $_FILES['userFile']['name'];
}
/*if (treat_uploaded_file($_FILES['userFile'], $document_sys_path,
$uploadPath."/".$fld, $maxFilledSpace, $unzip))*/
$allow_output_on_success = false;
if (handle_uploaded_document($_course,$_FILES['userFile'],$document_sys_path,$uploadPath."/".$fld,$_user['user_id'],null,null,$maxFilledSpace,$unzip,'',$allow_output_on_success))
{
if ($finish==2)
{
$checked = CheckImageName($imgparams,$filename);
if ($checked)
{ $imgcount = $imgcount-1; }
else
{
{
$dialogBox .= $filename." ".get_lang('NameNotEqual');
my_delete($document_sys_path.$uploadPath."/".$fld."/".$filename);
update_db_info("delete", $uploadPath."/".$fld."/".$filename);
@ -154,7 +153,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
else
{ //if we are (still) on the first step of the upload process
if ($finish==0)
{
{
$finish = 2;
// get number and name of images from the files contents
GetImgParams("/".$filename,$document_sys_path.$uploadPath."/".$fld,$imgparams,$imgcount);
@ -165,10 +164,10 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
}
}
$newComment = "";
$query = "UPDATE $dbTable SET comment='$newComment' WHERE path=\"".$uploadPath."/".$fld."/".$filename."\"";
$query = "UPDATE $dbTable SET comment='$newComment' WHERE path=\"".$uploadPath."/".$fld."/".$filename."\"";
/*, visibility='v' */
api_sql_query($query,__FILE__,__LINE__);
api_item_property_update($_course, TOOL_QUIZ, $id, "QuizAdded", $_user['user_id']);
}
@ -180,7 +179,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
//$dialogBox .= get_lang('NoImg');
}
$finish = 0; // error
if (api_failure::get_last_failure() == 'not_enough_space')
{
$dialogBox .= get_lang('NoSpace');
@ -189,9 +188,9 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
{
$dialogBox .= get_lang('ZipNoPhp');
}
}
/* if ($oke==1)
{ $enableDocumentParsing=true; $oke=0;}
*/
@ -202,8 +201,8 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
{ /** ok -> send to main exercises page */
header("Location: exercice.php");
exit;
}
}
Display::display_header($nameTools,"Exercise");
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
/* -----*/
@ -226,7 +225,7 @@ if(($is_allowedToEdit) && (($finish == 0) || ($finish == 2)))
{
$dialogBox.= get_lang('ImgNote_st').$imgcount.get_lang('ImgNote_en')."<br>";
while(list($key,$string)=each($imgparams))
{
{
$dialogBox.=$string."; ";
}
}
@ -274,7 +273,7 @@ else
{ // ok
//include("exercice.php");
header("Location: exercice.php");
}
}
else
{
}

@ -1,35 +1,31 @@
<?php // $Id: hotspot.class.php 10234 2006-12-26
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* File containing the HotSpot class.
*
* @author Eric Marguin
* @package dokeos.exercise
==============================================================================
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('HotSpot')):
/**
@ -43,10 +39,10 @@ if(!class_exists('HotSpot')):
**/
class HotSpot extends Question {
static $typePicture = 'hotspot.png';
static $explanationLangVar = 'Hotspot';
function HotSpot(){
parent::question();
@ -75,7 +71,7 @@ class HotSpot extends Question {
$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
$this->resizePicture('any',350);
$this->save();
}
}
}
function createAnswersForm ($form) {

@ -1,118 +1,98 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file generates the ActionScript variables code used by the HotSpot .swf
*
* @author Toon Keppens
* @package dokeos.exercise
==============================================================================
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$questionId = $_GET['modifyAnswers'];
$objQuestion = Question::read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$dbNameGlu = $_course['dbNameGlu'];
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$picturePath = $documentPath.'/images';
$pictureName = $objQuestion->selectPicture();
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
// Query db for answers
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
$result = api_sql_query($sql,__FILE__,__LINE__);
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
$i = 0;
$nmbrTries = 0;
while ($hotspot = mysql_fetch_assoc($result))
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$questionId = $_GET['modifyAnswers'];
$objQuestion = Question::read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$picturePath = $documentPath.'/images';
$pictureName = $objQuestion->selectPicture();
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
// Query db for answers
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
$result = api_sql_query($sql,__FILE__,__LINE__);
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
$i = 0;
$nmbrTries = 0;
while ($hotspot = mysql_fetch_assoc($result))
{
$output .= "&hotspot_".$hotspot['id']."=true";
$output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
// Square or rectancle
if ($hotspot['hotspot_type'] == 'square' )
{
$output .= "&hotspot_".$hotspot['id']."=true";
$output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
// Square or rectancle
if ($hotspot['hotspot_type'] == 'square' )
{
$output .= "&hotspot_".$hotspot['id']."_type=square";
}
// Circle or ovale
if ($hotspot['hotspot_type'] == 'circle')
{
$output .= "&hotspot_".$hotspot['id']."_type=circle";
}
// Polygon
if ($hotspot['hotspot_type'] == 'poly')
{
$output .= "&hotspot_".$hotspot['id']."_type=poly";
}
// This is a good answer, count + 1 for nmbr of clicks
if ($hotspot['hotspot_type'] > 0)
{
$nmbrTries++;
}
$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
$i++;
$output .= "&hotspot_".$hotspot['id']."_type=square";
}
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
// Circle or ovale
if ($hotspot['hotspot_type'] == 'circle')
{
$output .= "&hotspot_".$hotspot['id']."_type=circle";
}
// Polygon
if ($hotspot['hotspot_type'] == 'poly')
{
$output .= "&hotspot_".$i."=false";
$output .= "&hotspot_".$hotspot['id']."_type=poly";
}
// Output
echo $output."&nmbrTries=".$nmbrTries."&done=done";
// This is a good answer, count + 1 for nmbr of clicks
if ($hotspot['hotspot_type'] > 0)
{
$nmbrTries++;
}
/*echo '<pre>';
$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
$i++;
var_dump($explode);
}
echo '</pre>';*/
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
{
$output .= "&hotspot_".$i."=false";
}
// Output
echo $output."&nmbrTries=".$nmbrTries."&done=done";
?>

@ -1,113 +1,106 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file generates the ActionScript variables code used by the HotSpot .swf
*
* @author Toon Keppens
* @package dokeos.exercise
==============================================================================
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$questionId = $_GET['modifyAnswers'];
$objQuestion = Question::read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$dbNameGlu = $_course['dbNameGlu'];
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$questionId = $_GET['modifyAnswers'];
$objQuestion = Question::read($questionId);
$picturePath = $documentPath.'/images';
$pictureName = $objQuestion->selectPicture();
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
$picturePath = $documentPath.'/images';
$pictureName = $objQuestion->selectPicture();
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
// Query db for answers
//$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
//$result = api_sql_query($sql,__FILE__,__LINE__);
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
$i = 0;
$nmbrTries = 0;
// Query db for answers
//$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
//$result = api_sql_query($sql,__FILE__,__LINE__);
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
$i = 0;
$nmbrTries = 0;
$answers=$_SESSION['tmp_answers'];
$nbrAnswers = count($answers['answer']);
for($i=1;$i <= $nbrAnswers;$i++)
{
$output .= "&hotspot_".$i."=true";
$output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
$answers=$_SESSION['tmp_answers'];
$nbrAnswers = count($answers['answer']);
// Square or rectancle
if ($answers['hotspot_type'][$i] == 'square' )
{
$output .= "&hotspot_".$i."_type=square";
}
for($i=1;$i <= $nbrAnswers;$i++)
{
$output .= "&hotspot_".$i."=true";
$output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
// Circle or ovale
if ($answers['hotspot_type'][$i] == 'circle')
{
$output .= "&hotspot_".$i."_type=circle";
}
// Polygon
if ($answers['hotspot_type'][$i] == 'poly')
{
$output .= "&hotspot_".$i."_type=poly";
}
// Square or rectancle
if ($answers['hotspot_type'][$i] == 'square' )
{
$output .= "&hotspot_".$i."_type=square";
}
// This is a good answer, count + 1 for nmbr of clicks
if ($answers['weighting'][$i] > 0)
{
$nmbrTries++;
}
// Circle or ovale
if ($answers['hotspot_type'][$i] == 'circle')
{
$output .= "&hotspot_".$i."_type=circle";
}
$output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
}
// Polygon
if ($answers['hotspot_type'][$i] == 'poly')
{
$output .= "&hotspot_".$i."_type=poly";
}
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
// This is a good answer, count + 1 for nmbr of clicks
if ($answers['weighting'][$i] > 0)
{
$output .= "&hotspot_".$i."=false";
$nmbrTries++;
}
// Output
echo $output."&nmbrTries=".$nmbrTries."&done=done";
$output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
}
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
{
$output .= "&hotspot_".$i."=false";
}
// Output
echo $output."&nmbrTries=".$nmbrTries."&done=done";
?>

@ -1,36 +1,30 @@
<?php // $Id: answer_admin.inc.php 10285 2006-12-04 10:52:39 +0100 (lun., 04 déc. 2006) develop-it $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/*>>>>>>>>>>>>>>>>>>>> ANSWER ADMINISTRATION <<<<<<<<<<<<<<<<<<<<*/
/**
==============================================================================
* This script allows to manage answers
*
* It is included from the script admin.php
* @author Olivier Brouckaert
* @package dokeos.exercise
==============================================================================
*/
* This script allows to manage answers. It is included from the script admin.php
* @package dokeos.exercise
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
// ALLOWED_TO_INCLUDE is defined in admin.php
if(!defined('ALLOWED_TO_INCLUDE'))

@ -1,129 +1,107 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file generates the ActionScript variables code used by the HotSpot .swf
*
* @author Toon Keppens
* @package dokeos.exercise
==============================================================================
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
//include('../inc/lib/database.inc.lib');
// set vars
$userId = $_user['user_id'];
$questionId = $_GET['modifyAnswers'];
$objQuestion = Question :: read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$dbNameGlu = $_course['dbNameGlu'];
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$picturePath = $documentPath.'/images';
$pictureName = $objQuestion->selectPicture();
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
// Query db for answers
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
$result = api_sql_query($sql,__FILE__,__LINE__);
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
$i = 0;
while ($hotspot = mysql_fetch_array($result)) {
$output .= "&hotspot_".$hotspot['id']."=true";
// Square or rectancle
if ($hotspot['hotspot_type'] == 'square' )
{
$output .= "&hotspot_".$hotspot['id']."_type=square";
}
// Circle or ovale
if ($hotspot['hotspot_type'] == 'circle')
{
$output .= "&hotspot_".$hotspot['id']."_type=circle";
}
// Polygon
if ($hotspot['hotspot_type'] == 'poly')
{
$output .= "&hotspot_".$hotspot['id']."_type=poly";
}
$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
$i++;
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
// set vars
$userId = $_user['user_id'];
$questionId = $_GET['modifyAnswers'];
$objQuestion = Question :: read($questionId);
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$picturePath = $documentPath.'/images';
$pictureName = $objQuestion->selectPicture();
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$courseLang = $_course['language'];
$courseCode = $_course['sysCode'];
$coursePath = $_course['path'];
// Query db for answers
$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
$result = api_sql_query($sql,__FILE__,__LINE__);
// Init
$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
$i = 0;
while ($hotspot = mysql_fetch_array($result))
{
$output .= "&hotspot_".$hotspot['id']."=true";
// Square or rectancle
if ($hotspot['hotspot_type'] == 'square' )
{
$output .= "&hotspot_".$hotspot['id']."_type=square";
}
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
// Circle or ovale
if ($hotspot['hotspot_type'] == 'circle')
{
$output .= "&hotspot_".$i."=false";
$output .= "&hotspot_".$hotspot['id']."_type=circle";
}
// set vars
$questionId = $_GET['modifyAnswers'];
$courseCode = $_course['sysCode'];
// Get clicks
foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
// Polygon
if ($hotspot['hotspot_type'] == 'poly')
{
$output2 .= $coordinate."|";
$output .= "&hotspot_".$hotspot['id']."_type=poly";
}
//var_dump($_SESSION['exerciseResultCoordinates']);
// Output
$output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
$i++;
}
$explode = explode('&', $output);
// Generate empty
$i++;
for ($i; $i <= 12; $i++)
{
$output .= "&hotspot_".$i."=false";
}
/*echo '<pre>';
// set vars
$questionId = $_GET['modifyAnswers'];
$courseCode = $_course['sysCode'];
var_dump($explode);
// Get clicks
foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
{
$output2 .= $coordinate."|";
}
echo '</pre>';*/
$output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
echo $output;
$explode = explode('&', $output);
echo $output;
?>

@ -1,4 +1,31 @@
<?php
/*
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
* Hotspot languae conversion
* @package dokeos.exercise
* @author
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include_once('../inc/global.inc.php');
$hotspot_lang_file = api_get_path(SYS_LANG_PATH);
@ -22,16 +49,16 @@ $temp = array();
foreach($file as $value)
{
$explode = explode('=', $value);
if(count($explode) > 1)
{
$explode[0] = trim($explode[0]);
$explode[0] = '&' . substr($explode[0], 1, strlen($explode[0]));
$explode[1] = trim($explode[1]);
$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
$explode[1] = ereg_replace('"', '', $explode[1]);
$temp[] = $explode[0] . '=' . $explode[1];
}
}

@ -1,72 +1,67 @@
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* This file generates the ActionScript code used by the HotSpot .swf
*
* @author Toon Keppens
* @package dokeos.exercise
==============================================================================
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
$TBL_ANSWER = $_GET['dbNameGlu']."quiz_answer";
$questionId = $_GET['questionId'];
$answerId = $_GET['answerId'];
if ($_GET['type'] == "square" || $_GET['type'] == "circle")
{
$hotspot_type = $_GET['type'];
$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
}
if ($_GET['type'] == "poly")
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
$questionId = $_GET['questionId'];
$answerId = $_GET['answerId'];
if ($_GET['type'] == "square" || $_GET['type'] == "circle")
{
$hotspot_type = $_GET['type'];
$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
}
if ($_GET['type'] == "poly")
{
$hotspot_type = $_GET['type'];
$tmp_coord = explode(",",$_GET['co']);
$i = 0;
$hotspot_coordinates = "";
foreach ($tmp_coord as $coord)
{
$hotspot_type = $_GET['type'];
$tmp_coord = explode(",",$_GET['co']);
$i = 0;
$hotspot_coordinates = "";
foreach ($tmp_coord as $coord)
if ($i%2 == 0)
{
$delimiter = ";";
}
else
{
if ($i%2 == 0)
{
$delimiter = ";";
} else
{
$delimiter = "|";
}
$hotspot_coordinates .= $coord.$delimiter;
$i++;
$delimiter = "|";
}
$hotspot_coordinates = substr($hotspot_coordinates,0,-2);
$hotspot_coordinates .= $coord.$delimiter;
$i++;
}
$sql = "UPDATE `$TBL_ANSWER` SET `hotspot_coordinates` = '$hotspot_coordinates',`hotspot_type` = '$hotspot_type' WHERE `id` =$answerId AND `question_id` =$questionId LIMIT 1 ;";
$result = api_sql_query($sql,__FILE__,__LINE__);
echo "done=done";
$hotspot_coordinates = substr($hotspot_coordinates,0,-2);
}
$sql = "UPDATE `$TBL_ANSWER` SET `hotspot_coordinates` = '$hotspot_coordinates',`hotspot_type` = '$hotspot_type' WHERE `id` =$answerId AND `question_id` =$questionId LIMIT 1 ;";
$result = api_sql_query($sql,__FILE__,__LINE__);
echo "done=done";
?>

@ -1,75 +1,60 @@
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* This file saves every click in the hotspot tool into track_e_hotspots
*
* @author Toon Keppens
* @package dokeos.exercise
==============================================================================
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
include('../inc/lib/database.lib.php');
$courseCode = $_GET['coursecode'];
$questionId = $_GET['questionId'];
$coordinates = $_GET['coord'];
$objExcercise = $_SESSION['objExercise'];
$exerciseId = $objExcercise->selectId();
// Save clicking order
$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
if ($_GET['answerId'] == "0") // click is NOT on a hotspot
{
$hit = 0;
$answerId = NULL;
}
else // user clicked ON a hotspot
{
$hit = 1;
$answerId = substr($_GET['answerId'],22,2);
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
}
$TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
// Save into db
$sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('".$_user['user_id']."', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')";
$result = api_sql_query($sql,__FILE__,__LINE__);
// Save insert id into session if users changes answer.
$insert_id = mysql_insert_id();
$_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id;
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
include('../inc/lib/database.lib.php');
$courseCode = $_GET['coursecode'];
$questionId = $_GET['questionId'];
$coordinates = $_GET['coord'];
$objExcercise = $_SESSION['objExercise'];
$exerciseId = $objExcercise->selectId();
// Save clicking order
$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
if ($_GET['answerId'] == "0") // click is NOT on a hotspot
{
$hit = 0;
$answerId = NULL;
}
else // user clicked ON a hotspot
{
$hit = 1;
$answerId = substr($_GET['answerId'],22,2);
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
}
$TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
// Save into db
$sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('".$_user['user_id']."', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')";
$result = api_sql_query($sql,__FILE__,__LINE__);
// Save insert id into session if users changes answer.
$insert_id = mysql_insert_id();
$_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id;
?>

@ -1,77 +1,72 @@
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* This file saves every click in the hotspot tool into track_e_hotspots
*
* @author Toon Keppens
* @package dokeos.exercise
==============================================================================
* @author Toon Keppens
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
include('../inc/lib/database.lib.php');
$courseCode = $_GET['coursecode'];
$questionId = $_GET['questionId'];
$coordinates = $_GET['coord'];
$objExcercise = $_SESSION['objExercise'];
$hotspotId = $_GET['hotspotId'];
$exerciseId = $objExcercise->selectId();
if ($_GET['answerId'] == "0") // click is NOT on a hotspot
{
$hit = 0;
$answerId = $hotspotId;
// remove from session
unset($_SESSION['exerciseResult'][$questionId][$answerId]);
// Save clicking order
//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
}
else // user clicked ON a hotspot
{
$hit = 1;
$answerId = $hotspotId;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
// Save clicking order
//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
}
$TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
// update db
$update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId];
$sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET `coordinate` = '".$coordinates."' WHERE `id` =$update_id LIMIT 1 ;;";
$result = api_sql_query($sql,__FILE__,__LINE__);
include('exercise.class.php');
include('question.class.php');
include('answer.class.php');
include('../inc/global.inc.php');
$courseCode = $_GET['coursecode'];
$questionId = $_GET['questionId'];
$coordinates = $_GET['coord'];
$objExcercise = $_SESSION['objExercise'];
$hotspotId = $_GET['hotspotId'];
$exerciseId = $objExcercise->selectId();
if ($_GET['answerId'] == "0") // click is NOT on a hotspot
{
$hit = 0;
$answerId = $hotspotId;
// remove from session
unset($_SESSION['exerciseResult'][$questionId][$answerId]);
// Save clicking order
//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
}
else // user clicked ON a hotspot
{
$hit = 1;
$answerId = $hotspotId;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
// Save clicking order
//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
}
$TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
// update db
$update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId];
$sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET `coordinate` = '".$coordinates."' WHERE `id` =$update_id LIMIT 1 ;;";
$result = api_sql_query($sql,__FILE__,__LINE__);
?>

@ -1,35 +1,31 @@
<?php // $Id: mark_free_answer.php,v 1.1.2.1 2005/08/30 01:47:37 yannoo Exp $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
DOKEOS - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2005 Yannick Warnier <yannick.warnier@dokeos.com>
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* FREE ANSWER MARKING SCRIPT
*
* This script allows a course tutor to mark a student's free answer.
* @author Yannick Warnier <yannick.warnier@dokeos.com>
* Free answer marking script
* This script allows a course tutor to mark a student's free answer.
* @package dokeos.exercise
* @author Yannick Warnier <yannick.warnier@dokeos.com>
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*
* @todo use the Database:: functions
* @todo respect coding guidelines
==============================================================================
*/
/*
@ -60,8 +56,8 @@ define('FREE_ANSWER', 5);
/** @todo use the Database:: functions */
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$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);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);

@ -1,53 +1,49 @@
<?php // $Id: uniquer_answer.class.php 10234 2006-12-26
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* File containing the Matching class.
*
* @author Eric Marguin
* @package dokeos.exercise
==============================================================================
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('Matching')):
/**
CLASS Matching
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package dokeos.exercise
**/
class Matching extends Question {
static $typePicture = 'matching.png';
static $explanationLangVar = 'Matching';
/**
* Constructor
*/
@ -55,20 +51,20 @@ class Matching extends Question {
parent::question();
$this -> type = MATCHING;
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm ($form) {
function createAnswersForm ($form) {
$defaults = array();
$nb_matches = $nb_options = 2;
if($form -> isSubmitted())
{
$nb_matches = $form -> getSubmitValue('nb_matches');
$nb_options = $form -> getSubmitValue('nb_options');
$nb_options = $form -> getSubmitValue('nb_options');
if(isset($_POST['lessMatches']))
$nb_matches--;
if(isset($_POST['moreMatches']))
@ -77,9 +73,9 @@ class Matching extends Question {
$nb_options--;
if(isset($_POST['moreOptions']))
$nb_options++;
}
else if(!empty($this -> id))
else if(!empty($this -> id))
{
$answer = new Answer($this -> id);
$answer -> read();
@ -89,7 +85,7 @@ class Matching extends Question {
$nb_matches = $nb_options = 0;
for($i=1 ; $i<=$answer->nbrAnswers ; $i++){
if($answer -> isCorrect($i))
{
{
$nb_matches++;
$defaults['answer['.$nb_matches.']'] = $answer -> selectAnswer($i);
$defaults['weighting['.$nb_matches.']'] = $answer -> selectWeighting($i);
@ -101,12 +97,12 @@ class Matching extends Question {
$defaults['option['.$nb_options.']'] = $answer -> selectAnswer($i);
}
}
}
}
else {
$defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1');
$defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
$defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
$defaults['matches[2]'] = '2';
$defaults['option[1]'] = get_lang('DefaultMatchingOptA');
$defaults['option[2]'] = get_lang('DefaultMatchingOptB');
@ -116,19 +112,19 @@ class Matching extends Question {
{
$a_matches[$i] = chr(64+$i); // fill the array with A, B, C.....
}
$form -> addElement('hidden', 'nb_matches', $nb_matches);
$form -> addElement('hidden', 'nb_options', $nb_options);
////////////////////////
// DISPLAY MATCHES ////
//////////////////////
//////////////////////
$html='
<div class="row">
<div class="label">
@ -153,34 +149,34 @@ class Matching extends Question {
<td width="0"></td>
</tr>';
$form -> addElement ('html', $html);
for($i = 1 ; $i <= $nb_matches ; ++$i)
{
$form -> addElement ('html', '<tr><td>');
$group = array();
$puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"');
$puce->freeze();
$puce->freeze();
$group[] = $puce;
$group[] = FormValidator :: createElement ('text', 'answer['.$i.']',null, 'size="30"');
$group[] = FormValidator :: createElement ('select', 'matches['.$i.']',null,$a_matches);
$group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="2" value="1"');
$form -> addGroup($group, null, null, '</td><td width="0">');
$form -> addElement ('html', '</td></tr>');
}
$form -> addElement ('html', '</table></div></div>');
$form -> addElement ('html', '</table></div></div>');
$group = array();
$group[] = FormValidator :: createElement ('submit', 'lessMatches', '-elem');
$group[] = FormValidator :: createElement ('submit', 'moreMatches', '+elem');
$form -> addGroup($group);
////////////////////////
// DISPLAY OPTIONS ////
//////////////////////
@ -200,50 +196,50 @@ class Matching extends Question {
<td width="0"></td>
</tr>';
$form -> addElement ('html', $html);
for($i = 1 ; $i <= $nb_options ; ++$i)
{
$form -> addElement ('html', '<tr><td>');
$group = array();
$puce = FormValidator :: createElement ('text', null,null,'value="'.chr(64+$i).'"');
$puce->freeze();
$puce->freeze();
$group[] = $puce;
$group[] = FormValidator :: createElement ('text', 'option['.$i.']',null, 'size="30"');
$form -> addGroup($group, null, null, '</td><td width="0">');
$form -> addElement ('html', '</td></tr>');
}
$form -> addElement ('html', '</table></div></div>');
$form -> addElement ('html', '</table></div></div>');
$group = array();
$group[] = FormValidator :: createElement ('submit', 'lessOptions', '-elem');
$group[] = FormValidator :: createElement ('submit', 'moreOptions', '+elem');
$form -> addGroup($group);
$form -> setDefaults($defaults);
$form->setConstants(array('nb_matches' => $nb_matches,'nb_options' => $nb_options));
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
*/
function processAnswersCreation($form) {
$nb_matches = $form -> getSubmitValue('nb_matches');
$nb_options = $form -> getSubmitValue('nb_options');
$this -> weighting = 0;
$objAnswer = new Answer($this->id);
$position = 0;
// insert the options
for($i=1 ; $i<=$nb_options ; ++$i)
{
@ -251,7 +247,7 @@ class Matching extends Question {
$option = $form -> getSubmitValue('option['.$i.']');
$objAnswer->createAnswer($option, 0, '', 0, $position);
}
// insert the answers
for($i=1 ; $i<=$nb_matches ; ++$i)
{
@ -262,12 +258,12 @@ class Matching extends Question {
$this -> weighting += $weighting;
$objAnswer->createAnswer($answer,$matches,'',$weighting,$position);
}
$objAnswer->save();
$this->save();
}
}
endif;

@ -1,52 +1,47 @@
<?php // $Id: uniquer_answer.class.php 10234 2006-12-26
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* File containing the MultipleAnswer class.
*
* @author Eric Marguin
* @package dokeos.exercise
==============================================================================
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('MultipleAnswer')):
/**
CLASS MultipleAnswer
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package dokeos.exercise
**/
class MultipleAnswer extends Question {
static $typePicture = 'mcma.png';
static $explanationLangVar = 'MultipleSelect';
/**
* Constructor
*/
@ -54,26 +49,26 @@ class MultipleAnswer extends Question {
parent::question();
$this -> type = MULTIPLE_ANSWER;
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
* @param the answers number to display
*/
function createAnswersForm ($form) {
global $fck_attribute;
$fck_attribute = array();
$fck_attribute['Width'] = '300px';
$fck_attribute['Height'] = '100px';
$fck_attribute['ToolbarSet'] = 'Small';
$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$html='
<div class="row">
<div class="label">
@ -100,23 +95,23 @@ class MultipleAnswer extends Question {
<td width="0"></td>
</tr>';
$form -> addElement ('html', $html);
$defaults = array();
if(!empty($this -> id))
if(!empty($this -> id))
{
$answer = new Answer($this -> id);
$answer -> read();
$answer -> read();
if(count($answer->nbrAnswers)>0 && !$form->isSubmitted())
{
$nb_answers = $answer->nbrAnswers;
}
}
$form -> addElement('hidden', 'nb_answers');
for($i = 1 ; $i <= $nb_answers ; ++$i)
{
if(is_object($answer))
{
$defaults['answer['.$i.']'] = $answer -> answer[$i];
@ -124,57 +119,57 @@ class MultipleAnswer extends Question {
$defaults['weighting['.$i.']'] = $answer -> weighting[$i];
$defaults['correct['.$i.']'] = $answer -> correct[$i];
}
$form -> addElement ('html', '<tr><td>');
$group = array();
$puce = FormValidator :: createElement ('text', null,null,'value="1"');
$puce->freeze();
$puce->freeze();
$group[] = $puce;
$group[] = FormValidator :: createElement ('checkbox', 'correct['.$i.']', null, null, $i);
$group[] = FormValidator :: createElement ('checkbox', 'correct['.$i.']', null, null, $i);
$group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"');
$form -> addGroup($group, null, null, '</td><td width="0">');
$form -> addElement ('html', '</td></tr>');
}
$form -> addElement ('html', '</table></div></div>');
$form -> addElement ('html', '</table></div></div>');
$group = array();
$group[] = FormValidator :: createElement ('submit', 'lessAnswers', '-answ');
$group[] = FormValidator :: createElement ('submit', 'moreAnswers', '+answ');
$form -> addGroup($group);
$form -> setDefaults($defaults);
$form->setConstants(array('nb_answers' => $nb_answers));
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
* @param the answers number to display
*/
function processAnswersCreation($form) {
$questionWeighting = $nbrGoodAnswers = 0;
$objAnswer = new Answer($this->id);
$nb_answers = $form -> getSubmitValue('nb_answers');
for($i=1 ; $i <= $nb_answers ; $i++)
{
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
$goodAnswer = trim($form -> getSubmitValue('correct['.$i.']'));
if($goodAnswer)
if($goodAnswer)
{
$nbrGoodAnswers++;
$weighting = abs($weighting);
@ -183,20 +178,20 @@ class MultipleAnswer extends Question {
$questionWeighting += $weighting;
}
}
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i);
}
// saves the answers into the data base
$objAnswer -> save();
// sets the total weighting of the question
$this -> updateWeighting($questionWeighting);
$this -> save();
}
}
endif;

@ -1,35 +1,31 @@
<?php // $Id: question.class.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* File containing the Question class.
*
* @author Olivier Brouckaert
* @package dokeos.exercise
==============================================================================
* @author Olivier Brouckaert
* @version $Id: question.class.php 10789 2007-01-18 19:18:27Z pcool $
*/
if(!class_exists('Question')):
// answer types
@ -105,9 +101,9 @@ abstract class Question
{
global $_course;
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$sql="SELECT question,description,ponderation,position,type,picture FROM `$TBL_QUESTIONS` WHERE id='$id'";
$result=api_sql_query($sql,__FILE__,__LINE__);

@ -1,35 +1,30 @@
<? // $Id: question_admin.inc.php 10691 2007-01-12 12:16:28Z elixir_inter $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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)
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* STATEMENT ADMINISTRATION
* Statement (?) administration
* This script allows to manage the statements of questions.
* It is included from the script admin.php
*
* @author Olivier Brouckaert
* It is included from the script admin.php
* @package dokeos.exercise
==============================================================================
* @author Olivier Brouckaert
* @version $Id: question_admin.inc.php 10789 2007-01-18 19:18:27Z pcool $
*/
/*
@ -79,65 +74,63 @@ if(is_object($objQuestion))
</style>
';
echo $styles;
/*********************
* INIT FORM
*********************/
$form = new FormValidator('question_admin_form','post',$action);
/*********************
* FORM CREATION
*********************/
$objQuestion -> createForm ($form);
$objQuestion -> createAnswersForm ($form);
$objQuestion -> createForm ($form);
$objQuestion -> createAnswersForm ($form);
$form->addElement('submit','submitQuestion',get_lang('Ok'));
/**********************
* FORM VALIDATION
* FORM VALIDATION
**********************/
if(isset($_POST['submitQuestion']) && $form->validate())
{
{
// question
$objQuestion -> processCreation($form,$objExercise);
// 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
{
else
{
/******************
* FORM DISPLAY
******************/
echo '<h3>'.$questionName.'</h3>';
if(!empty($pictureName)){
echo '<img src="../document/download.php?doc_url=%2Fimages%2F'.$pictureName.'" border="0">';
}
if(!empty($msgErr))
{
Display::display_normal_message($msgErr); //main API
}
// display the form
$form->display();
}
}
?>

@ -1,36 +1,41 @@
<?php // $Id: question_list_admin.inc.php 10748 2007-01-17 08:22:39Z elixir_inter $
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
* Code library for HotPotatoes integration.
* @package dokeos.exercise
* @author
* @version $Id: question_list_admin.inc.php 10789 2007-01-18 19:18:27Z pcool $
*/
/**
==============================================================================
* QUESTION LIST ADMINISTRATION
==============================================================================
* QUESTION LIST ADMINISTRATION
*
* This script allows to manage the question list
* It is included from the script admin.php
*
* @author Olivier Brouckaert
* @package dokeos.exercise
==============================================================================
==============================================================================
*/
// ALLOWED_TO_INCLUDE is defined in admin.php
@ -85,7 +90,7 @@ Question :: display_type_menu ();
<td width="15%" align="center"><b><?php echo get_lang('Modify'); ?></b></td>
</tr>
<?php
<?php
if($nbrQuestions)
{
$questionList=$objExercise->selectQuestionList();
@ -97,12 +102,12 @@ if($nbrQuestions)
$objQuestionTmp = Question :: read($id);
//showQuestion($id);
?>
?>
<tr>
<td><?php echo "$i. ".$objQuestionTmp->selectTitle(); ?></td> <td><?php eval('echo get_lang('.get_class($objQuestionTmp).'::$explanationLangVar);'); ?></td>
<td> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?myid=1&editQuestion=<?php echo $id; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" alt="<?php echo get_lang('Modify'); ?>" /></a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?deleteQuestion=<?php echo $id; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" alt="<?php echo get_lang('Delete'); ?>" /></a>
<?php
if($i != 1)
{
@ -133,11 +138,11 @@ if($nbrQuestions)
</tr>
<?php }
}
?>
?>
</table>
<table border="0" align="center" cellpadding="2" cellspacing="2" width="100%">
<?php
<?php
if(!$i)
{
?>

@ -1,54 +1,48 @@
<?php // $Id: question_pool.php 10774 2007-01-17 21:24:24Z pcool $
<?php
/*
==============================================================================
Dokeos - elearning and course management software
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 documentation/credits.html
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 "documentation/licence.html" more details.
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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* QUESTION POOL
*
* This script allows administrators to manage questions and add them
* into their exercises.
*
* One question can be in several exercises.
*
* @author Olivier Brouckaert
* Question Pool
* This script allows administrators to manage questions and add them into their exercises.
* One question can be in several exercises
* @package dokeos.exercise
==============================================================================
* @author Olivier Brouckaert
* @version $Id: question_pool.php 10789 2007-01-18 19:18:27Z pcool $
*/
// name of the language file that needs to be included
$language_file='exercice';
include('../inc/global.inc.php');
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');
$this_section=SECTION_COURSES;
$is_allowedToEdit=$is_courseAdmin;
$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
$TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
$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);
$TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);

@ -1,35 +1,31 @@
<?php
/*
==============================================================================
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) Istvan Mandak
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* Code library for HotPotatoes integration.
*
* @author Istvan Mandak
* Saving the scores.
* @package dokeos.exercise
==============================================================================
* @author
* @version $Id: savescores.php 10789 2007-01-18 19:18:27Z pcool $
*/
// name of the language file that needs to be included
// name of the language file that needs to be included
$language_file = 'learnpath';
include ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
@ -43,7 +39,6 @@ my_delete($full_file_path.$_user['user_id'].".t.html");
$TABLETRACK_HOTPOTATOES = $_configuration['statistics_database']."`.`track_e_hotpotatoes";
$tbl_learnpath_user = Database::get_course_table(TABLE_LEARNPATH_USER);
//$_course['dbNameGlu']."learnpath_user";
$_cid = $cid;
$test = mysql_real_escape_string($_REQUEST['test']);
$score = mysql_real_escape_string($_REQUEST['score']);
@ -51,8 +46,8 @@ $origin = $_REQUEST['origin'];
function save_scores($file, $score)
{
global $_configuration, $origin, $tbl_learnpath_user,
$learnpath_id, $learnpath_item_id, $_user, $_cid,
global $_configuration, $origin, $tbl_learnpath_user,
$learnpath_id, $learnpath_item_id, $_user, $_cid,
$TABLETRACK_HOTPOTATOES;
// if tracking is disabled record nothing
$weighting = 100; // 100%
@ -75,17 +70,17 @@ function save_scores($file, $score)
$sql = "INSERT INTO `".$TABLETRACK_HOTPOTATOES."`
(`exe_name`,
`exe_user_id`,
`exe_date`,
`exe_date`,
`exe_cours_id`,
`exe_result`,
`exe_weighting`
`exe_weighting`
)
VALUES
(
'".$file."',
".$user_id.",
'".$date."',
".$user_id.",
'".$date."',
'".$_cid."',
'".$score."',
'".$weighting."'
@ -97,8 +92,8 @@ function save_scores($file, $score)
{
$user_id = '0';
}
$sql2 = "update $tbl_learnpath_user
set score='$score'
$sql2 = "update $tbl_learnpath_user
set score='$score'
where (user_id=$user_id and learnpath_id='$learnpath_id' and learnpath_item_id='$learnpath_item_id')";
error_log($sql,0);
$res2 = api_sql_query($sql2,__FILE__,__LINE__);

@ -1,48 +1,43 @@
<?php
/*
==============================================================================
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) Istvan Mandak
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* Code library for HotPotatoes integration.
*
* @author Istvan Mandak
* @package dokeos.exercise
==============================================================================
* @author Istvan Mandak
* @version $Id: showinframes.php 10789 2007-01-18 19:18:27Z pcool $
*/
/*
-----------------------------------------------------------
Included libraries
-----------------------------------------------------------
*/
*/
include('../inc/global.inc.php');
include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
$time=time();
require_once(api_get_path(SYS_PATH).'main/exercice/hotpotatoes.lib.php');
// init
$doc_url=urldecode($_GET['file']);
$cid = $_course['official_code'];
// init
$doc_url=urldecode($_GET['file']);
$cid = $_course['official_code'];
$documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$documentWebPath= api_get_path(WEB_COURSE_PATH).$_course['path']."/document";
$origin = $_REQUEST['origin'];
@ -51,8 +46,8 @@ $learnpath_item_id = $_REQUEST['learnpath_item_id'];
$time = $_REQUEST['time'];
// read content
$full_file_path = $documentPath.$doc_url;
my_delete($full_file_path.$_user['user_id'].".t.html");
$full_file_path = $documentPath.$doc_url;
my_delete($full_file_path.$_user['user_id'].".t.html");
$content = ReadFileCont($full_file_path.$_user['user_id'].".t.html");
if ($content=="")
@ -67,7 +62,7 @@ if ($content=="")
" {\n".
" SaveScoreVariable = 1;\n".
" if (C.ie)\n".
" {\n".
" {\n".
" document.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=$time&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n".
" //window.alert(Score);\n".
" }\n".
@ -80,20 +75,20 @@ if ($content=="")
"// Must be included \n".
"function Finish(){\n".
" mySaveScore();";
$newcontent = str_replace($mit,$js_content,$content);
$newcontent = str_replace($mit,$js_content,$content);
$prehref="<!-- BeginTopNavButtons -->";
$posthref="<!-- BeginTopNavButtons --><!-- edited by Dokeos -->";
$newcontent = str_replace($prehref,$posthref,$newcontent);
if (CheckSubFolder($full_file_path.$_user['user_id'].".t.html")==0)
{ $newcontent = ReplaceImgTag($newcontent); }
$newcontent = str_replace($prehref,$posthref,$newcontent);
if (CheckSubFolder($full_file_path.$_user['user_id'].".t.html")==0)
{ $newcontent = ReplaceImgTag($newcontent); }
}
else
{
//my_delete($full_file_path.$_user['user_id'].".t.html");
//my_delete($full_file_path.$_user['user_id'].".t.html");
$newcontent = $content;
}
@ -101,22 +96,22 @@ WriteFileCont($full_file_path.$_user['user_id'].".t.html",$newcontent);
/* $prehref="javascript:void(0);";
$posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
$newcontent = str_replace($prehref,$posthref,$newcontent);
$newcontent = str_replace($prehref,$posthref,$newcontent);
$prehref="class=\"GridNum\" onclick=";
$posthref="class=\"GridNum\" onMouseover=";
$newcontent = str_replace($prehref,$posthref,$newcontent);
*/
$newcontent = str_replace($prehref,$posthref,$newcontent);
*/
$doc_url = GetFolderPath($doc_url).urlencode(GetFileName($doc_url));
// echo $documentWebPath.$doc_url.$_user['user_id'].".t.html";
// exit;
?>
?>
<html>
<head>
<title>Tests - Dokeos</title>
</head>
<?php
<?php
if ($origin!='learnpath') {
?>
@ -131,16 +126,16 @@ if ($origin!='learnpath') {
</body>
</noframes>
</frameset>
<?php
} else {
<?php
} else {
?>
<script language='Javascript' type='text/javascript'>
s='<?php echo $documentWebPath.$doc_url.$_user['user_id']; ?>.t.html?time=<?php echo $time; ?>';
//document.write(s);
window.location=s;
</script>
<?php
}
<?php
}
?>
</html>

@ -1,50 +1,46 @@
<?php
/*
==============================================================================
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) Istvan Mandak
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* Code library for HotPotatoes integration.
*
* @author Istvan Mandak
* @package dokeos.exercise
==============================================================================
* @author Istvan Mandak
* @version $Id: testheaderpage.php 10789 2007-01-18 19:18:27Z pcool $
*/
// name of the language file that needs to be included
// name of the language file that needs to be included
$language_file='exercice';
include('../inc/global.inc.php');
require_once($_configuration['root_sys'].'main/exercice/hotpotatoes.lib.php');
include('../inc/global.inc.php');
require_once($_configuration['root_sys'].'main/exercice/hotpotatoes.lib.php');
$documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$title = GetQuizName($_GET['file'],$documentPath);
$title = GetQuizName($_GET['file'],$documentPath);
if ($title =='')
{
$title = GetFileName($_GET['file']);
}
{
$title = GetFileName($_GET['file']);
}
$nameTools = $title;
$noPHP_SELF=true;
$interbreadcrumb[]= array ("url"=>"./exercice.php", "name"=> get_lang('Exercices'));
Display::display_header($nameTools,"Exercise");
echo "<a name='TOP'></a>";
?>

@ -1,78 +1,74 @@
<?php // $Id: uniquer_answer.class.php 10234 2006-12-26
<?php
/*
==============================================================================
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
==============================================================================
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
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 "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
==============================================================================
* File containing the UNIQUE_ANSWER class.
*
* @author Eric Marguin
* @package dokeos.exercise
==============================================================================
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('UniqueAnswer')):
/**
CLASS UNIQUE_ANSWER
*
* This class allows to instantiate an object of type UNIQUE_ANSWER (MULTIPLE CHOICE, UNIQUE ANSWER),
*
* This class allows to instantiate an object of type UNIQUE_ANSWER (MULTIPLE CHOICE, UNIQUE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package dokeos.exercise
**/
class UniqueAnswer extends Question {
static $typePicture = 'mcua.png';
static $explanationLangVar = 'UniqueSelect';
/**
* Constructor
*/
function UniqueAnswer(){
$this -> type = UNIQUE_ANSWER;
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
* @param the answers number to display
*/
function createAnswersForm ($form) {
global $fck_attribute;
$fck_attribute = array();
$fck_attribute['Width'] = '300px';
$fck_attribute['Height'] = '100px';
$fck_attribute['ToolbarSet'] = 'Small';
$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$html='
<div class="row">
<div class="label">
@ -99,27 +95,27 @@ class UniqueAnswer extends Question {
<td width="0"></td>
</tr>';
$form -> addElement ('html', $html);
$defaults = array();
$correct = 0;
if(!empty($this -> id))
if(!empty($this -> id))
{
$answer = new Answer($this -> id);
$answer -> read();
$answer -> read();
if(count($answer->nbrAnswers)>0 && !$form->isSubmitted())
{
$nb_answers = $answer->nbrAnswers;
}
}
$form -> addElement('hidden', 'nb_answers');
for($i = 1 ; $i <= $nb_answers ; ++$i)
{
if(is_object($answer))
{
if($answer -> correct[$i])
if($answer -> correct[$i])
{
$correct = $i;
}
@ -127,60 +123,60 @@ class UniqueAnswer extends Question {
$defaults['comment['.$i.']'] = $answer -> comment[$i];
$defaults['weighting['.$i.']'] = $answer -> weighting[$i];
}
$form -> addElement ('html', '<tr><td>');
$group = array();
$puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"');
$puce->freeze();
$puce->freeze();
$group[] = $puce;
$group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i);
$group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i);
$group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"');
$group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"');
$group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"');
$form -> addGroup($group, null, null, '</td><td width="0">');
$form -> addElement ('html', '</td></tr>');
}
$form -> addElement ('html', '</table></div></div>');
$form -> addElement ('html', '</table></div></div>');
$group = array();
$group[] = FormValidator :: createElement ('submit', 'lessAnswers', '-answ');
$group[] = FormValidator :: createElement ('submit', 'moreAnswers', '+answ');
$form -> addGroup($group);
$defaults['correct'] = $correct;
$form -> setDefaults($defaults);
$form->setConstants(array('nb_answers' => $nb_answers));
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
* @param the answers number to display
*/
function processAnswersCreation($form) {
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form -> getSubmitValue('correct');
$objAnswer = new Answer($this->id);
$nb_answers = $form -> getSubmitValue('nb_answers');
for($i=1 ; $i <= $nb_answers ; $i++)
{
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
$goodAnswer= ($correct == $i) ? true : false;
if($goodAnswer)
if($goodAnswer)
{
$nbrGoodAnswers++;
$weighting = abs($weighting);
@ -189,21 +185,18 @@ class UniqueAnswer extends Question {
$questionWeighting += $weighting;
}
}
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i);
}
// saves the answers into the data base
$objAnswer -> save();
// sets the total weighting of the question
$this -> updateWeighting($questionWeighting);
$this -> save();
}
}
endif;
?>
Loading…
Cancel
Save