diff --git a/main/exercice/question_create.php b/main/exercice/question_create.php index effa50f394..7a10f757f5 100755 --- a/main/exercice/question_create.php +++ b/main/exercice/question_create.php @@ -44,9 +44,12 @@ $form->addElement('static','',''); $form->addElement('static','select_question_type', get_lang('QuestionType'),'
'); +//session id +$session_id = api_get_session_id(); + // the exercices $tbl_exercices = Database :: get_course_table(TABLE_QUIZ_TEST); -$sql = "SELECT id,title,type,description, results_disabled FROM $tbl_exercices WHERE active<>'-1' ORDER BY title ASC"; +$sql = "SELECT id,title,type,description, results_disabled FROM $tbl_exercices WHERE active<>'-1' AND session_id=".$session_id." ORDER BY title ASC"; $result = Database::query($sql); $exercises['-'] = '-'.get_lang('SelectExercice').'-'; while ($row = Database :: fetch_array($result)) { diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index 22a0968674..99ab8c8b0f 100755 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -212,7 +212,7 @@ if($is_allowedToEdit) ?> - : + : '; ?> - + '.Display::return_icon('message_reply_forum.png', get_lang('GoBackToQuestionList')),get_lang('GoBackToQuestionList'),''; /*if(!empty($fromExercise)) { @@ -354,7 +354,7 @@ if($is_allowedToEdit) $answer_where = ' questions.type='.$answerType.' AND '; } - $sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id , level + $sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id , level, session_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 @@ -365,29 +365,22 @@ if($is_allowedToEdit) // if we have not selected any option in the list-box 'Filter' //$sql="SELECT id,question,type FROM $TBL_QUESTIONS LIMIT $from, ".($limitQuestPage + 1); - $where = ''; + $filter = ''; - if (isset($type)&& $type==1){ - $where = ' WHERE type = 1 '; + if (isset($type) && $type==1){ + $filter .= ' AND qu.type = 1 '; } if (isset($exerciseLevel) && $exerciseLevel != -1) { - if (strlen($where)>0) - $where .= ' AND level='.$exerciseLevel.' '; - else - $where = ' WHERE level='.$exerciseLevel.' '; + $filter .= ' AND level='.$exerciseLevel.' '; } if (isset($answerType) && $answerType != -1) { - if (strlen($where)>0) - $where .= ' AND type='.$answerType.' '; - else - $where = ' WHERE type='.$answerType.' '; + $filter .= ' AND qu.type='.$answerType.' '; } - $sql="SELECT id,question,type,level FROM $TBL_QUESTIONS $where "; - + $sql="SELECT qu.id, question, qu.type, level, q.session_id FROM $TBL_QUESTIONS as qu, $TBL_EXERCICE_QUESTION as qt, $TBL_EXERCICES as q WHERE q.id=qt.exercice_id AND qu.id=qt.question_id AND qt.exercice_id<>".$fromExercise." $filter ORDER BY session_id ASC"; // forces the value to 0 //echo $sql; $exerciseId=0; @@ -437,6 +430,7 @@ if($is_allowedToEdit) echo '
';
 
 	echo '
'; + $session_id = api_get_session_id(); while ($row = Database::fetch_array($result)) { // if we come from the exercise administration to get a question, // don't show the questions already used by that exercise @@ -464,10 +458,12 @@ if($is_allowedToEdit) //echo $row['level'],'', // '',get_lang('Reuse'),''; echo $row['level'],'', - '' . - ''.get_lang('Reuse').''; + ''; + if ($row['session_id'] == $session_id){ + echo ''.get_lang('Reuse').''; + } - echo ' ' . + echo ' ' . ''.get_lang('ReUseACopyInCurrentTest').''; } echo '';