Should fix bug when correcting open questions in exercises see #5434

skala
Julio Montoya 12 years ago
parent 60ee6d6f14
commit 008487e289
  1. 21
      main/css/base.css
  2. 8
      main/exercice/exercise.lib.php
  3. 87
      main/exercice/exercise_show.php
  4. 122
      main/exercice/freeanswer.class.php
  5. 12
      main/exercice/question.class.php
  6. 3
      main/exercice/result.php
  7. 1
      main/inc/lib/exercise_show_functions.lib.php

@ -2610,6 +2610,21 @@ div.admin_section h4 {
border-bottom: 1px solid #7A290F;
}
.ribbon .rib-gray {
background: #cccccc;
background-image: -ms-linear-gradient(top, #bbbbbb, #cccccc);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#bbbbbb), to(#cccccc));
background-image: -webkit-linear-gradient(top, #bbbbbb, #cccccc);
background-image: -o-linear-gradient(top, #bbbbbb, #cccccc);
background-image: -moz-linear-gradient(top, #bbbbbb, #cccccc);
background-image: linear-gradient(top, #bbbbbb, #cccccc);
border-top: 1px solid #bbbbbb;
border-bottom: 1px solid #bbbbbb;
}
.ribbon .rib-success, .ribbon .ribbon-total-success{
background-color: #768E00;
background-image: -ms-linear-gradient(top, #9CB80A, #768E00);
@ -2675,6 +2690,12 @@ div.admin_section h4 {
border-color: #66751B transparent transparent transparent;
}
.ribbon .rib-gray::before {
border-color: #ccc transparent transparent transparent;
}
.ribbon .rib::before {left: 0;}
.ribbon .rib::after {right: 0;}

@ -2056,7 +2056,9 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
$score = array();
if ($show_results) {
$score['result'] = get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['score'] = $my_total_score;
$score['weight'] = $my_total_weight;
}
if ($show_results) {
@ -2071,9 +2073,9 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
$question_content = '<div class="question_row">';
if ($show_results) {
if ($show_results) {
//Shows question title an description
$question_content .= $objQuestionTmp->return_header("", $counter, $score);
$question_content .= $objQuestionTmp->return_header(null, $counter, $score);
// display question category, if any
$question_content .= Testcategory::returnCategoryAndTitle($questionId);

@ -286,6 +286,10 @@ foreach ($questionList as $questionId) {
// Start buffer
ob_start();
/* Use switch
switch ($answerType) {
}*/
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
@ -464,12 +468,9 @@ foreach ($questionList as $questionId) {
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfree = Database::query($queryfree);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;
?>
</table>
</td></tr>
<?php
echo '<tr>
$totalScore+=$questionScore;
echo '</table></td></tr>';
echo '<tr>
<td colspan="2">
<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" width="556" height="350">
<param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" />
@ -478,7 +479,7 @@ foreach ($questionList as $questionId) {
</td>
</tr>
</table>';
}
}
}
if ($show_results) {
@ -487,67 +488,61 @@ foreach ($questionList as $questionId) {
}
}
if ($show_results) {
//if (0) {
echo '<table width="100%" border="0" cellspacing="3" cellpadding="0">';
if ($is_allowedToEdit && $locked == false && !api_is_drh() ) {
echo '<tr><td>';
if ($show_results) {
if ($is_allowedToEdit && $locked == false && !api_is_drh()) {
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
?>
<br />
<a class="btn" href="javascript://" onclick="showfck('<?php echo $name; ?>','<?php echo $marksname; ?>');">
<?php
$marksname = "marksName".$questionId;
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
echo get_lang('EditCommentsAndMarks');
$url_name = get_lang('EditCommentsAndMarks');
} else {
if ($action=='edit') {
echo '<img src="../img/edit.gif"/>'.get_lang('EditIndividualComment');
$url_name = get_lang('EditIndividualComment');
} else {
echo get_lang('AddComments');
$url_name = get_lang('AddComments');
}
}
echo '</a><br /><div id="feedback_'.$name.'" style="width:100%">';
echo '<br />';
echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick'=>"showfck('".$name."', '".$marksname."');"));
echo '<br />';
echo '<div id="feedback_'.$name.'" style="width:100%">';
$comnt = trim(get_comments($id,$questionId));
if (empty($comnt)) {
echo '<br />';
} else {
echo '<div id="question_feedback">'.$comnt.'</div>';
}
echo '</div><div id="'.$name.'" style="display:none">';
echo '</div>';
echo '<div id="'.$name.'" style="display:none">';
$arrid[] = $questionId;
$feedback_form = new FormValidator('frmcomments'.$questionId,'post','');
$feedback_form->addElement('html','<br>');
$renderer =& $feedback_form->defaultRenderer();
$renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
$renderer->setElementTemplate('<div align="left">{element}</div>');
$comnt = get_comments($id,$questionId);
${user.$questionId}['comments_'.$questionId] = $comnt;
$comnt = get_comments($id, $questionId);
$default = array('comments_'.$questionId => $comnt);
$feedback_form->addElement('html_editor', 'comments_'.$questionId, null, null, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '100%', 'Height' => '120'));
$feedback_form->addElement('html','<br>');
//$feedback_form->addElement('submit','submitQuestion',get_lang('Ok'));
$feedback_form->setDefaults(${user.$questionId});
$feedback_form->addElement('html','<br>');
$feedback_form->setDefaults($default);
$feedback_form->display();
echo '</div>';
} else {
$comnt = get_comments($id,$questionId);
echo '<tr><td><br />';
$comnt = get_comments($id, $questionId);
echo '<br />';
if (!empty($comnt)) {
echo '<b>'.get_lang('Feedback').'</b>';
echo '<div id="question_feedback">'.$comnt.'</div>';
}
echo '</td><td>';
}
}
}
if ($is_allowedToEdit) {
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
$marksname = "marksName".$questionId;
?>
<div id="<?php echo $marksname; ?>" style="display:none">
<form name="marksform_<?php echo $questionId; ?>" method="post" action="">
<?php
echo '<div id="'.$marksname.'" style="display:none" >';
echo '<form name="marksform_'.$questionId.'" method="post" action="">';
$arrmarks[] = $questionId;
echo get_lang("AssignMarks");
echo "&nbsp;<select name='marks' id='marks'>";
@ -566,13 +561,10 @@ foreach ($questionList as $questionId) {
<select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form><br/ ></div>';
}
} else {
if ($questionScore==-1) {
$questionScore=0;
if ($questionScore == -1) {
$questionScore = 0;
}
}
echo '</td>
</tr>
</table>';
}
}
$my_total_score = $questionScore;
@ -586,7 +578,10 @@ foreach ($questionList as $questionId) {
$score = array();
if ($show_results) {
$score['result'] = get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['type'] = $answerType;
$score['score'] = $my_total_score;
$score['weight'] = $my_total_weight;
}
unset($objAnswerTmp);
@ -598,7 +593,7 @@ foreach ($questionList as $questionId) {
if ($show_results) {
//Shows question title an description
$question_content .= $objQuestionTmp->return_header("", $counter, $score);
$question_content .= $objQuestionTmp->return_header(null, $counter, $score);
// display question category, if any
$question_content .= Testcategory::returnCategoryAndTitle($questionId);

@ -1,70 +1,76 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File containing the FreeAnswer class.
* This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question
* @package chamilo.exercise
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/**
* Code
* File containing the FreeAnswer class.
* This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question
* @package chamilo.exercise
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('FreeAnswer')):
/**
* @package chamilo.exercise
* Code
*/
class FreeAnswer extends Question {
if (!class_exists('FreeAnswer')):
/**
* @package chamilo.exercise
*/
class FreeAnswer extends Question {
static $typePicture = 'open_answer.gif';
static $explanationLangVar = 'FreeAnswer';
/**
* Constructor
*/
function FreeAnswer() {
parent::question();
$this->type = FREE_ANSWER;
$this->isContent = $this->getIsContent();
}
static $typePicture = 'open_answer.gif';
static $explanationLangVar = 'FreeAnswer';
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm($form) {
$form->addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1'));
global $text, $class;
// setting the save button here and not in the question class.php
$form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
if (!empty($this->id)) {
$form->setDefaults(array('weighting' => float_format($this->weighting, 1)));
} else {
if ($this->isContent == 1) {
$form->setDefaults(array('weighting' => '10'));
}
}
}
/**
* Constructor
*/
function FreeAnswer(){
parent::question();
$this -> type = FREE_ANSWER;
$this -> isContent = $this-> getIsContent();
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
*/
function processAnswersCreation($form) {
$this->weighting = $form->getSubmitValue('weighting');
$this->save();
}
/**
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm ($form)
{
$form -> addElement('text','weighting',get_lang('Weighting'), array('class' => 'span1'));
global $text, $class;
// setting the save button here and not in the question class.php
$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
if (!empty($this->id)) {
$form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
} else {
if ($this -> isContent == 1) {
$form -> setDefaults(array('weighting' => '10'));
}
}
}
function return_header($feedback_type = null, $counter = null, $score = null) {
if ((int) $score['score'] == 0) {
$score['revised'] = false;
} else {
$score['revised'] = true;
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
*/
function processAnswersCreation($form)
{
$this -> weighting = $form -> getSubmitValue('weighting');
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null) {
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="'.$this->question_table_class .'" >
$header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="' . $this->question_table_class . '" >
<tr>
<th>'.get_lang("Answer").'</th>
</tr>';
return $header;
}
}
<th>' . get_lang("Answer") . '</th>
</tr>';
return $header;
}
}
endif;

@ -1373,6 +1373,7 @@ abstract class Question
* @param type $score
*/
function return_header($feedback_type = null, $counter = null, $score = null) {
$counter_label = '';
if (!empty($counter)) {
$counter_label = intval($counter);
@ -1383,6 +1384,17 @@ abstract class Question
$score_label = get_lang('Correct');
$class = 'success';
}
if ($this->type == FREE_ANSWER) {
if ($score['revised'] == true) {
$score_label = get_lang('Revised');
$class = 'gray';
} else {
$score_label = get_lang('NotRevised');
$class = 'gray';
}
}
$question_title = get_lang("Question").' '.($counter_label).' : '.$this->question;
$header = Display::div('<div class="rib rib-'.$class.'"><h3>'.$score_label.'</h3></div><h4>'.$question_title.'</h4><h5 class="'.$class.'">'.$score['result'].' </h5>', array('class'=>'ribbon'));
$header .= Display::div($this->description, array('id'=>'question_description'));

@ -74,8 +74,7 @@ if (!$is_allowedToEdit) {
if ($show_headers) {
$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
$interbreadcrumb[] = array("url" => "#","name" => get_lang('Result'));
$this_section = SECTION_COURSES;
$this_section = SECTION_COURSES;
Display::display_header();
} else {
Display::display_reduced_header();

@ -206,7 +206,6 @@ class ExerciseShowFunctions {
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%">
<?php
if ($studentChoice) {
if ($answerCorrect) {
$color = 'green';

Loading…
Cancel
Save