diff --git a/.htaccess b/.htaccess
index b488d37009..372ab4fee2 100644
--- a/.htaccess
+++ b/.htaccess
@@ -45,3 +45,6 @@ RewriteRule ^badge/(\d{1,}) main/badge/issued.php?issue=$1 [L]
RewriteRule ^skill/(\d{1,})/user/(\d{1,}) main/badge/issued_all.php?skill=$1&user=$2 [L]
# Support deprecated URL (avoid 404)
RewriteRule ^badge/(\d{1,})/user/(\d{1,}) main/badge/issued_all.php?skill=$1&user=$2 [L]
+
+# Support old URLs using the exercice (with a c) folder rather than exercise
+RewriteRule ^main/exercice/(.*)$ main/exercise/$1 [QSA,L]
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 8cf644dfc9..e9d2cf1a98 100755
--- a/composer.json
+++ b/composer.json
@@ -22,7 +22,7 @@
"main/cron/lang",
"main/course_description",
"main/dropbox",
- "main/exercice",
+ "main/exercise",
"main/gradebook/lib",
"main/newscorm",
"main/inc/lib",
diff --git a/documentation/installation_guide.html b/documentation/installation_guide.html
index 50e5b106cb..320bd3e557 100755
--- a/documentation/installation_guide.html
+++ b/documentation/installation_guide.html
@@ -680,6 +680,7 @@ If you have issues with files taking a long time to download, make sure you reco
RewriteRule ^courses/([^/]+)/course-pic.png$ app/courses/$1/course-pic.png [QSA,L]
RewriteRule ^session/(\d{1,})/about/?$ main/session/about.php?session_id=$1 [L]
RewriteRule ^badge/(\d{1,})/user/(\d{1,}) main/badge/issued.php?skill=$1&user=$2 [L]
+ RewriteRule ^main/exercice/(.+)$ main/exercise/$1 [QSA,L]
</Directory>
';
if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
- echo '
'.
+ echo ''.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'';
if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
- echo '
'.
+ echo ''.
Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'';
}
- echo '
'.
+ echo ''.
Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'';
echo Display::url(
Display::return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_MEDIUM),
- api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id
+ api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id
);
- echo '
'.
+ echo ''.
Display::return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'';
$maxScoreAllQuestions = 0;
@@ -396,13 +396,13 @@ if ($inATest) {
} else if (isset($_GET['newQuestion'])) {
// we are in create a new question from question pool not in a test
echo '
';
} else {
// If we are in question_pool but not in an test, go back to question create in pool
echo '
';
diff --git a/main/exercice/adminhp.php b/main/exercise/adminhp.php
similarity index 97%
rename from main/exercice/adminhp.php
rename to main/exercise/adminhp.php
index 49932f6c62..c3768b2abc 100755
--- a/main/exercice/adminhp.php
+++ b/main/exercise/adminhp.php
@@ -54,7 +54,7 @@ $nameTools = get_lang('adminHP');
Display::display_header($nameTools,"Exercise");
/** @todo probably wrong !!!! */
-require_once(api_get_path(SYS_CODE_PATH).'/exercice/hotpotatoes.lib.php');
+require_once(api_get_path(SYS_CODE_PATH).'/exercise/hotpotatoes.lib.php');
?>
diff --git a/main/exercice/aiken.php b/main/exercise/aiken.php
similarity index 91%
rename from main/exercice/aiken.php
rename to main/exercise/aiken.php
index 052821cf0f..a75755276f 100755
--- a/main/exercice/aiken.php
+++ b/main/exercise/aiken.php
@@ -15,8 +15,8 @@ $lib_path = api_get_path(LIBRARY_PATH);
$main_path = api_get_path(SYS_CODE_PATH);
// including additional libraries
-require_once $main_path.'exercice/export/aiken/aiken_import.inc.php';
-require_once $main_path.'exercice/export/aiken/aiken_classes.php';
+require_once $main_path.'exercise/export/aiken/aiken_import.inc.php';
+require_once $main_path.'exercise/export/aiken/aiken_classes.php';
// section (for the tabs)
$this_section = SECTION_COURSES;
diff --git a/main/exercice/answer.class.php b/main/exercise/answer.class.php
similarity index 100%
rename from main/exercice/answer.class.php
rename to main/exercise/answer.class.php
diff --git a/main/exercice/calculated_answer.class.php b/main/exercise/calculated_answer.class.php
similarity index 99%
rename from main/exercice/calculated_answer.class.php
rename to main/exercise/calculated_answer.class.php
index fc92aaad36..88ab4b21c4 100644
--- a/main/exercice/calculated_answer.class.php
+++ b/main/exercise/calculated_answer.class.php
@@ -138,7 +138,7 @@ class CalculatedAnswer extends Question
$notationListButton = Display::url(
get_lang('NotationList'),
- api_get_path(WEB_PATH).'main/exercice/evalmathnotation.php',
+ api_get_path(WEB_CODE_PATH).'exercise/evalmathnotation.php',
array(
'class' => 'btn btn-info ajax',
'data-title' => get_lang('NotationList'),
diff --git a/main/exercice/evalmathnotation.php b/main/exercise/evalmathnotation.php
similarity index 100%
rename from main/exercice/evalmathnotation.php
rename to main/exercise/evalmathnotation.php
diff --git a/main/exercice/exercice.php b/main/exercise/exercice.php
similarity index 100%
rename from main/exercice/exercice.php
rename to main/exercise/exercice.php
diff --git a/main/exercice/exercise.class.php b/main/exercise/exercise.class.php
similarity index 99%
rename from main/exercice/exercise.class.php
rename to main/exercise/exercise.class.php
index 8aa5681209..15548e98ba 100755
--- a/main/exercice/exercise.class.php
+++ b/main/exercise/exercise.class.php
@@ -5165,7 +5165,7 @@ class Exercise
}
$url_email = api_get_path(WEB_CODE_PATH)
- . 'exercice/exercise_show.php?'
+ . 'exercise/exercise_show.php?'
. api_get_cidreq()
. '&id_session='
. $sessionId
@@ -5241,7 +5241,7 @@ class Exercise
$course_info = api_get_course_info($courseCode);
$url_email = api_get_path(WEB_CODE_PATH)
- . 'exercice/exercise_show.php?'
+ . 'exercise/exercise_show.php?'
. api_get_cidreq()
. '&id_session='
. api_get_session_id()
@@ -5337,7 +5337,7 @@ class Exercise
$course_info = api_get_course_info($courseCode);
$url_email = api_get_path(WEB_CODE_PATH)
- . 'exercice/exercise_show.php?'
+ . 'exercise/exercise_show.php?'
. api_get_cidreq()
. '&id_session='
. api_get_session_id()
diff --git a/main/exercice/exercise.php b/main/exercise/exercise.php
similarity index 98%
rename from main/exercice/exercise.php
rename to main/exercise/exercise.php
index e3d8f221bc..7c76278dd5 100644
--- a/main/exercice/exercise.php
+++ b/main/exercise/exercise.php
@@ -116,7 +116,7 @@ if (!empty($gradebook) && $gradebook == 'view') {
$nameTools = get_lang('Exercises');
$errorXmlExport = null;
if ($is_allowedToEdit && !empty($choice) && $choice == 'exportqti2') {
- require_once api_get_path(SYS_CODE_PATH).'exercice/export/qti2/qti2_export.php';
+ require_once api_get_path(SYS_CODE_PATH).'exercise/export/qti2/qti2_export.php';
$export = export_exercise_to_qti($exerciseId, true);
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
@@ -443,25 +443,25 @@ $total = $total_exercises + $hp_count;
$token = Security::get_token();
if ($is_allowedToEdit && $origin != 'learnpath') {
- echo '
'.
+ echo ''.
Display :: return_icon('new_exercice.png', get_lang('NewEx'), '', ICON_SIZE_MEDIUM).'';
- echo '
'.
+ echo ''.
Display :: return_icon('new_question.png', get_lang('AddQ'), '', ICON_SIZE_MEDIUM).'';
// Question category
- echo '
';
+ echo '';
echo Display::return_icon('green_open.png', get_lang('QuestionCategory'), '', ICON_SIZE_MEDIUM);
echo '';
- echo '
';
+ echo '';
echo Display::return_icon('database.png', get_lang('QuestionPool'), '', ICON_SIZE_MEDIUM);
echo '';
//echo Display::url(Display::return_icon('looknfeel.png', get_lang('Media')), 'media.php?' . api_get_cidreq());
// end question category
- echo '
'.Display :: return_icon('import_hotpotatoes.png', get_lang('ImportHotPotatoesQuiz'), '', ICON_SIZE_MEDIUM).'';
+ echo '
'.Display :: return_icon('import_hotpotatoes.png', get_lang('ImportHotPotatoesQuiz'), '', ICON_SIZE_MEDIUM).'';
// link to import qti2 ...
- echo '
'.Display :: return_icon('import_qti2.png', get_lang('ImportQtiQuiz'), '', ICON_SIZE_MEDIUM).'';
- echo '
'.Display :: return_icon('import_aiken.png', get_lang('ImportAikenQuiz'), '', ICON_SIZE_MEDIUM).'';
- echo '
'.Display :: return_icon('import_excel.png', get_lang('ImportExcelQuiz'), '', ICON_SIZE_MEDIUM).'';
+ echo '
'.Display :: return_icon('import_qti2.png', get_lang('ImportQtiQuiz'), '', ICON_SIZE_MEDIUM).'';
+ echo '
'.Display :: return_icon('import_aiken.png', get_lang('ImportAikenQuiz'), '', ICON_SIZE_MEDIUM).'';
+ echo '
'.Display :: return_icon('import_excel.png', get_lang('ImportExcelQuiz'), '', ICON_SIZE_MEDIUM).'';
echo Display::url(
Display::return_icon(
'clean_all.png',
@@ -472,7 +472,7 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
'',
array(
'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToEmptyAllTestResults'), ENT_QUOTES, $charset))."')) return false;",
- 'href' => api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidreq().'&choice=clean_all_test&sec_token='.$token
+ 'href' => api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq().'&choice=clean_all_test&sec_token='.$token
)
);
}
diff --git a/main/exercice/exercise_admin.php b/main/exercise/exercise_admin.php
similarity index 100%
rename from main/exercice/exercise_admin.php
rename to main/exercise/exercise_admin.php
diff --git a/main/exercice/exercise_history.php b/main/exercise/exercise_history.php
similarity index 97%
rename from main/exercice/exercise_history.php
rename to main/exercise/exercise_history.php
index bdb5fde572..0d614251ab 100755
--- a/main/exercice/exercise_history.php
+++ b/main/exercise/exercise_history.php
@@ -22,7 +22,7 @@ $is_allowedToEdit = api_is_allowed_to_edit(null,true);
$is_tutor = api_is_allowed_to_edit(true);
if (!$is_allowedToEdit){
- header('Location: /main/exercice/exercise.php?'.api_get_cidreq());
+ header('Location: ' . api_get_path(WEB_CODE_PATH) . 'exercise/exercise.php?' . api_get_cidreq());
exit;
}
diff --git a/main/exercice/exercise_reminder.php b/main/exercise/exercise_reminder.php
similarity index 100%
rename from main/exercice/exercise_reminder.php
rename to main/exercise/exercise_reminder.php
diff --git a/main/exercice/exercise_report.php b/main/exercise/exercise_report.php
similarity index 99%
rename from main/exercice/exercise_report.php
rename to main/exercise/exercise_report.php
index 9ee7bb9596..46d3e338bb 100755
--- a/main/exercice/exercise_report.php
+++ b/main/exercise/exercise_report.php
@@ -151,7 +151,7 @@ if (isset($_REQUEST['comments']) &&
null,
PERSON_NAME_EMAIL_ADDRESS
);
- $url = api_get_path(WEB_CODE_PATH).'exercice/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq().'&show_headers=1&id_session='.$session_id;
+ $url = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq().'&show_headers=1&id_session='.$session_id;
$my_post_info = array();
$post_content_id = array();
@@ -261,7 +261,7 @@ if (isset($_REQUEST['comments']) &&
Database::query($sql);
if ($origin == 'tracking_course') {
//Redirect to the course detail in lp
- header('location: '.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?course='.Security :: remove_XSS($_GET['course']));
+ header('location: '.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?course='.Security :: remove_XSS($_GET['course']));
exit;
} else {
// Redirect to the reporting
diff --git a/main/exercice/exercise_result.class.php b/main/exercise/exercise_result.class.php
similarity index 100%
rename from main/exercice/exercise_result.class.php
rename to main/exercise/exercise_result.class.php
diff --git a/main/exercice/exercise_result.php b/main/exercise/exercise_result.php
similarity index 99%
rename from main/exercice/exercise_result.php
rename to main/exercise/exercise_result.php
index fa5dae3cb4..9a31671fc6 100755
--- a/main/exercice/exercise_result.php
+++ b/main/exercise/exercise_result.php
@@ -151,7 +151,7 @@ if ($objExercise->selectAttempts() > 0) {
if ($remainingAttempts) {
$attemptButton = Display::toolbarButton(
get_lang('AnotherAttempt'),
- api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?' . api_get_cidreq() . '&' . http_build_query([
+ api_get_path(WEB_CODE_PATH) . 'exercise/overview.php?' . api_get_cidreq() . '&' . http_build_query([
'exerciseId' => $objExercise->id
]),
'pencil-square-o',
diff --git a/main/exercice/exercise_show.php b/main/exercise/exercise_show.php
similarity index 99%
rename from main/exercice/exercise_show.php
rename to main/exercise/exercise_show.php
index 7e866929b7..6003d700f3 100755
--- a/main/exercice/exercise_show.php
+++ b/main/exercise/exercise_show.php
@@ -855,7 +855,7 @@ if ($isFeedbackAllowed) {
if ($isFeedbackAllowed) {
if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) {
- $formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
+ $formUrl = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_report.php?' . api_get_cidreq() . '&';
$formUrl .= http_build_query([
'exerciseId' => $exercise_id,
'filter' => 2,
@@ -874,7 +874,7 @@ if ($isFeedbackAllowed) {
echo '
';
echo '
';
} else {
- $formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
+ $formUrl = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_report.php?' . api_get_cidreq() . '&';
$formUrl .= http_build_query([
'exerciseId' => $exercise_id,
'filter' => 1,
diff --git a/main/exercice/exercise_submit.php b/main/exercise/exercise_submit.php
similarity index 100%
rename from main/exercice/exercise_submit.php
rename to main/exercise/exercise_submit.php
diff --git a/main/exercice/exercise_submit_modal.php b/main/exercise/exercise_submit_modal.php
similarity index 100%
rename from main/exercice/exercise_submit_modal.php
rename to main/exercise/exercise_submit_modal.php
diff --git a/main/exercice/export/aiken/aiken_classes.php b/main/exercise/export/aiken/aiken_classes.php
similarity index 100%
rename from main/exercice/export/aiken/aiken_classes.php
rename to main/exercise/export/aiken/aiken_classes.php
diff --git a/main/exercice/export/aiken/aiken_import.inc.php b/main/exercise/export/aiken/aiken_import.inc.php
similarity index 100%
rename from main/exercice/export/aiken/aiken_import.inc.php
rename to main/exercise/export/aiken/aiken_import.inc.php
diff --git a/main/exercice/export/exercise_import.inc.php b/main/exercise/export/exercise_import.inc.php
similarity index 100%
rename from main/exercice/export/exercise_import.inc.php
rename to main/exercise/export/exercise_import.inc.php
diff --git a/main/exercice/export/exercise_import.php b/main/exercise/export/exercise_import.php
similarity index 100%
rename from main/exercice/export/exercise_import.php
rename to main/exercise/export/exercise_import.php
diff --git a/main/exercice/export/index.php b/main/exercise/export/index.php
similarity index 100%
rename from main/exercice/export/index.php
rename to main/exercise/export/index.php
diff --git a/main/exercice/export/qti2/qti2_classes.php b/main/exercise/export/qti2/qti2_classes.php
similarity index 100%
rename from main/exercice/export/qti2/qti2_classes.php
rename to main/exercise/export/qti2/qti2_classes.php
diff --git a/main/exercice/export/qti2/qti2_export.php b/main/exercise/export/qti2/qti2_export.php
similarity index 100%
rename from main/exercice/export/qti2/qti2_export.php
rename to main/exercise/export/qti2/qti2_export.php
diff --git a/main/exercice/export/scorm/scorm_classes.php b/main/exercise/export/scorm/scorm_classes.php
similarity index 100%
rename from main/exercice/export/scorm/scorm_classes.php
rename to main/exercise/export/scorm/scorm_classes.php
diff --git a/main/exercice/feedback.php b/main/exercise/feedback.php
similarity index 100%
rename from main/exercice/feedback.php
rename to main/exercise/feedback.php
diff --git a/main/exercice/fill_blanks.class.php b/main/exercise/fill_blanks.class.php
similarity index 99%
rename from main/exercice/fill_blanks.class.php
rename to main/exercise/fill_blanks.class.php
index 45a290f4c1..16e6d3e734 100755
--- a/main/exercice/fill_blanks.class.php
+++ b/main/exercise/fill_blanks.class.php
@@ -757,7 +757,7 @@ class FillBlanks extends Question
$tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$courseId = api_get_course_int_id();
- require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';
+ require_once api_get_path(SYS_PATH).'main/exercise/fill_blanks.class.php';
// request to have all the answers of student for this question
// student may have doing it several time
diff --git a/main/exercice/freeanswer.class.php b/main/exercise/freeanswer.class.php
similarity index 100%
rename from main/exercice/freeanswer.class.php
rename to main/exercise/freeanswer.class.php
diff --git a/main/exercice/global_multiple_answer.class.php b/main/exercise/global_multiple_answer.class.php
similarity index 97%
rename from main/exercice/global_multiple_answer.class.php
rename to main/exercise/global_multiple_answer.class.php
index f98ecbff0a..dbcc71a8a4 100755
--- a/main/exercice/global_multiple_answer.class.php
+++ b/main/exercise/global_multiple_answer.class.php
@@ -1,243 +1,243 @@
-type = GLOBAL_MULTIPLE_ANSWER;
- $this->isContent = $this->getIsContent();
- }
-
- /**
- * function which redefines Question::createAnswersForm
- * @param FormValidator $form
- */
- public function createAnswersForm($form)
- {
- $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
- $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
-
- $obj_ex = $_SESSION['objExercise'];
-
- /* Mise en variable de Affichage "Reponses" et son icone, "N�", "Vrai", "Reponse" */
- $html = '
-
- |
- ' . get_lang('Number') . '
- |
-
- ' . get_lang('True') . '
- |
-
- ' . get_lang('Answer') . '
- | ';
-
- $html .='' . get_lang('Comment') . ' | ';
- $html .='
';
- $form->addElement(
- 'label',
- get_lang('Answers') .
- '
'.Display::return_icon('fill_field.png'),
- $html
- );
- $defaults = array();
- $correct = 0;
- $answer = false;
- if (!empty($this->id)) {
- $answer = new Answer($this->id);
- $answer->read();
- if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
- $nb_answers = $answer->nbrAnswers;
- }
- }
-
- #le nombre de r�ponses est bien enregistr� sous la forme int(nb)
-
- /* Ajout mise en forme nb reponse */
- $form->addElement('hidden', 'nb_answers');
- $boxes_names = array();
-
- /* V�rification : Cr�action d'au moins une r�ponse */
- if ($nb_answers < 1) {
- $nb_answers = 1;
- Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
- }
-
- //D�but affichage score global dans la modification d'une question
- $scoreA = "0"; //par reponse
- $scoreG = "0"; //Global
-
- /* boucle pour sauvegarder les donn�es dans le tableau defaults */
- for ($i = 1; $i <= $nb_answers; ++$i) {
- /* si la reponse est de type objet */
- if (is_object($answer)) {
- $defaults['answer[' . $i . ']'] = $answer->answer[$i];
- $defaults['comment[' . $i . ']'] = $answer->comment[$i];
- $defaults['correct[' . $i . ']'] = $answer->correct[$i];
-
- // start
- $scoreA = $answer->weighting[$i];
- }
- if ($scoreA > 0) {
- $scoreG = $scoreG + $scoreA;
- }
- //------------- Fin
- //------------- Debut si un des scores par reponse est egal � 0 : la coche vaut 1 (coch�)
- if ($scoreA == 0) {
- $defaults['pts'] = 1;
- }
-
- $renderer = & $form->defaultRenderer();
-
- $renderer->setElementTemplate('{error} {element} | ', 'correct['.$i.']');
- $renderer->setElementTemplate('{error} {element} | ', 'counter['.$i.']');
- $renderer->setElementTemplate('{error} {element} | ', 'answer['.$i.']');
- $renderer->setElementTemplate('{error} {element} | ', 'comment['.$i.']');
- //$renderer->setElementTemplate('{error} {element} | ', 'weighting['.$i.']');
-
- $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
- $answer_number->freeze();
-
- $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"');
- $boxes_names[] = 'correct[' . $i . ']';
-
- $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
- $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
-
- $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
-
- $form->addElement('html', '');
- }
- //--------- Mise en variable du score global lors d'une modification de la question/r�ponse
- $defaults['weighting[1]'] = (round($scoreG));
-
- $form->addElement('html', '
');
-
- //$form -> addElement ('html', '
');
- $form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
-
- //only 1 answer the all deal ...
- $form->addElement('text', 'weighting[1]', get_lang('Score'));
-
- global $pts;
- //--------- Creation coche pour ne pas prendre en compte les n�gatifs
- $form->addElement('checkbox', 'pts', '', get_lang('NoNegativeScore'));
- $form->addElement('html', '
');
-
- // Affiche un message si le score n'est pas renseign�
- $form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
-
- global $text, $class;
-
- if ($obj_ex->edit_exercise_in_lp == true) {
- $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers');
- $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers');
- $form->addButtonSave($text, 'submitQuestion');
- // setting the save button here and not in the question class.php
- }
-
- $renderer->setElementTemplate('{element} ', 'lessAnswers');
- $renderer->setElementTemplate('{element} ', 'submitQuestion');
- $renderer->setElementTemplate('{element}', 'moreAnswers');
-
- $form->addElement('html', '
');
-
- $defaults['correct'] = $correct;
-
- if (!empty($this->id)) {
- $form->setDefaults($defaults);
- } else {
- if ($this->isContent == 1) {
- $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 FormValidator $form
- */
- function processAnswersCreation($form)
- {
- $questionWeighting = $nbrGoodAnswers = 0;
- $objAnswer = new Answer($this->id);
- $nb_answers = $form->getSubmitValue('nb_answers');
-
- // Score total
- $answer_score = trim($form->getSubmitValue('weighting[1]'));
-
- // Reponses correctes
- $nbr_corrects = 0;
- for ($i = 1; $i <= $nb_answers; $i++) {
- $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
- if ($goodAnswer) {
- $nbr_corrects++;
- }
- }
- // Set question weighting (score total)
- $questionWeighting = $answer_score;
-
- // Set score per answer
- $nbr_corrects = $nbr_corrects == 0 ? 1 : $nbr_corrects;
- $answer_score = $nbr_corrects == 0 ? 0 : $answer_score;
-
- $answer_score = ($answer_score / $nbr_corrects);
-
- //$answer_score �quivaut � la valeur d'une bonne r�ponse
- // cr�ation variable pour r�cuperer la valeur de la coche pour la prise en compte des n�gatifs
- $test = $form->getSubmitValue('pts');
-
- for ($i = 1; $i <= $nb_answers; $i++) {
- $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
- $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
- $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
-
- if ($goodAnswer) {
- $weighting = abs($answer_score);
- } else {
- if ($test == 1) {
- $weighting = 0;
- } else {
- $weighting = -abs($answer_score);
- }
- }
-
- $objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i);
- }
- // saves the answers into the data base
- $objAnswer->save();
-
- // sets the total weighting of the question --> sert � donner le score total pendant l'examen
- $this->updateWeighting($questionWeighting);
- $this->save();
- }
-
- public function return_header(
- $feedback_type = null,
- $counter = null,
- $score = null
- ) {
- $header = parent::return_header($feedback_type, $counter, $score);
- $header .= '