More Exercises UI Improvements

skala
Julio Montoya 15 years ago
parent 5afbcf08e2
commit 362563fbb9
  1. 2
      main/exercice/admin.php
  2. 31
      main/exercice/exercise.lib.php
  3. 9
      main/exercice/question.class.php
  4. 87
      main/exercice/question_list_admin.inc.php
  5. BIN
      main/img/move.png

@ -424,7 +424,7 @@ if (isset($exerciseId) && !empty($exerciseId)) {
echo '<div class="actions">';
if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
echo Display::return_icon('back.png', get_lang('GoBackToQuestionList')).' '.'<a href="admin.php?">'.get_lang('GoBackToQuestionList').'</a>';
echo Display::return_icon('back.png', get_lang('GoBackToQuestionList')).' '.'<a href="admin.php?exerciseId='.$exerciseId.'">'.get_lang('GoBackToQuestionList').'</a>';
echo Display::return_icon('preview.gif', get_lang('Preview')).'<a href="exercice_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('Preview').'</a>';
echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';

@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
* @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) {
function showQuestion($questionId, $onlyAnswers = 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';
@ -76,6 +76,10 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
} else {
$option_ie="margin-left:10px";
}
if ($answerType == FREE_ANSWER && $freeze) {
return '';
}
$s .= '<table width="720" class="exercise_options" style="width: 720px;'.$option_ie.' background-color:#fff;">';
// construction of the Answer object (also gets all answers details)
$objAnswerTmp=new Answer($questionId);
@ -118,17 +122,19 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
}
$num_suggestions = ($nbrAnswers - $x) + 1;
} elseif ($answerType == FREE_ANSWER) {
#$comment = $objAnswerTmp->selectComment(1);
//
$oFCKeditor = new FCKeditor("choice[".$questionId."]") ;
$oFCKeditor->ToolbarSet = 'TestFreeAnswer';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '' ;
$s .= '<tr><td colspan="3">';
$s .= $oFCKeditor->CreateHtml();
$s .= '</td></tr>';
$s .= '<tr><td colspan="3">'.$oFCKeditor->CreateHtml()."</td></tr>";
//$s.="<tr><td colspan='2'><textarea cols='80' rows='10' name='choice[".$questionId."]'>$answer</textarea></td></tr>";
}
@ -190,7 +196,6 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
'<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'.
$answer.
'</div></div></td></tr>';
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
// multiple answers
// set $debug_mark_answer to true at function start to
@ -214,7 +219,6 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
} elseif ($answerType == FILL_IN_BLANKS) {
// fill in blanks
$s .= '<tr><td colspan="3">'.$answer.'</td></tr>';
} else {
// matching type, showing suggestions and answers
// TODO: replace $answerId by $numAnswer
@ -311,6 +315,11 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
}
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
if ($freeze) {
echo Display::img($objQuestionTmp->selectPicturePath());
exit;
}
// Get the answers, make a list
$objAnswerTmp = new Answer($questionId);
@ -347,10 +356,12 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
echo $questionDescription=text_filter($questionDescription);
echo '</td></tr>';
}
$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
//$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
//echo $tes;
$s .= '<script language="JavaScript" type="text/javascript" src="../plugin/hotspot/JavaScriptFlashGateway.js"></script>
<script src="../plugin/hotspot/hotspot.js" type="text/javascript" language="JavaScript"></script>

@ -212,6 +212,15 @@ abstract class Question
{
return $this->picture;
}
function selectPicturePath() {
global $_course;
if (!empty($this->picture)) {
return api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/images/'.$this->picture;
}
return false;
}
/**
* returns the array with the exercise ID list

@ -64,6 +64,7 @@ if($deleteQuestion) {
</style>
<script>
$(function() {
var stop = false;
$( "#question_list h3" ).click(function( event ) {
if ( stop ) {
@ -77,12 +78,13 @@ $(function() {
.accordion({
autoHeight: false,
active: false, // all items closed by default
collapsible: true ,
collapsible: true,
header: "> div > h3"
})
.sortable({
cursor: "move", // works?
update: function(event, ui) {
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);
@ -91,7 +93,7 @@ $(function() {
},
axis: "y",
placeholder: "ui-state-highlight", //defines the yellow highlight
handle: "h3",
handle: ".moved", //only the class "moved"
stop: function() {
stop = true;
}
@ -128,42 +130,55 @@ if ($nbrQuestions) {
$question_class = get_class($objQuestionTmp);
$label = $question_class->$explanationLangVar;
//echo get_lang($question_class.$label);
echo '<div id="question_id_list_'.$id.'">';
echo '<h3><a href="#">'.$objQuestionTmp->selectTitle().'</a></h3>';
echo '<div>';
echo '<p>';
//echo $objQuestionTmp->selectLevel();
echo $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>';
// this variable $show_quiz_edition comes from admin.php blocks the exercise/quiz modifications
if ($show_quiz_edition) {
echo $delete_link = '<a href="'.api_get_self().'?'.api_get_cidreq().' &amp;deleteQuestion='.$id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))).' \')) return false;"><img src="../img/delete.gif" border="0" alt="'.get_lang('Delete').'" /></a>';
}
showQuestion($id, false, '', '',false);
echo '<div id="question_id_list_'.$id.'" >';
/*
if($i != 1) { ?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq() ?>&moveUp=<?php echo $id; ?>&token=<?php echo $token; ?>"><img src="../img/up.gif" border="0" alt="<?php echo get_lang('MoveUp'); ?>"></a>
<?php if($i == $nbrQuestions) {
echo '<img src="../img/down_na.gif">';
}
$move = Display::return_icon('move.png',get_lang('Move'), array('class'=>'moved'));
echo Display::tag('h3','<a href="#">'.$move.' '.$objQuestionTmp->selectTitle().'</a>');
echo '<div>';
echo '<p>';
$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>';
// 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().' &amp;deleteQuestion='.$id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))).' \')) return false;"><img src="../img/delete.gif" border="0" alt="'.get_lang('Delete').'" /></a>';
}
echo Display::tag('div',$edit_link.$delete_link, array('style'=>'float:right;'));
echo get_lang($question_class.$label);
echo '<br />';
echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
echo '<br />';
$description = $objQuestionTmp->selectDescription();
if (!empty($description)) {
echo get_lang('Description').': '.$description;
}
showQuestion($id, false, '', '',false, true);
/*
if($i != 1) { ?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq() ?>&moveUp=<?php echo $id; ?>&token=<?php echo $token; ?>"><img src="../img/up.gif" border="0" alt="<?php echo get_lang('MoveUp'); ?>"></a>
<?php if($i == $nbrQuestions) {
echo '<img src="../img/down_na.gif">';
}
}
if($i != $nbrQuestions) {
if($i == 1){
echo '<img src="../img/up_na.gif">';
}
if($i != $nbrQuestions) {
if($i == 1){
echo '<img src="../img/up_na.gif">';
}
?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq() ?>&moveDown=<?php echo $id; ?>&token=<?php echo $token; ?>"><img src="../img/down.gif" border="0" alt="<?php echo get_lang('MoveDown'); ?>"></a>
<?php } ?>
?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq() ?>&moveDown=<?php echo $id; ?>&token=<?php echo $token; ?>"><img src="../img/down.gif" border="0" alt="<?php echo get_lang('MoveDown'); ?>"></a>
<?php } ?>
<?php
$i++;
<?php
$i++;
*/
*/
echo '</p>';
echo '</div>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Loading…
Cancel
Save