|
|
|
@ -683,8 +683,7 @@ abstract class Question |
|
|
|
|
* @author Olivier Brouckaert |
|
|
|
|
* @param integer $exerciseId - exercise ID if saving in an exercise |
|
|
|
|
*/ |
|
|
|
|
public function save($exerciseId=0) |
|
|
|
|
{ |
|
|
|
|
function save($exerciseId=0) { |
|
|
|
|
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
|
|
|
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
|
|
|
|
|
|
|
@ -700,6 +699,7 @@ abstract class Question |
|
|
|
|
$c_id = $this->course['real_id']; |
|
|
|
|
$category = $this->category; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// question already exists |
|
|
|
|
if(!empty($id)) { |
|
|
|
|
$sql="UPDATE $TBL_QUESTIONS SET |
|
|
|
@ -1143,13 +1143,24 @@ abstract class Question |
|
|
|
|
* A subclass can redifine this function to add fields... |
|
|
|
|
* @param FormValidator $form the formvalidator instance (by reference) |
|
|
|
|
*/ |
|
|
|
|
function createForm (&$form, $fck_config=0) |
|
|
|
|
{ |
|
|
|
|
function createForm (&$form, $fck_config=0) { |
|
|
|
|
echo '<style> |
|
|
|
|
.media { display:none;} |
|
|
|
|
</style>'; |
|
|
|
|
|
|
|
|
|
echo '<script> |
|
|
|
|
// hack to hide http://cksource.com/forums/viewtopic.php?f=6&t=8700 |
|
|
|
|
|
|
|
|
|
function FCKeditor_OnComplete( editorInstance ) { |
|
|
|
|
if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name )) { |
|
|
|
|
HideFCKEditorByInstanceName (editorInstance.Name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function HideFCKEditorByInstanceName ( editorInstanceName ) { |
|
|
|
|
if (document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className == "HideFCKEditor" ) { |
|
|
|
|
document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className = "media"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function show_media(){ |
|
|
|
|
var my_display = document.getElementById(\'HiddenFCKquestionDescription\').style.display; |
|
|
|
@ -1206,7 +1217,7 @@ abstract class Question |
|
|
|
|
<a href="javascript://" onclick=" return show_media()"><span id="media_icon"><img style="vertical-align: middle;" src="../img/looknfeel.png" alt="" /> '.get_lang('EnrichQuestion').'</span></a> |
|
|
|
|
'); |
|
|
|
|
|
|
|
|
|
$form->addElement ('html','<div class="HideFCKEditor" id="HiddenFCKquestionDescription" style="display:none">'); |
|
|
|
|
$form->addElement ('html','<div class="HideFCKEditor" id="HiddenFCKquestionDescription" >'); |
|
|
|
|
$form->add_html_editor('questionDescription', get_lang('QuestionDescription'), false, false, $editor_config); |
|
|
|
|
$form->addElement ('html','</div>'); |
|
|
|
|
|
|
|
|
@ -1232,6 +1243,11 @@ abstract class Question |
|
|
|
|
$tabCat = Testcategory::getCategoriesIdAndName(); |
|
|
|
|
$form->addElement('select', 'questionCategory', get_lang('Category'), $tabCat); |
|
|
|
|
|
|
|
|
|
if (in_array($this->type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER))) { |
|
|
|
|
$buttonValue = $this->type == UNIQUE_ANSWER ? 'ConvertToMultipleAnswer' : 'ConvertToUniqueAnswer'; |
|
|
|
|
$form->addElement('button', 'convertAnswer', get_lang($buttonValue)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Medias |
|
|
|
|
//$course_medias = Question::prepare_course_media_select(api_get_course_int_id()); |
|
|
|
|
//$form->addElement('select', 'parent_id', get_lang('AttachToMedia'), $course_medias); |
|
|
|
@ -1611,4 +1627,31 @@ abstract class Question |
|
|
|
|
} |
|
|
|
|
return $html; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Swap between unique and multiple type answers |
|
|
|
|
* @return object |
|
|
|
|
*/ |
|
|
|
|
function swapAnswerTypes() |
|
|
|
|
{ |
|
|
|
|
$oppositeAnswers = array( |
|
|
|
|
UNIQUE_ANSWER => MULTIPLE_ANSWER, |
|
|
|
|
MULTIPLE_ANSWER => UNIQUE_ANSWER |
|
|
|
|
); |
|
|
|
|
$this->type = $oppositeAnswers[$this->type]; |
|
|
|
|
Database::update( |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_QUESTION), |
|
|
|
|
array('type' => $this->type), |
|
|
|
|
array('c_id = ? AND id = ?' => array($this->course['real_id'], $this->id)) |
|
|
|
|
); |
|
|
|
|
$answerClasses = array( |
|
|
|
|
UNIQUE_ANSWER => 'UniqueAnswer', |
|
|
|
|
MULTIPLE_ANSWER => 'MultipleAnswer' |
|
|
|
|
); |
|
|
|
|
$swappedAnswer = new $answerClasses[$this->type]; |
|
|
|
|
foreach ($this as $key => $value) { |
|
|
|
|
$swappedAnswer->$key = $value; |
|
|
|
|
} |
|
|
|
|
return $swappedAnswer; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|