Adding some exercises alpha improvements ...

skala
Julio Montoya 15 years ago
parent f829bbd363
commit ee4f7404e2
  1. 2
      main/css/chamilo/default.css
  2. 9
      main/exercice/admin.php
  3. 31
      main/exercice/exercice.php
  4. 2
      main/exercice/exercice_submit.php
  5. 40
      main/exercice/exercise.lib.php
  6. 1
      main/exercice/question_admin.inc.php
  7. 126
      main/exercice/question_list_admin.inc.php
  8. BIN
      main/img/clean_group.png
  9. BIN
      main/img/delete.png
  10. BIN
      main/img/export_db.png
  11. BIN
      main/img/settings.png
  12. 25
      main/inc/ajax/exercise.ajax.php
  13. 2
      main/inc/ajax/message.ajax.php
  14. 2
      main/newscorm/learnpath_functions.inc.php

@ -1547,7 +1547,7 @@ div.row div.form_header {
div.row div.label {
float: left;
width: 8%;
width: 9%;
text-align: right;
}
div.row div.formw {

@ -286,6 +286,13 @@ if($modifyIn == 'thisExercise') {
}
}
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-1.4.4.min.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui-1.8.7.custom.min.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui-css/cupertino/jquery-ui-1.8.7.custom.css" type="text/css" media="print, projection, screen">';
$htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
<script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
<script language=\"JavaScript\" type=\"text/javascript\">
@ -418,8 +425,10 @@ 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('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>';
echo '</div>';
if(isset($_GET['message'])) {

@ -425,11 +425,9 @@ if (!empty ($_POST['export_report']) && $_POST['export_report'] == 'export_repor
if ($origin != 'learnpath') {
//so we are not in learnpath tool
Display :: display_header($nameTools, "Exercise");
Display :: display_header($nameTools, get_lang('Exercise'));
if (isset ($_GET['message'])) {
if (in_array($_GET['message'], array (
'ExerciseEdited'
))) {
if (in_array($_GET['message'], array ('ExerciseEdited'))) {
Display :: display_confirmation_message(get_lang($_GET['message']));
}
}
@ -816,19 +814,23 @@ if ($show == 'test') {
echo '<td align="center">';
if ($session_id == $row['session_id']) {
?>
<a href="admin.php?<?php echo api_get_cidreq()?>&amp;exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=copy_exercise&amp;sec_token=<?php echo $token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=clean_results&amp;sec_token=<?php echo $token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;" ><img width="16" src="../img/clean_group.gif" border="0" title="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=delete&sec_token=<?php echo$token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;"> <img src="../img/delete.gif" border="0" title="<?php echo get_lang('Delete'); ?>" alt="<?php echo api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
<a href="admin.php?<?php echo api_get_cidreq()?>&amp;exerciseId=<?php echo $row['id']; ?>">
<img src="../img/settings.png" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=copy_exercise&amp;sec_token=<?php echo $token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;">
<img width="22" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=clean_results&amp;sec_token=<?php echo $token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;" >
<img width="22" src="../img/clean_group.png" border="0" title="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" /></a>
<?php
//if active
if ($row['active']) {
?>
<a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=disable&sec_token=<?php echo$token; ?>&amp;page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/visible.gif" border="0" title="<?php echo get_lang('Deactivate'); ?>" alt="<?php echo api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=disable&sec_token=<?php echo$token; ?>&amp;page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>">
<img src="../img/visible.gif" border="0" title="<?php echo get_lang('Deactivate'); ?>" alt="<?php echo api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
<?php
} else { // else if not active
?>
<a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=enable&sec_token=<?php echo$token; ?>&amp;page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" title="<?php echo get_lang('Activate'); ?>" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=enable&sec_token=<?php echo$token; ?>&amp;page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>">
<img src="../img/invisible.gif" border="0" title="<?php echo get_lang('Activate'); ?>" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
<?php
}
// Export qti ...
@ -839,6 +841,15 @@ if ($show == 'test') {
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=copy_exercise&amp;sec_token=<?php echo $token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
<?php
}
//last option is deleted
if ($session_id == $row['session_id']) {
?>
<a href="exercice.php?<?php echo api_get_cidreq() ?>&choice=delete&sec_token=<?php echo$token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset)); echo " ".addslashes($row['title']); echo "?"; ?>')) return false;">
<img width="22" src="../img/delete.png" border="0" title="<?php echo get_lang('Delete'); ?>" alt="<?php echo api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
<?php
}
echo "</td>";
echo "</tr>";
} else { // student only

@ -630,7 +630,7 @@ if (!empty ($error)) {
}
}
// shows the question and its answers
showQuestion($questionId, false, $origin, $i, $nbrQuestions);
showQuestion($questionId, false, $origin, $i);
$i++;
// for sequential exercises
if ($exerciseType == ONE_PER_PAGE) {

@ -13,13 +13,15 @@
require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
/**
* @param int question id
* @param boolean only answers
* @param boolean origin i.e = learnpath
* @param int current item from the list of questions
* @param int number of total questions
* Shows a question
*
* @param int question id
* @param bool only answers
* @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, $total_item) {
function showQuestion($questionId, $onlyAnswers = false, $origin = false, $current_item = '', $show_title = true) {
// Text direction for the current language
$is_ltr_text_direction = api_get_text_direction() != 'rtl';
@ -43,16 +45,18 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$questionDescription=$objQuestionTmp->selectDescription();
$questionName=text_filter($questionName);
$s='<div id="question_title" class="sectiontitle">'.get_lang('Question').' ';
$s.=$current_item;
//@todo I need the get the feedback type
//if($answerType != 1)
//$s.=' / '.$total_item;
echo $s;
echo ' : ';
echo $questionName.'</div>';
if ($show_title) {
$s='<div id="question_title" class="sectiontitle">'.get_lang('Question').' ';
$s.=$current_item;
//@todo I need the get the feedback type
//if($answerType != 1)
//$s.=' / '.$total_item;
echo $s;
echo ' : ';
echo $questionName.'</div>';
}
$s='';
$s.='<table class="exercise_questions" style="margin:4px 4px 4px 0px; padding:2px;">
<tr><td valign="top" colspan="2">';
@ -330,7 +334,9 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$answer_list .= '</dl></div>';
if (!$onlyAnswers) {
echo '<div id="question_title" class="sectiontitle">'.get_lang('Question').' '.$current_item.' : '.$questionName.'</div>';
if ($show_title) {
echo '<div id="question_title" class="sectiontitle">'.get_lang('Question').' '.$current_item.' : '.$questionName.'</div>';
}
//@todo I need to the get the feedback type
//if($answerType == 2)
// $s.=' / '.$total_item;

@ -44,6 +44,7 @@ if(isset($_GET['editQuestion'])) {
$action = api_get_self()."?".api_get_cidreq()."&modifyQuestion=".$modifyQuestion."&newQuestion=".$newQuestion;
}
if(is_object($objQuestion)) {
//INIT FORM
$form = new FormValidator('question_admin_form','post',$action);

@ -22,7 +22,7 @@
if(!defined('ALLOWED_TO_INCLUDE')) {
exit();
}
/*
// moves a question up in the list
if(isset($_GET['moveUp'])) {
$check = Security::get_token('get');
@ -42,7 +42,7 @@ if(isset($_GET['moveDown'])) {
}
Security::clear_token();
}
*/
// deletes a question from the exercise (not from the data base)
if($deleteQuestion) {
@ -55,55 +55,97 @@ if($deleteQuestion) {
$nbrQuestions--;
}
}
// destruction of the Question object
unset($objQuestionTmp);
}
echo '<div class="actionsbig">';
//we filter the type of questions we can add
Question :: display_type_menu ($objExercise->feedbacktype);
echo '</div>';
?>
<style>
.ui-state-highlight { height: 30px; line-height: 1.2em; }
</style>
<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"
})
.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: "h3",
stop: function() {
stop = true;
}
});
});
</script>
<?php
<div class="content_table"><table class="data_table">
<span class="row_odd">
<th><?php echo get_lang('Question'); ?></th>
<th><?php echo get_lang('Type');?></th>
<th><?php echo get_lang('Difficulty'); ?></th>
<!--<th><?php //echo get_lang('Export'); ?></th>-->
<th><?php echo get_lang('Modify'); ?></th>
</span>
<?php
echo '<div class="actionsbig">';
//we filter the type of questions we can add
Question :: display_type_menu ($objExercise->feedbacktype);
echo '</div><div style="clear:both;">';
echo '<div id="message">ddddddddd</div>';
$token = Security::get_token();
if($nbrQuestions) {
$questionList=$objExercise->selectQuestionList();
if ($nbrQuestions) {
$my_exercise = new Exercise();
//forces the query to the database
$my_exercise->read($_GET['exerciseId']);
$questionList=$my_exercise->selectQuestionList();
$i=1;
if (is_array($questionList)) {
if (is_array($questionList)) {
echo '<div id="question_list">';
foreach($questionList as $id) {
//To avoid warning messages
if (!is_numeric($id)) {
continue;
}
}
$objQuestionTmp = Question :: read($id);
//showQuestion($id);
?>
<tr <?php if($i%2==0) echo 'class="row_odd"'; else echo 'class="row_even"'; ?>>
<td><?php echo "$i. ".$objQuestionTmp->selectTitle(); ?></td>
<td><?php eval('echo get_lang('.get_class($objQuestionTmp).'::$explanationLangVar);'); ?></td>
<td align="center"><?php echo $objQuestionTmp->selectLevel(); ?></td>
<td>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq() ?>&type=<?php echo $objQuestionTmp->selectType(); ?>&myid=1&editQuestion=<?php echo $id; ?>"><img src="../img/edit.gif" border="0" alt="<?php echo get_lang('Modify'); ?>" /></a>
<?php
// this variable $show_quiz_edition comes from admin.php blocks the exercise/quiz modifications
if ($show_quiz_edition) { ?>
<a href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq() ?>&amp;deleteQuestion=<?php echo $id; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;"><img src="../img/delete.gif" border="0" alt="<?php echo get_lang('Delete'); ?>" /></a>
$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>';
<?php
// 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);
/*
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) {
@ -117,14 +159,18 @@ if($nbrQuestions) {
?>
<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 } ?>
</td>
<?php
$i++;
unset($objQuestionTmp);
?>
</tr>
<?php
*/
echo '</p>';
echo '</div>';
echo '</div>';
unset($objQuestionTmp);
}
echo '</div>';
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,25 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
require_once '../global.inc.php';
$action = $_REQUEST['a'];
switch ($action) {
case 'update_question_order':
$new_question_list = $_POST['question_id_list'];
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$counter = 1;
foreach ($new_question_list as $new_order_id) {
Database::update_query($TBL_QUESTIONS, array('question_order'=>$counter), array('question_id = ? '=>$new_order_id));
$counter++;
}
Display::display_confirmation_message(get_lang('Saved'));
break;
default:
echo '';
}
exit;
?>

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/

@ -1326,7 +1326,7 @@ function export_exercise($item_id) {
echo $s = "<tr bgcolor='#e6e6e6'><td valign='top' colspan='2'>".get_lang('Question')." ";
// Call the showQuestion() function from exercise.lib.php. This basically displays the question in a table.
$test .= showQuestion($questionId, false, 'export', $i, $nbrQuestions);
$test .= showQuestion($questionId, false, 'export', $i);
} // end foreach()

Loading…
Cancel
Save