[svn r18411] Fixing the querys in the question pool. If a DirectFeedback questions is enabled we filter the type of question that could be added ( see FS#3612)
$sql="INSERT INTO $TBL_EXERCICE_QUESTION(question_id,exercice_id) VALUES('".Database::escape_string($id)."','".Database::escape_string($exerciseId)."')";
$sql="INSERT INTO $TBL_EXERCICE_QUESTION (question_id, exercice_id) VALUES('".Database::escape_string($id)."','".Database::escape_string($exerciseId)."')";
api_sql_query($sql,__FILE__,__LINE__);
// we do not want to reindex if we had just saved adnd indexed the question
if (!$fromSave) {
$this->search_engine_edit($exerciseId, TRUE);
@ -1066,16 +1060,22 @@ abstract class Question
/**
* Displays the menu of question types
*/
static function display_type_menu ()
static function display_type_menu ($feedbacktype = 0)
// if we have selected an exercise in the list-box 'Filter'
if($exerciseId > 0)
{
if ($exerciseId > 0) {
//$sql="SELECT id,question,type FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS WHERE question_id=id AND exercice_id='".Database::escape_string($exerciseId)."' ORDER BY question_order LIMIT $from, ".($limitQuestPage + 1);
$sql="SELECT id,question,type,level FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS WHERE question_id=id AND exercice_id='".Database::escape_string($exerciseId)."' ".
// if we have selected the option 'Orphan questions' in the list-box 'Filter'
elseif($exerciseId == -1)
{
// Old logic: When a test is deleted, the correspondent records in 'quiz' and 'quiz_rel_question' tables are deleted.
$where = '';
if (isset($type) && $type==1) {
$where = ' type = 1 AND ';
}
if (isset($exerciseLevel) && $exerciseLevel != -1) {
$where .= ' level='.$exerciseLevel.' AND ';
}
$sql="SELECT id,question,type,level
FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS
WHERE $where question_id=id AND exercice_id='".Database::escape_string($exerciseId)."'
ORDER BY question_order";
} elseif($exerciseId == -1) {
// if we have selected the option 'Orphan questions' in the list-box 'Filter'
// 1. Old logic: When a test is deleted, the correspondent records in 'quiz' and 'quiz_rel_question' tables are deleted.
//$sql='SELECT id, question, type, exercice_id FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id WHERE exercice_id IS NULL LIMIT $from, '.($limitQuestPage + 1);
// New logic: When a test is deleted, the field 'active' takes value -1 (it is in the correspondent record in 'quiz' table).
// 2. New logic: When a test is deleted, the field 'active' takes value -1 (it is in the correspondent record in 'quiz' table).
//$sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id FROM '.$TBL_QUESTIONS.
// ' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.
// ' as exercices ON exercice_id=exercices.id WHERE exercices.active = -1 LIMIT $from, '.($limitQuestPage + 1);
// This is more safe to changes, it is a mix between old and new logic.
// 3. This is more safe to changes, it is a mix between old and new logic.
/*$sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id FROM '.$TBL_QUESTIONS.
' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.
' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1 LIMIT '.$from.', '.($limitQuestPage + 1);
' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1 LIMIT '.$from.', '.($limitQuestPage + 1);
*/
$sql='SELECT id, question, type, exercice_id,level FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id AND exercice_id IS NULL '.
/* 4. Query changed because of the Level feature implemented
$sql='SELECT id, question, type, exercice_id,level FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions
ON questions.id=quizz_questions.question_id AND exercice_id IS NULL '.