Adding links in the accordion header

skala
Julio Montoya 16 years ago
parent e30f3c82d6
commit f5ee76136d
  1. 6
      main/exercice/admin.php
  2. 31
      main/exercice/exercise.lib.php
  3. 105
      main/exercice/question_list_admin.inc.php

@ -304,11 +304,7 @@ function multiple_answer_true_false_onchange(variable) {
}
document.getElementById(weight_id).value = array_result[result];
}
</script>';

@ -16,12 +16,12 @@ require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
* Shows a question
*
* @param int question id
* @param bool only answers
* @param bool if true only show the questions, no exercise title etc
* @param bool origin i.e = learnpath
* @param int current item from the list of questions
* @param int number of total questions
* */
function showQuestion($questionId, $onlyAnswers = false, $origin = false, $current_item = '', $show_title = true, $freeze = false) {
function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false) {
// Text direction for the current language
$is_ltr_text_direction = api_get_text_direction() != 'rtl';
@ -42,7 +42,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
if ($answerType != HOT_SPOT) {
// Question is not of type hotspot
if (!$onlyAnswers) {
if (!$only_questions) {
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
@ -141,13 +141,9 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$s .= '<tr><td colspan="3">';
$s .= $oFCKeditor->CreateHtml();
$s .= '</td></tr>';
}
?>
<style>
}
?>
<style>
#questions {
width:40%;
@ -237,8 +233,8 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
}
for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
if ($answerType == FILL_IN_BLANKS) {
@ -278,7 +274,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
// multiple answers
// set $debug_mark_answer to true at function start to
// show the correct answer with a suffix '-x'
$help = $selected = '';
$help = $selected = '';
if ($debug_mark_answer) {
if ($answerCorrect) {
$help = 'x-';
@ -293,6 +289,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$s .= '<tr><td colspan="3"><div class="u-m-answer"><p style="float: '.($is_ltr_text_direction ? 'left' : 'right').'; padding-'.($is_ltr_text_direction ? 'right' : 'left').': 4px;">';
$options = array('type'=>'checkbox','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
if ($answerCorrect) {
$options['checked'] = 'checked';
}
@ -421,7 +418,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
} // end for()
/*
//Adding divs for the new MATCHING interface
if ($answerType == MATCHING && !$freeze) {
@ -435,13 +432,13 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
echo '</div>';
echo Display::tag('h2','Options');
echo Display::tag('h2','Options');
echo '<div id="options" class=" ui-widget-header">';
foreach ($select_items as $key=>$val) {
echo Display::tag('div', Display::tag('p',$val['answer']), array('id'=>'option_'.$i, 'class'=>'option_item ui-widget-content'));
}
echo '</ul>';
}
}*/
$s .= '</table>';
@ -504,7 +501,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
}
$answer_list .= '</dl></div>';
if (!$onlyAnswers) {
if (!$only_questions) {
if ($show_title) {
echo '<div id="question_title" class="sectiontitle">'.get_lang('Question').' '.$current_item.' : '.$questionName.'</div>';
}

@ -62,39 +62,53 @@ if($deleteQuestion) {
<script>
$(function() {
var stop = false;
$( "#question_list h3" ).click(function( event ) {
if ( stop ) {
event.stopImmediatePropagation();
event.preventDefault();
stop = false;
}
});
$( "#question_list" )
.accordion({
autoHeight: false,
active: false, // all items closed by default
collapsible: true,
header: "> div > h3"
})
var stop = false;
$( "#question_list h3" ).click(function( event ) {
if ( stop ) {
event.stopImmediatePropagation();
event.preventDefault();
stop = false;
}
});
var icons = {
header: "ui-icon-circle-arrow-e",
headerSelected: "ui-icon-circle-arrow-s"
};
.sortable({
cursor: "move", // works?
update: function(event, ui) {
var order = $(this).sortable("serialize") + "&a=update_question_order";
$.post("<?php echo api_get_path(WEB_AJAX_PATH)?>exercise.ajax.php", order, function(reponse){
$("#message").html(reponse);
});
},
axis: "y",
placeholder: "ui-state-highlight", //defines the yellow highlight
handle: ".moved", //only the class "moved"
stop: function() {
stop = true;
}
});
/*We can add links in the accordion header*/
$("div > div > div > .edition > div > a").click(function() {
newWind = window.open(this.href,"_self");
newWind.focus();
return false;
});
$( "#question_list" ).accordion({
icons: icons,
autoHeight: false,
active: false, // all items closed by default
collapsible: true,
header: ".test1",
})
.sortable({
cursor: "move", // works?
update: function(event, ui) {
var order = $(this).sortable("serialize") + "&a=update_question_order";
$.post("<?php echo api_get_path(WEB_AJAX_PATH)?>exercise.ajax.php", order, function(reponse){
$("#message").html(reponse);
});
},
axis: "y",
placeholder: "ui-state-highlight", //defines the yellow highlight
handle: ".moved", //only the class "moved"
stop: function() {
stop = true;
}
});
});
@ -128,31 +142,38 @@ if ($nbrQuestions) {
}
$objQuestionTmp = Question :: read($id);
$question_class = get_class($objQuestionTmp);
$label = $question_class->$explanationLangVar;
$label = $question_class->$explanationLangVar;
$edit_link = '<a href="'.api_get_self().'?'.api_get_cidreq().'&type='.$objQuestionTmp->selectType().'&myid=1&editQuestion='.$id.'"><img src="../img/edit.gif" border="0" alt="'.get_lang('Modify').'" /></a>';
$edit_link = '<a href="'.api_get_self().'?'.api_get_cidreq().'&type='.$objQuestionTmp->selectType().'&myid=1&editQuestion='.$id.'">'.Display::return_icon('edit.gif',get_lang('Modify')).'</a>';
// this variable $show_quiz_edition comes from admin.php blocks the exercise/quiz modifications
if ($show_quiz_edition) {
$delete_link = '<a href="'.api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId.'&deleteQuestion='.$id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))).' \')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a>';
}
$actions = Display::tag('div',$edit_link.$delete_link, array('style'=>'float:right'));
$edit_link = Display::tag('div',$edit_link, array('style'=>'float:left;padding:0px; margin:0px'));
$delete_link = Display::tag('div',$delete_link, array('style'=>'float:left;padding:0px; margin:0px'));
$actions = Display::tag('div',$edit_link.$delete_link, array('class'=>'edition','style'=>'width:110px; right:10px; margin-top: 0px; position: absolute; top: 10%;'));
echo '<div id="question_id_list_'.$id.'" >';
$move = Display::return_icon('move.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
echo Display::tag('h3','<a href="#">'.$move.' '.$objQuestionTmp->selectTitle().' <span style="float: right; padding-top: 0.3em;">['.get_lang('QualificationNumeric').': '.$objQuestionTmp->selectWeighting().']</span></a>');
echo '<div id="question_id_list_'.$id.'" >';
echo '<div class="test1">';
$move = Display::return_icon('move.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
echo Display::tag('span','<a href="#">'.$move.' '.$objQuestionTmp->selectTitle().' '. Display::tag('span','['.get_lang('QualificationNumeric').': '.$objQuestionTmp->selectWeighting().']', array('style'=>"right:110px; position: absolute;padding-top: 0.3em;")).'</a>', array('style'=>''));
echo $actions;
echo '</div>';
echo '<div class="question-list-description-block">';
echo '<p>';
echo $actions;
//echo $actions;
echo get_lang($question_class.$label);
echo '<br />';
echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
echo '<br />';
showQuestion($id, false, '', '',false, true);
echo '</p>';
echo '</p>';
echo '</div>';
echo '</div>';
unset($objQuestionTmp);
}
echo '</div>';

Loading…
Cancel
Save