Adding setting "exercise_enable_category_order" see BT#10052

Db changes:

// CREATE TABLE c_quiz_rel_category (iid BIGINT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, category_id INT NOT NULL, exercise_id INT NOT NULL, count_questions INT NOT NULL, PRIMARY KEY(iid));
// ALTER TABLE c_quiz ADD COLUMN question_selection_type INT;
1.10.x
jmontoyaa 9 years ago
parent 6b51fae1a3
commit 940fbdd51c
  1. 441
      main/exercice/TestCategory.php
  2. 4096
      main/exercice/exercise.class.php
  3. 35
      main/exercice/exercise_admin.php
  4. 84
      main/exercice/exercise_submit.php
  5. 1
      main/exercice/fill_blanks.class.php
  6. 3
      main/exercice/question.class.php
  7. 18
      main/exercice/question_list_admin.inc.php
  8. 2
      main/exercice/upload_exercise.php
  9. 18
      main/inc/lib/api.lib.php
  10. 6
      main/inc/lib/events.lib.php

@ -314,40 +314,99 @@ class TestCategory
* input : test_id
* return : array of category id (integer)
* hubert.borderiou 07-04-2011
* @param int $exerciseId
*/
public static function getListOfCategoriesIDForTest($in_testid)
public static function getListOfCategoriesIDForTest($exerciseId)
{
// parcourir les questions d'un test, recup les categories uniques dans un tableau
$result = array();
$quiz = new Exercise();
$quiz->read($in_testid);
$tabQuestionList = $quiz->selectQuestionList();
$exercise = new Exercise();
$exercise->read($exerciseId, false);
$categoriesInExercise = $exercise->getQuestionWithCategories();
// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
for ($i=1; $i <= count($tabQuestionList); $i++) {
if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) {
$result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]);
$categories = array();
if (!empty($categoriesInExercise)) {
foreach ($categoriesInExercise as $category) {
//$category['id'] = $category['iid'];
$categories[$category['id']] = $category;
}
}
return $result;
return $categories;
}
/**
* return the list of different categories NAME for a test
* input : test_id
* return : array of string
* hubert.borderiou 07-04-2011
* @param Exercise $exercise_obj
* @return array
*/
public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj)
{
// parcourir les questions d'un test, recup les categories uniques dans un tableau
$categories_in_exercise = array();
// $question_list = $exercise_obj->getQuestionList();
$question_list = $exercise_obj->getQuestionOrderedListByName();
// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
foreach ($question_list as $questionInfo) {
$question_id = $questionInfo['question_id'];
$category_list = self::getCategoryForQuestion($question_id);
if (is_numeric($category_list)) {
$category_list = array($category_list);
}
if (!empty($category_list)) {
$categories_in_exercise = array_merge($categories_in_exercise, $category_list);
}
}
if (!empty($categories_in_exercise)) {
$categories_in_exercise = array_unique(array_filter($categories_in_exercise));
}
return $categories_in_exercise;
}
/**
* Return the list of differents categories NAME for a test
* @param int exercise id
* @param bool
* @return array of string
*
* @author function rewrote by jmontoya
*/
public static function getListOfCategoriesNameForTest($in_testid)
public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
{
$tabcatName = array();
$tabcatID = self::getListOfCategoriesIDForTest($in_testid);
for ($i=0; $i < count($tabcatID); $i++) {
$cat = new TestCategory($tabcatID[$i]);
$tabcatName[$cat->id] = $cat->name;
$result = array();
$categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
foreach ($categories as $catInfo) {
$categoryId = $catInfo['id'];
if (!empty($categoryId)) {
$result[$categoryId] = array(
'title' => $catInfo['title'],
//'parent_id' => $catInfo['parent_id'],
'parent_id' => '',
'c_id' => $catInfo['c_id']
);
}
return $tabcatName;
}
return $result;
}
/**
* @param Exercise $exercise_obj
* @return array
*/
public static function getListOfCategoriesForTest(Exercise $exercise_obj)
{
$result = array();
$categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
foreach ($categories as $cat_id) {
$cat = new TestCategory($cat_id);
$cat = (array)$cat;
$cat['iid'] = $cat['id'];
$cat['title'] = $cat['name'];
$result[$cat['id']] = $cat;
}
return $result;
}
/**
@ -356,9 +415,9 @@ class TestCategory
* return : integer
* hubert.borderiou 07-04-2011
*/
public static function getNumberOfCategoriesForTest($in_testid)
public static function getNumberOfCategoriesForTest($id)
{
return count(TestCategory::getListOfCategoriesIDForTest($in_testid));
return count(TestCategory::getListOfCategoriesIDForTest($id));
}
/**
@ -397,7 +456,7 @@ class TestCategory
$nbquestionresult = 0;
$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
for ($i=0; $i < count($tabcatid); $i++) {
if ($tabcatid[$i] > 0) { // 0 = no category for this questio
if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) { // 0 = no category for this questio
$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
if ($nbQuestionInThisCat > $in_nbrandom) {
$nbquestionresult += $in_nbrandom;
@ -407,6 +466,7 @@ class TestCategory
}
}
}
return $nbquestionresult;
}
@ -433,43 +493,93 @@ class TestCategory
}
/**
* return an array of question_id for each category
* tabres[0] = array of question id with category id = 0 (i.e. no category)
* tabres[24] = array of question id with category id = 24
* In this version, a question has 0 or 1 category
* Returns an array of question ids for each category
* $categories[1][30] = 10, array with category id = 1 and question_id = 10
* A question has "n" categories
* @param int exercise
* @param array $check_in_question_list
* @param array $categoriesAddedInExercise
*
* @param int $exerciseId
* @return array
*/
public static function getQuestionsByCat($exerciseId)
{
$em = Database::getManager();
$qb = $em->createQueryBuilder();
$res = $qb
->select('qrc.questionId', 'qrc.categoryId')
->from('ChamiloCourseBundle:CQuizQuestionRelCategory', 'qrc')
->innerJoin(
'ChamiloCourseBundle:CQuizRelQuestion',
'eq',
Doctrine\ORM\Query\Expr\Join::WITH,
'qrc.questionId = eq.questionId AND qrc.cId = eq.cId'
)
->where(
$qb->expr()->eq('eq.exerciceId', $exerciseId)
)
->andWhere(
$qb->expr()->eq('eq.cId', api_get_course_int_id())
)
->getQuery()
->getResult();
$list = array();
foreach ($res as $data) {
if (!isset($list[$data['categoryId']])) {
$list[$data['categoryId']] = array();
static function getQuestionsByCat(
$exerciseId,
$check_in_question_list = array(),
$categoriesAddedInExercise = array()
) {
$tableQuestion = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$categoryTable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$exerciseId = intval($exerciseId);
$courseId = api_get_course_int_id();
$sql = "SELECT DISTINCT qrc.question_id, qrc.category_id
FROM $TBL_QUESTION_REL_CATEGORY qrc
INNER JOIN $TBL_EXERCICE_QUESTION eq
ON (eq.question_id = qrc.question_id)
INNER JOIN $categoryTable c
ON (c.id = qrc.category_id)
INNER JOIN $tableQuestion q
ON (q.id = qrc.question_id )
WHERE
exercice_id = $exerciseId AND
qrc.c_id = ".$courseId."
";
$res = Database::query($sql);
$categories = array();
while ($data = Database::fetch_array($res)) {
if (!empty($check_in_question_list)) {
if (!in_array($data['question_id'], $check_in_question_list)) {
continue;
}
}
if (!isset($categories[$data['category_id']]) ||
!is_array($categories[$data['category_id']])
) {
$categories[$data['category_id']] = array();
}
$categories[$data['category_id']][] = $data['question_id'];
}
if (!empty($categoriesAddedInExercise)) {
$newCategoryList = array();
foreach ($categoriesAddedInExercise as $category) {
$categoryId = $category['category_id'];
if (isset($categories[$categoryId])) {
$newCategoryList[$categoryId] = $categories[$categoryId];
}
}
$checkQuestionsWithNoCategory = false;
foreach ($categoriesAddedInExercise as $category) {
if (empty($category['category_id'])) {
// Check
$checkQuestionsWithNoCategory = true;
break;
}
}
$list[$data['categoryId']][] = $data['questionId'];
// Select questions that don't have any category related
if ($checkQuestionsWithNoCategory) {
$originalQuestionList = $check_in_question_list;
foreach ($originalQuestionList as $questionId) {
$categoriesFlatten = array_flatten($categories);
if (!in_array($questionId, $categoriesFlatten)) {
$newCategoryList[0][] = $questionId;
}
}
}
$categories = $newCategoryList;
}
return $list;
return $categories;
}
/**
@ -554,6 +664,33 @@ class TestCategory
}
/**
* return total score for test exe_id for all question in the category $in_cat_id for user
* If no question for this category, return ""
*/
public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
{
$tbl_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$in_cat_id = intval($in_cat_id);
$in_exe_id = intval($in_exe_id);
$in_user_id = intval($in_user_id);
$query = "SELECT DISTINCT
marks, exe_id, user_id, ta.question_id, category_id
FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc
WHERE
ta.question_id=qrc.question_id AND
qrc.category_id=$in_cat_id AND
exe_id=$in_exe_id AND user_id=$in_user_id";
$res = Database::query($query);
$totalcatscore = "";
while ($data = Database::fetch_array($res)) {
$totalcatscore += $data['marks'];
}
return $totalcatscore;
}
/**
* return the number max of question in a category
* count the number of questions in all categories, and return the max
* @param int $exerciseId
@ -631,6 +768,202 @@ class TestCategory
}
/**
* @return array
*/
function get_all_categories()
{
$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
$sql = "SELECT * FROM $table ORDER BY title ASC";
$res = Database::query($sql);
while ($row = Database::fetch_array($res,'ASSOC')) {
$array[] = $row;
}
return $array;
}
/**
* @param Exercise $exercise
* @param int $course_id
* @param string $order
* @param bool $shuffle
* @param bool $excludeCategoryWithNoQuestions
* @return array|bool
*/
public function getCategoryExerciseTree(
$exercise,
$course_id,
$order = null,
$shuffle = false,
$excludeCategoryWithNoQuestions = true
) {
if (empty($exercise)) {
return array();
}
if (!$exercise->specialCategoryOrders) {
return false;
}
$course_id = intval($course_id);
$table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
$categoryTable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$sql = "SELECT * FROM $table qc
LEFT JOIN $categoryTable c
ON (qc.c_id = c.c_id AND c.id = qc.category_id)
WHERE qc.c_id = $course_id AND exercise_id = {$exercise->id} ";
if (!empty($order)) {
$sql .= "ORDER BY $order";
}
$categories = array();
$result = Database::query($sql);
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($excludeCategoryWithNoQuestions) {
if ($row['count_questions'] == 0) {
continue;
}
}
if (empty($row['title']) && empty($row['category_id'])) {
$row['title'] = get_lang('NoCategory');
}
$categories[$row['category_id']] = $row;
}
}
if ($shuffle) {
shuffle_assoc($categories);
}
return $categories;
}
public function getForm(& $form, $action = 'new')
{
switch($action) {
case 'new':
$header = get_lang('AddACategory');
$submit = get_lang('AddTestCategory');
break;
case 'edit':
$header = get_lang('EditCategory');
$submit = get_lang('ModifyCategory');
break;
}
// settting the form elements
$form->addElement('header', $header);
$form->addElement('hidden', 'category_id');
$form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
$category_parent_list = array();
$options = array(
'1' => get_lang('Visible'),
'0' => get_lang('Hidden')
);
$form->addElement('select', 'visibility', get_lang('Visibility'), $options);
$script = null;
if (!empty($this->parent_id)) {
$parent_cat = new TestCategory($this->parent_id);
$category_parent_list = array($parent_cat->id => $parent_cat->name);
$script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>';
}
$form->addElement('html', $script);
$form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id'));
$form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
// setting the defaults
$defaults = array();
$defaults["category_id"] = $this->id;
$defaults["category_name"] = $this->name;
$defaults["category_description"] = $this->description;
$defaults["parent_id"] = $this->parent_id;
$defaults["visibility"] = $this->visibility;
$form->setDefaults($defaults);
// setting the rules
$form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
}
/**
* Returns the category form.
* @param Exercise $exercise_obj
* @return string
*/
public function returnCategoryForm(Exercise $exercise_obj)
{
$categories = $this->getListOfCategoriesForTest($exercise_obj);
$saved_categories = $exercise_obj->get_categories_in_exercise();
$return = null;
if (!empty($categories)) {
$nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
$exercise_obj->setCategoriesGrouping(true);
$real_question_count = count($exercise_obj->getQuestionList());
$warning = null;
if ($nbQuestionsTotal != $real_question_count) {
$warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
}
$return .= $warning;
$return .= '<table class="data_table">';
$return .= '<tr>';
$return .= '<th height="24">' . get_lang('Categories') . '</th>';
$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
$emptyCategory = array(
'id' => '0',
'name' => get_lang('NoCategory'),
'description' => '',
'iid' => '0',
'title' => get_lang('NoCategory')
);
$categories[] = $emptyCategory;
foreach ($categories as $category) {
$cat_id = $category['iid'];
$return .= '<tr>';
$return .= '<td>';
//$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : '');
$return .= Display::div($category['name']);
$return .= '</td>';
$return .= '<td>';
$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;
}
}
/**
* Sorts an array
* @param $array
* @return mixed
*/
public function sort_tree_array($array)
{
foreach ($array as $key => $row) {
$parent[$key] = $row['parent_id'];
}
if (count($array) > 0) {
array_multisort($parent, SORT_ASC, $array);
}
return $array;
}
/**
* Return true if a category already exists with the same name
* @param string $in_name
*

File diff suppressed because it is too large Load Diff

@ -78,6 +78,41 @@ $htmlHeadXtra[] = '<script>
function check_results_disabled() {
document.getElementById(\'exerciseType_2\').checked = true;
}
function disabledHideRandom() {
$("#hidden_random option:eq(0)").prop("selected", true);
$("#hidden_random").hide();
}
function checkQuestionSelection() {
var selection = $("#questionSelection option:selected").val()
switch (selection) {
case "\'.EX_Q_SELECTION_ORDERED.\'":
disabledHideRandom();
$("#hidden_matrix").hide();
break;
case "\'.EX_Q_SELECTION_RANDOM.\'":
$("#hidden_random").show();
$("#hidden_matrix").hide();
break;
case "\'.EX_Q_SELECTION_CATEGORIES_ORDERED_QUESTIONS_ORDERED.\'":
disabledHideRandom();
$("#hidden_matrix").show();
break;
case "per_categories":
$("#questionSelection option:eq(\'.EX_Q_SELECTION_CATEGORIES_ORDERED_QUESTIONS_ORDERED.\')").prop("selected", true);
disabledHideRandom();
$("#hidden_matrix").show();
break;
default:
disabledHideRandom();
$("#hidden_matrix").show();
break;
}
}
</script>';
// to correct #4029 Random and number of attempt menu empty added window.onload=advanced_parameters;

@ -85,6 +85,7 @@ $choice = empty($choice) ? isset($_REQUEST['choice2']) ? $_REQUEST['choice2'] :
//From submit modal
$current_question = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : null;
$currentAnswer = isset($_REQUEST['num_answer']) ? intval($_REQUEST['num_answer']) : null;
$endExercise = isset($_REQUEST['end_exercise']) && $_REQUEST['end_exercise'] == 1 ? true : false;
//Error message
$error = '';
@ -101,14 +102,15 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['prev
// 1. Loading the $objExercise variable
if (!isset($_SESSION['objExercise']) ||
$_SESSION['objExercise']->id != $_REQUEST['exerciseId']
) {
/** @var \Exercise $exerciseInSession */
$exerciseInSession = Session::read('objExercise');
if (!isset($exerciseInSession) || isset($exerciseInSession) && ($exerciseInSession->id != $_GET['exerciseId'])) {
// Construction of Exercise
$objExercise = new Exercise();
Session::write('firstTime', true);
if ($debug) {error_log('1. Setting the $objExercise variable'); };
unset($_SESSION['questionList']);
Session::erase('questionList');
// if the specified exercise doesn't exist or is disabled
if (!$objExercise->read($exerciseId) ||
@ -120,16 +122,16 @@ if (!isset($_SESSION['objExercise']) ||
} else {
// Saves the object into the session
Session::write('objExercise', $objExercise);
if ($debug) {error_log('1.1. $_SESSION[objExercise] was unset - set now - end'); };
if ($debug) {error_log('1.1. $exerciseInSession was unset - set now - end'); };
}
} else {
Session::write('firstTime', false);
}
//2. Checking if $objExercise is set
if (!isset($objExercise) && isset($_SESSION['objExercise'])) {
if (!isset($objExercise) && isset($exerciseInSession)) {
if ($debug) { error_log('2. Loading $objExercise from session'); };
$objExercise = $_SESSION['objExercise'];
$objExercise = $exerciseInSession;
}
//3. $objExercise is not set, then return to the exercise list
@ -142,10 +144,11 @@ if (!is_object($objExercise)) {
// If reminder ends we jump to the exercise_reminder
if ($objExercise->review_answers) {
if ($remind_question_id == -1) {
header('Location: exercise_reminder.php?origin='.$origin.'&exerciseId='.$exerciseId);
header('Location: exercise_reminder.php?origin='.$origin.'&exerciseId='.$exerciseId.'&'.api_get_cidreq());
exit;
}
}
$template->assign('shuffle_answers', $objExercise->random_answers);
$htmlHeadXtra[] = $template->fetch('default/exercise/submit.js.tpl');
@ -257,13 +260,45 @@ $exercise_stat_info = $objExercise->get_stat_track_exercise_info(
$learnpath_item_view_id
);
//if (1) {
$questionListInSession = Session::read('questionList');
if (!isset($questionListInSession)) {
// Selects the list of question ID
$questionList = $objExercise->getQuestionList();
// Media questions.
$media_is_activated = $objExercise->mediaIsActivated();
//Getting order from random
if ($media_is_activated == false &&
$objExercise->isRandom() &&
isset($exercise_stat_info) &&
!empty($exercise_stat_info['data_tracking'])
) {
$questionList = explode(',', $exercise_stat_info['data_tracking']);
}
Session::write('questionList', $questionList);
if ($debug > 0) {
error_log('$_SESSION[questionList] was set');
}
} else {
if (isset($objExercise) && isset($exerciseInSession)) {
$questionList = Session::read('questionList');
}
}
// Fix in order to get the correct question list.
$questionListUncompressed = $objExercise->getQuestionListWithMediasUncompressed();
Session::write('question_list_uncompressed', $questionListUncompressed);
$clock_expired_time = null;
if (empty($exercise_stat_info)) {
if ($debug) error_log('5 $exercise_stat_info is empty ');
$total_weight = 0;
$questionList = $objExercise->get_validated_question_list();
foreach ($questionList as $question_id) {
foreach ($questionListUncompressed as $question_id) {
$objQuestionTmp = Question::read($question_id);
$total_weight += floatval($objQuestionTmp->weighting);
}
@ -564,12 +599,15 @@ if ($formSent && isset($_POST)) {
}
// If questionNum comes from POST and not from GET
if (!$current_question || isset($_REQUEST['num']) && $_REQUEST['num']) {
if (!$current_question) {
$current_question = 1;
} else {
$current_question++;
$latestQuestionId = Event::getLatestQuestionIdFromAttempt($exe_id);
if (is_null($current_question)) {
$current_question = 1;
if ($latestQuestionId) {
$current_question = $objExercise->getPositionInCompressedQuestionList($latestQuestionId);
}
} else {
$current_question++;
}
if ($question_count != 0) {
@ -648,6 +686,11 @@ if ($origin != 'learnpath') { //so we are not in learnpath tool
Display :: display_warning_message(get_lang('SessionIsReadOnly'));
}
} else {
$htmlHeadXtra[] = "
<style>
body { background: none;}
</style>
";
Display::display_reduced_header();
echo '<div style="height:10px">&nbsp;</div>';
}
@ -751,7 +794,7 @@ if ($reminder == 2) {
$current_question = 1; //set by default the 1st question
if (!empty($my_remind_list)) {
//Checking which questions we are going to call from the remind list
// Checking which questions we are going to call from the remind list
for ($i = 0; $i < count($data_tracking); $i++) {
for($j = 0; $j < count($my_remind_list); $j++) {
@ -821,13 +864,17 @@ if (!empty($error)) {
if ($current_question != $i) {
continue;
} else {
if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
if ($objQuestionTmp->selectType() == HOT_SPOT ||
$objQuestionTmp->selectType() == HOT_SPOT_DELINEATION
) {
$number_of_hotspot_questions++;
}
break;
}
} else {
if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
if ($objQuestionTmp->selectType() == HOT_SPOT ||
$objQuestionTmp->selectType() == HOT_SPOT_DELINEATION
) {
$number_of_hotspot_questions++;
}
}
@ -1039,9 +1086,7 @@ if (!empty($error)) {
// Show list of questions
$i = 1;
$attempt_list = array();
if (isset($exe_id)) {
$attempt_list = Event::getAllExerciseEventByExeId($exe_id);
}
@ -1098,7 +1143,6 @@ if (!empty($error)) {
// Showing the exercise description
if (!empty($objExercise->description)){
if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i==1)) {
//echo Display::panel($objExercise->description, get_lang('ExerciseDescriptionLabel'));
echo Display::panelCollapse('<span>' .
get_lang('ExerciseDescriptionLabel') . '</span>',
$objExercise->description,

@ -33,6 +33,7 @@ class FillBlanks extends Question
*/
public function createAnswersForm($form)
{
$fillBlanksAllowedSeparator = self::getAllowedSeparator();
$defaults = array();
if (!empty($this->id)) {

@ -115,6 +115,7 @@ abstract class Question
$course_id = $course_info['real_id'];
if (empty($course_id) || $course_id == -1 ) {
return false;
}
@ -204,8 +205,6 @@ abstract class Question
*/
public function selectDescription()
{
$this->description = $this->description;
return $this->description;
}

@ -126,6 +126,9 @@ $ajax_url = api_get_path(WEB_AJAX_PATH)."exercise.ajax.php?".api_get_cidreq()."&
//we filter the type of questions we can add
Question :: display_type_menu($objExercise);
// Re sets the question list
$objExercise->setQuestionList();
echo '<div style="clear:both;"></div>';
echo '<div id="message"></div>';
$token = Security::get_token();
@ -149,11 +152,23 @@ if (!$inATest) {
echo "</tr>";
echo "</table>";
echo "</div>";
echo "<div style='clear:both'>&nbsp;</div>";
echo '<div id="question_list">';
if ($nbrQuestions) {
//Always getting list from DB
//$questionList = $objExercise->selectQuestionList(true);
$objExercise->setCategoriesGrouping(false);
// Show exercises as in category settings
//$questionList = $objExercise->getQuestionListWithMediasUncompressed();
// Show all questions no matter the category settings.
$tempCategoryOrder = $objExercise->specialCategoryOrders;
$objExercise->specialCategoryOrders = false;
$questionList = $objExercise->selectQuestionList(true);
$objExercise->specialCategoryOrders = $tempCategoryOrder;
// Style for columns
$styleQuestion = "width:50%; float:left; margin-left: 25px;";
@ -162,12 +177,15 @@ if (!$inATest) {
$styleLevel = "width:6%; float:left; text-align:center;";
$styleScore = "width:4%; float:left; text-align:center;";
$category_list = TestCategory::getListOfCategoriesNameForTest($objExercise->id, false);
if (is_array($questionList)) {
foreach ($questionList as $id) {
//To avoid warning messages
if (!is_numeric($id)) {
continue;
}
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($id);
$question_class = get_class($objQuestionTmp);

@ -345,7 +345,7 @@ function lp_upload_quiz_action_handling() {
$categoryId = null;
if (isset($categoryList[$i]) && !empty($categoryList[$i])) {
$categoryName = $categoryList[$i];
$categoryId = Testcategory::get_category_id_for_title($categoryName, $courseId);
$categoryId = TestCategory::get_category_id_for_title($categoryName, $courseId);
if (empty($categoryId)) {
$category = new TestCategory(null, $categoryName, '');
$categoryId = $category->addCategoryInBDD();

@ -70,7 +70,6 @@ define('COURSE_REQUEST_ACCEPTED', 1);
define('COURSE_REQUEST_REJECTED', 2);
define('DELETE_ACTION_ENABLED', false);
// EMAIL SENDING RECIPIENT CONSTANTS
define('SEND_EMAIL_EVERYONE', 1);
define('SEND_EMAIL_STUDENTS', 2);
@ -481,6 +480,22 @@ define('UNIQUE_ANSWER_IMAGE', 17);
define('DRAGGABLE', 18);
define('MATCHING_DRAGGABLE', 19);
define('EXERCISE_CATEGORY_RANDOM_SHUFFLED', 1);
define('EXERCISE_CATEGORY_RANDOM_ORDERED', 2);
define('EXERCISE_CATEGORY_RANDOM_DISABLED', 0);
// Question selection type
define('EX_Q_SELECTION_ORDERED', 1);
define('EX_Q_SELECTION_RANDOM', 2);
define('EX_Q_SELECTION_CATEGORIES_ORDERED_QUESTIONS_ORDERED', 3);
define('EX_Q_SELECTION_CATEGORIES_RANDOM_QUESTIONS_ORDERED', 4);
define('EX_Q_SELECTION_CATEGORIES_ORDERED_QUESTIONS_RANDOM', 5);
define('EX_Q_SELECTION_CATEGORIES_RANDOM_QUESTIONS_RANDOM', 6);
define('EX_Q_SELECTION_CATEGORIES_RANDOM_QUESTIONS_ORDERED_NO_GROUPED', 7);
define('EX_Q_SELECTION_CATEGORIES_RANDOM_QUESTIONS_RANDOM_NO_GROUPED', 8);
define('EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_ORDERED', 9);
define('EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_RANDOM', 10);
// one big string with all question types, for the validator in pear/HTML/QuickForm/Rule/QuestionType
define('QUESTION_TYPES',
UNIQUE_ANSWER.':'.
@ -6640,7 +6655,6 @@ function api_get_home_path()
$clean_url .= '/';
$home = 'app/home/' . $clean_url;
}
return $home;

@ -1796,7 +1796,7 @@ class Event
* @param array $values (passing by reference)
* @return boolean True if everything is OK, false otherwise
*/
function event_send_mail_filter_func(&$values)
public function event_send_mail_filter_func(&$values)
{
return true;
}
@ -1806,7 +1806,7 @@ class Event
* @param array $values (passing by reference)
* @return boolean True if everything is OK, false otherwise
*/
function user_registration_event_send_mail_filter_func(&$values)
public function user_registration_event_send_mail_filter_func(&$values)
{
$res = self::event_send_mail_filter_func($values);
// proper logic for this filter
@ -1818,7 +1818,7 @@ class Event
* @param array $values (passing by reference)
* @return boolean True if everything is OK, false otherwise
*/
function portal_homepage_edited_event_send_mail_filter_func(&$values)
public function portal_homepage_edited_event_send_mail_filter_func(&$values)
{
$res = self::event_send_mail_filter_func($values);
// proper logic for this filter

Loading…
Cancel
Save