Updating from 1.10

skala
Julio Montoya 13 years ago
parent fc03b79453
commit 1126d33787
  1. 10
      main/exercice/draggable.class.php
  2. 15
      main/exercice/exercise.class.php
  3. 3
      main/exercice/exercise_admin.php
  4. 10
      main/exercice/exercise_show.php
  5. 35
      main/exercice/exercise_submit.php
  6. 7
      main/exercice/fill_blanks.class.php
  7. 7
      main/exercice/freeanswer.class.php
  8. 7
      main/exercice/global_multiple_answer.class.php
  9. 10
      main/exercice/matching.class.php
  10. 10
      main/exercice/multiple_answer.class.php
  11. 7
      main/exercice/multiple_answer_combination.class.php
  12. 7
      main/exercice/multiple_answer_true_false.class.php
  13. 13
      main/exercice/oral_expression.class.php
  14. 19
      main/exercice/question.class.php
  15. 8
      main/exercice/testcategory.class.php
  16. 7
      main/exercice/unique_answer.class.php
  17. 10
      main/exercice/unique_answer_image.class.php
  18. 8
      main/exercice/unique_answer_no_option.class.php

@ -194,15 +194,11 @@ class Draggable extends Matching
}
/**
* @param null $feedback_type
* @param null $counter
* @param null $score
* @param bool $show_media
* @return string
* {@inheritdoc}
*/
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">';
$header .= '<tr>
<th>'.get_lang('ElementList').'</th>

@ -4,7 +4,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya Cleaning exercises
* @author Julio Montoya Cleaning exercises, adding multiple categories, media questions, commitee
* Modified by Hubert Borderiou #294
*/
/**
@ -730,7 +730,10 @@ class Exercise
if (isset($questions_by_category[$category_id])) {
// How many question will be picked from this category.
$count = $category_info['count_questions'];
if ($count != -1) {
// -1 means all questions
if ($count == -1) {
$categoryCountArray[$category_id] = 999;
} else {
$categoryCountArray[$category_id] = $count;
}
}
@ -4617,8 +4620,8 @@ class Exercise
return false;
}
if (0) {
//if (!empty($this->emailNotificationTemplate)) {
//if (0) {
if (!empty($this->emailNotificationTemplate)) {
$twig = new \Twig_Environment(new \Twig_Loader_String());
$twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
$template = $this->emailNotificationTemplate;
@ -6430,8 +6433,8 @@ class Exercise
$tempParentId = $objQuestionTmp->parent_id;
}
//Shows question title an description
$question_content .= $objQuestionTmp->return_header(null, $counterToShow, $score, $show_media);
// Shows question title an description.
$question_content .= $objQuestionTmp->return_header(null, $counterToShow, $score, $show_media, $this->getHideQuestionTitle());
// display question category, if any
$question_content .= Testcategory::getCategoryNamesForQuestion($questionId);

@ -287,8 +287,9 @@ if ($form->validate()) {
}
echo '</div>';
if ($objExercise->feedback_type==1)
if ($objExercise->feedback_type == 1) {
Display::display_normal_message(get_lang('DirectFeedbackCantModifyTypeQuestion'));
}
if (api_get_setting('search_enabled')=='true' && !extension_loaded('xapian')) {
Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));

@ -285,6 +285,7 @@ foreach ($questionList as $questionId) {
$choice = $exerciseResult[$questionId];
// creates a temporary Question object
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($questionId);
$questionWeighting = $objQuestionTmp->selectWeighting();
@ -579,12 +580,6 @@ foreach ($questionList as $questionId) {
$category_was_added_for_this_test = false;
// We use now category_list instead of a unique category
/*if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) {
$category_list[$objQuestionTmp->category]['score'] += $my_total_score;
$category_list[$objQuestionTmp->category]['total'] += $my_total_weight;
$category_was_added_for_this_test = true;
}*/
if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) {
foreach ($objQuestionTmp->category_list as $category_id) {
@ -654,8 +649,9 @@ foreach ($questionList as $questionId) {
if ($show_results) {
//Shows question title an description
//$question_content .= $objQuestionTmp->return_header(null, $counterToShow, $score, $show_media, $mediaCounter, );
$question_content .= $objQuestionTmp->return_header(null, $counterToShow, $score, $show_media, $mediaCounter);
$question_content .= $objQuestionTmp->return_header(null, $counterToShow, $score, $show_media, $objExercise->getHideQuestionTitle());
// display question category, if any
$question_content .= Testcategory::getCategoryNamesForQuestion($questionId);

@ -339,6 +339,7 @@ we delete the objExercise from the session in order to get the latest changes in
if (api_is_allowed_to_edit(null,true) && isset($_GET['preview']) && $_GET['preview'] == 1) {
Session::erase('objExercise');
}
/** @var \Exercise $exerciseInSession */
$exerciseInSession = Session::read('objExercise');
// 1. Loading the $objExercise variable
@ -371,7 +372,9 @@ if (!isset($exerciseInSession) || isset($exerciseInSession) && ($exerciseInSessi
//2. Checking if $objExercise is set
if (!isset($objExercise) && isset($exerciseInSession)) {
if ($debug) { error_log('2. Loading $objExercise from session'); };
if ($debug) {
error_log('2. Loading $objExercise from session');
}
$objExercise = $exerciseInSession;
}
@ -401,7 +404,7 @@ if ($objExercise->expired_time != 0) {
$time_control = true;
}
//Generating the time control key for the user
// Generating the time control key for the user.
$current_expired_time_key = ExerciseLib::get_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
if ($debug) {
error_log("4. current_expired_time_key: $current_expired_time_key ");
@ -540,18 +543,20 @@ if (empty($exercise_stat_info)) {
if ($time_control) {
$expected_time = $current_timestamp + $total_seconds;
if ($debug) error_log('5.1. $current_timestamp '.$current_timestamp);
if ($debug) error_log('5.2. $expected_time '.$expected_time);
$clock_expired_time = api_get_utc_datetime($expected_time);
if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
//Sessions that contain the expired time
$expiredTime = array(
$current_expired_time_key => $clock_expired_time
);
Session::write('expired_time', $expiredTime);
if ($debug) { error_log('5.4. Setting the $expiredTime: '.$expiredTime[$current_expired_time_key] ); };
if ($debug) {
error_log('5.1. $current_timestamp '.$current_timestamp);
error_log('5.2. $expected_time '.$expected_time);
error_log('5.3. $expected_time '.$clock_expired_time);
error_log('5.4. Setting the $expiredTime: '.$expiredTime[$current_expired_time_key]);
}
}
$exe_id = $objExercise->save_stat_track_exercise_info($clock_expired_time, $learnpath_id, $learnpath_item_id, $learnpath_item_view_id, $questionListUncompressed, $total_weight);
$exercise_stat_info = $objExercise->getStatTrackExerciseInfo($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
@ -564,7 +569,9 @@ if (empty($exercise_stat_info)) {
// Array to check in order to block the chat
ExerciseLib::create_chat_exercise_session($exe_id);
if ($debug) { error_log('6. $objExercise->getStatTrackExerciseInfo function called:: '.print_r($exercise_stat_info, 1)); };
if ($debug) {
error_log('6. $objExercise->getStatTrackExerciseInfo function called:: '.print_r($exercise_stat_info, 1));
}
if (!empty($exercise_stat_info['questions_to_check'])) {
$my_remind_list = $exercise_stat_info['questions_to_check'];
@ -589,8 +596,10 @@ if ($reminder == 2 && empty($my_remind_list)) {
if ($time_control) {
$expiredTimeInSession = Session::read('expired_time');
if ($debug) error_log('7.1. Time control is enabled.');
if ($debug) error_log('7.2. $current_expired_time_key:'.$current_expired_time_key);
if ($debug) {
error_log('7.1. Time control is enabled.');
error_log('7.2. $current_expired_time_key:'.$current_expired_time_key);
}
if (!isset($expiredTimeInSession[$current_expired_time_key])) {
if ($debug) error_log('7.3. $expiredTimeInSession[$current_expired_time_key] not set.');
//Timer - Get expired_time for a student
@ -711,8 +720,10 @@ if ($formSent && isset($_POST)) {
}
}
}
if ($debug) { error_log('9.3. $choice is an array - end'); }
if ($debug) { error_log('9.4. $exerciseResult '.print_r($exerciseResult,1)); }
if ($debug) {
error_log('9.3. $choice is an array - end');
error_log('9.4. $exerciseResult '.print_r($exerciseResult,1));
}
}
// the script "exercise_result.php" will take the variable $exerciseResult from the session
@ -944,7 +955,7 @@ if (isset($_custom['exercises_hidden_when_no_start_date']) && $_custom['exercise
}
}
//Timer control
// Timer control.
if ($time_control) {
echo $objExercise->returnTimeLeftDiv();
echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciceExpiredTimeMessage').'</div>';

@ -193,9 +193,12 @@ class FillBlanks extends Question
$objAnswer->save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
/**
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Answer").'</th>

@ -63,14 +63,17 @@ class FreeAnswer extends Question
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
/**
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
if (!empty($score['comments']) || $score['score'] > 0) {
$score['revised'] = true;
} else {
$score['revised'] = false;
}
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'" >
<tr>
<th>'.get_lang("Answer").'</th>

@ -269,9 +269,12 @@ class GlobalMultipleAnswer extends Question
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
/**
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -255,15 +255,11 @@ class Matching extends Question
}
/**
* @param null $feedback_type
* @param null $counter
* @param null $score
* @param bool $show_media
* @return string
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
if ($this->type == MATCHING) {
$header .= '<table class="'.$this->question_table_class.'">';
$header .= '<tr>

@ -255,15 +255,11 @@ class MultipleAnswer extends Question
}
/**
* @param int $feedback_type
* @param int $counter
* @param string $score
* @param bool $show_media
* @return string
* {@inheritdoc}
*/
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -250,9 +250,12 @@ class MultipleAnswerCombination extends Question
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
/**
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -343,9 +343,12 @@ class MultipleAnswerTrueFalse extends Question
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
/**
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -49,15 +49,20 @@ class OralExpression extends Question
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
* @param FormValidator instance
*/
function processAnswersCreation($form) {
function processAnswersCreation($form)
{
$this->weighting = $form -> getSubmitValue('weighting');
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
/**
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>&nbsp;</th>

@ -39,7 +39,8 @@ abstract class Question
public static $explanationLangVar = '';
public $question_table_class = 'table table-striped';
public $editionMode = 'normal';
public $exercise; // exercise obj
/** @var Exercise $exercise */
public $exercise;
public $setDefaultValues = false;
public $submitClass;
public $submitText;
@ -129,7 +130,7 @@ abstract class Question
}
/**
* Reads question informations from the data base
* Reads question information from the database
*
* @author Olivier Brouckaert
* @param int $id - question ID
@ -1774,14 +1775,15 @@ abstract class Question
*
* @param int $feedback_type
* @param int $counter
* @param type $score
* @param array $score
* @param bool $show_media
* @param int $hideTitle
*
* @return string
*/
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media)
public function return_header($feedbackType = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$counterLabel = '';
$counterLabel = null;
if (!empty($counter)) {
$counterLabel = $counter;
}
@ -1803,14 +1805,17 @@ abstract class Question
}
}
$question_title = $this->question;
$header = null;
// Display question category, if any
if ($show_media) {
$header .= $this->show_media_content();
}
$header .= Display::page_subheader2($counterLabel.". ".$question_title);
if ($hideTitle == 1) {
$header .= Display::page_subheader2($counterLabel);
} else {
$header .= Display::page_subheader2($counterLabel.". ".$this->question);
}
$header .= Display::div(
'<div class="rib rib-'.$class.'"><h3>'.$score_label.'</h3></div><h4>'.$score['result'].' </h4>',
array('class' => 'ribbon')

@ -1041,7 +1041,10 @@ class Testcategory
//$list = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($excludeCategoryWithNoQuestions) {
if ($row['count_questions'] == 0 || $row['count_questions'] == -1) {
//if ($row['count_questions'] == 0 || $row['count_questions'] == -1) {
/*0 means no questions selected this options is also filtered in the function:
Exercise::pickQuestionsPerCategory() */
if ($row['count_questions'] == 0) {
continue;
}
@ -1094,12 +1097,13 @@ class Testcategory
$return .= Display::div($category['parent_path']);
$return .= '</td>';
$return .= '<td>';
$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : 0;
$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
$return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
$return .= '</td>';
$return .= '</tr>';
}
$return .= '</table>';
$return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
return $return;
}
}

@ -414,9 +414,12 @@ class UniqueAnswer extends Question
$this->save();
}
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
/**
* {@inheritdoc}
*/
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>

@ -354,14 +354,10 @@ class UniqueAnswerImage extends UniqueAnswer
}
/**
* @param int $feedback_type
* @param int $counter
* @param int $score
* @param bool $show_media
* @return string
* {@inheritdoc}
*/
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false)
public function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
return parent::return_header($feedback_type, $counter, $score, $show_media);
return parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
}
}

@ -396,8 +396,12 @@ class UniqueAnswerNoOption extends Question
$this -> save();
}
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false) {
$header = parent::return_header($feedback_type, $counter, $score, $show_media);
/**
* {@inheritdoc}
*/
function return_header($feedback_type = null, $counter = null, $score = null, $show_media = false, $hideTitle = 0)
{
$header = parent::return_header($feedback_type, $counter, $score, $show_media, $hideTitle);
$header .= '<table class="'.$this->question_table_class .'">
<tr>
<th>'.get_lang("Choice").'</th>

Loading…
Cancel
Save