If fast edit exercise setting is on then show the question advanced settings

skala
Julio Montoya 12 years ago
parent 1c659c795c
commit 3ad4245489
  1. 4
      main/exercice/admin.php
  2. 46
      main/exercice/exercise.class.php
  3. 13
      main/exercice/exercise_submit.php
  4. 37
      main/exercice/question.class.php
  5. 5
      main/exercice/question_admin.inc.php

@ -118,8 +118,8 @@ if (empty($modifyExercise)) {
delete_all_incomplete_attempts(api_get_user_id(), $exerciseId, api_get_course_int_id(), api_get_session_id());
// get from session
$objExercise = isset($_SESSION['objExercise'])?$_SESSION['objExercise']:0;
$objQuestion = isset($_SESSION['objQuestion'])?$_SESSION['objQuestion']:0;
$objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : 0;
$objQuestion = isset($_SESSION['objQuestion']) ? $_SESSION['objQuestion'] : 0;
$objAnswer = isset($_SESSION['objAnswer'])?$_SESSION['objAnswer']:0;
// document path

@ -64,6 +64,7 @@ class Exercise
public $force_edit_exercise_in_lp = false;
public $categories;
public $categories_grouping = true;
public $fastExerciseEdition = false;
/**
* Constructor of the class
@ -101,6 +102,7 @@ class Exercise
}
$this->course_id = $course_info['real_id'];
$this->course = $course_info;
$this->fastExerciseEdition = api_get_course_setting('allow_fast_exercise_edition') == 1 ? true : false;
}
/**
@ -1148,27 +1150,24 @@ class Exercise
get_lang('ExerciseName'),
array('class' => 'span6', 'id' => 'exercise_title')
);
//$form->applyFilter('exerciseTitle','html_filter');
$form->addElement(
'advanced_settings',
'
<a href="javascript://" onclick=" return show_media()">
<span id="media_icon">
'.Display::return_icon('looknfeel.png').' '.addslashes(
api_htmlentities(get_lang('ExerciseDescription'))
).'
</span>
</a>
'
);
//if ($this->fastExerciseEdition == false) {
$form->addElement(
'advanced_settings',
'<a href="javascript://" onclick=" return show_media()">
<span id="media_icon">
'.Display::return_icon('looknfeel.png').' '.addslashes(
api_htmlentities(get_lang('ExerciseDescription'))
).'
</span>
</a>'
);
//}
$editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
if (is_array($type)) {
$editor_config = array_merge($editor_config, $type);
}
$form->addElement('html', '<div class="HideFCKEditor" id="HiddenFCKexerciseDescription" >');
$form->add_html_editor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config);
$form->addElement('html', '</div>');
@ -4583,6 +4582,19 @@ class Exercise
}
/**
* Returns an array with the media list
* @example there's 1 question with iid 5 that belongs to the media question with iid = 100
* <code>
* array (size=2)
* 999 =>
* array (size=3)
* 0 => int 7
* 1 => int 6
* 2 => int 3254
* 100 =>
* array (size=1)
* 0 => int 5
* </code>
* @return array
*/
function get_media_list()
@ -4593,11 +4605,11 @@ class Exercise
if (!empty($question_list)) {
foreach ($question_list as $questionId) {
$objQuestionTmp = Question::read($questionId);
// if a media question exists
if (isset($objQuestionTmp->parent_id) && $objQuestionTmp->parent_id != 0) {
$media_questions[$objQuestionTmp->parent_id][] = $objQuestionTmp->id;
} else {
//Always the last item
// Always the last item
$media_questions[999][] = $objQuestionTmp->id;
}
}

@ -376,6 +376,7 @@ if (api_is_allowed_to_edit(null,true) && isset($_GET['preview']) && $_GET['previ
// 1. Loading the $objExercise variable
if (!isset($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
// Construction of Exercise
/** @var Exercise $objExercise */
$objExercise = new Exercise();
if ($debug) {error_log('1. Setting the $objExercise variable'); };
unset($_SESSION['questionList']);
@ -494,8 +495,8 @@ if ($objExercise->selectAttempts() > 0) {
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
//Media questions
$media_questions = $objExercise->get_media_list();
$media_is_activated = $objExercise->media_is_activated($media_questions);
$mediaQuestions = $objExercise->get_media_list();
$media_is_activated = $objExercise->media_is_activated($mediaQuestions);
//In LP's is enabled the "remember question" feature?
@ -642,7 +643,7 @@ $exercise_title = $objExercise->selectTitle();
$exercise_sound = $objExercise->selectSound();
if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
if ($debug) error_log('8.1. Media list loaded '.print_r($media_questions, 1));
if ($debug) error_log('8.1. Media list loaded '.print_r($mediaQuestions, 1));
$question_count = $objExercise->get_count_question_list();
@ -887,6 +888,7 @@ if ($objExercise->type == ONE_PER_PAGE) {
}
$categoryList = Session::read('categoryList');
//$categoryList = null;
if (empty($categoryList)) {
$categoryList = Testcategory::getListOfCategoriesWithQuestionForTestObject($objExercise, $questionList);
@ -905,7 +907,8 @@ if ($objExercise->type == ONE_PER_PAGE) {
echo '<div class="span10">';
if (!empty($categoryList)) {
echo Display::progress_pagination_bar_with_categories($categoryList, $media_questions, $current_question, $conditions, $link);
//var_dump($categoryList, $mediaQuestions);
echo Display::progress_pagination_bar_with_categories($categoryList, $mediaQuestions, $current_question, $conditions, $link);
} else {
echo Display::progress_pagination_bar($questionList, $current_question, $conditions, $link);
}
@ -1283,7 +1286,7 @@ if (!empty($error)) {
$remind_list = explode(',', $exercise_stat_info['questions_to_check']);
}
ExerciseLib::render_question_list($objExercise, $questionList, $current_question, $exerciseResult, $attempt_list, $remind_list, $media_questions);
ExerciseLib::render_question_list($objExercise, $questionList, $current_question, $exerciseResult, $attempt_list, $remind_list, $mediaQuestions);
echo '</form>';
}

@ -1454,27 +1454,34 @@ abstract class Question
$editor_config['UserStatus'] = 'student';
}
$form->addElement(
'advanced_settings',
'<a href="javascript://" onclick=" return show_media()"><span id="media_icon">
'.Display::return_icon('looknfeel.png').'&nbsp;'.get_lang('EnrichQuestion').'</span></a>
'
);
if ($this->exercise->fastExerciseEdition == false) {
$form->addElement(
'advanced_settings',
'<a href="javascript://" onclick=" return show_media()"><span id="media_icon">
'.Display::return_icon('looknfeel.png').'&nbsp;'.get_lang('EnrichQuestion').'</span></a>
'
);
$form->addElement('html', '<div class="HideFCKEditor" id="HiddenFCKquestionDescription" >');
}
$form->addElement('html', '<div class="HideFCKEditor" id="HiddenFCKquestionDescription" >');
$form->add_html_editor('questionDescription', get_lang('QuestionDescription'), false, false, $editor_config);
$form->addElement('html', '</div>');
if ($this->exercise->fastExerciseEdition == false) {
$form->addElement('html', '</div>');
}
// hidden values
$my_id = isset($_REQUEST['myid']) ? intval($_REQUEST['myid']) : null;
$form->addElement('hidden', 'myid', $my_id);
if ($this->type != MEDIA_QUESTION) {
// Advanced parameters
$form->addElement('advanced_settings', '<a class="btn btn-show advanced_parameters" id="advanced_params" href="javascript://">'.get_lang('AdvancedParameters').'</a>');
$form->addElement('html', '<div id="advanced_params_options" style="display:none;">');
if ($this->exercise->fastExerciseEdition == false) {
// Advanced parameters
$form->addElement('advanced_settings', '<a class="btn btn-show advanced_parameters" id="advanced_params" href="javascript://">'.get_lang('AdvancedParameters').'</a>');
$form->addElement('html', '<div id="advanced_params_options" style="display:none;">');
}
$select_level = Question::get_default_levels();
$form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);
@ -1515,7 +1522,9 @@ abstract class Question
$extraFields = new ExtraField('question');
$extraFields->add_elements($form, $this->id);
$form->addElement('html', '</div>');
if ($this->exercise->fastExerciseEdition == false) {
$form->addElement('html', '</div>');
}
}
//@todo why we need this condition??

@ -48,11 +48,6 @@ if (is_object($objQuestion)) {
// form title
$form->addElement('header', $objQuestion->submitText.': '.$form_title_extra);
if ($fastEdition) {
//$form->setAllowRichEditorInForm(false);
//$form->setAllowedRichEditorList(array('questionDescription'));
}
// question form elements
$objQuestion->createForm($form);

Loading…
Cancel
Save