Replacing exercise_min_note to exercise_min_score platform settings (same thing with the max score)

skala
Julio Montoya 14 years ago
parent f102a6380f
commit e3499250d3
  1. 2
      main/exercice/admin.php
  2. 12
      main/exercice/exercise.class.php
  3. 23
      main/exercice/exercise.lib.php
  4. 33
      main/exercice/exercise_show.php
  5. 13
      main/exercice/multiple_answer_true_false.class.php
  6. 6
      main/install/db_main.sql
  7. 4
      main/install/migrate-db-1.8.7-1.8.8-pre.sql

@ -488,7 +488,7 @@ if(!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspota
Display::display_confirmation_message(get_lang('ExerciseEdited')); Display::display_confirmation_message(get_lang('ExerciseEdited'));
} }
if(api_get_setting('search_enabled')=='true' && !extension_loaded('xapian')) { if(api_get_setting('search_enabled')=='true' && !extension_loaded('xapian')) {
Display::display_error_message(get_lang('SearchXapianModuleNotInstaled')); Display::display_error_message(get_lang('SearchXapianModuleNotInstaled'));
} }
$form -> display (); $form -> display ();
echo '<br />'; echo '<br />';

@ -1658,7 +1658,7 @@ class Exercise {
$questionName = $objQuestionTmp->selectTitle(); $questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription(); $questionDescription = $objQuestionTmp->selectDescription();
$questionWeighting = $objQuestionTmp->selectWeighting(); $questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType(); $answerType = $objQuestionTmp->selectType();
$quesId = $objQuestionTmp->selectId(); $quesId = $objQuestionTmp->selectId();
$extra = $objQuestionTmp->extra; $extra = $objQuestionTmp->extra;
@ -1697,7 +1697,7 @@ class Exercise {
$real_answers = array(); $real_answers = array();
$quiz_question_options = Question::readQuestionOption($questionId); $quiz_question_options = Question::readQuestionOption($questionId);
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId); $answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId); $answerComment = $objAnswerTmp->selectComment($answerId);
@ -1757,9 +1757,9 @@ class Exercise {
$questionScore += $doubt_score; $questionScore += $doubt_score;
} }
} }
$questionWeighting+=$true_score; //$questionWeighting+=$true_score;
$totalScore +=$true_score; $totalScore +=$true_score;
//echo $studentChoice.' - '.$answerCorrect.' '.$questionScore.'<br />'; //echo $studentChoice.' - '.$answerCorrect.' '.$questionScore.' - '.$questionWeighting.'<br />';
break; break;
case MULTIPLE_ANSWER : case MULTIPLE_ANSWER :
if ($from_database) { if ($from_database) {
@ -2408,7 +2408,9 @@ class Exercise {
$sql_update = 'UPDATE ' . $stat_table . ' SET exe_result = exe_result + ' . (int) $totalScore . ',exe_weighting = exe_weighting + ' . (int) $totalWeighting . ' WHERE exe_id = ' . $exeId; $sql_update = 'UPDATE ' . $stat_table . ' SET exe_result = exe_result + ' . (int) $totalScore . ',exe_weighting = exe_weighting + ' . (int) $totalWeighting . ' WHERE exe_id = ' . $exeId;
Database::query($sql_update); Database::query($sql_update);
} }
return array('score'=>$questionScore, 'weight'=>$questionWeighting);
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting);
return $return_array;
} //End function } //End function

@ -1073,22 +1073,37 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
return $list_info; return $list_info;
} }
/**
* Transform the score with exercise_max_note and exercise_min_score the platform settings
* @param float score
* @param float weight
* @param bool show porcentage or not
* @return string an html with the score modified
*/
function show_score($score, $weight, $show_porcentage = true) { function show_score($score, $weight, $show_porcentage = true) {
$html = ''; $html = '';
$score_rounded = $score; $score_rounded = $score;
if ($score != '' && $weight != '') { if ($score != '' && $weight != '') {
$max_note = api_get_setting('exercise_max_note'); $max_note = api_get_setting('exercise_max_score');
$min_note = api_get_setting('exercise_min_note'); $min_note = api_get_setting('exercise_min_score');
if ($max_note != '' && $min_note != '') { if ($max_note != '' && $min_note != '') {
if (!empty($weight)) { if (!empty($weight)) {
$score = $min_note + ($max_note - $min_note) * $score /$weight; $score = $min_note + ($max_note - $min_note) * $score /$weight;
} else { } else {
$score = $min_note; $score = $min_note;
} }
$score_rounded = round($score, 2); $score_rounded = round($score, 2);
$weight = $max_note; $weight = $max_note;
} }
$html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')'; if ($show_porcentage) {
$html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')';
} else {
$html = $score_rounded . ' / ' . $weight;
}
} }
return $html; return $html;
} }

@ -314,7 +314,13 @@ if ($show_results) {
// for each question // for each question
$counter=0; $counter=0;
//var_dump($exerciseResult);
$total_weighting = 0;
foreach ($questionList as $questionId) {
$objQuestionTmp = Question::read($questionId);
$total_weighting +=$objQuestionTmp->selectWeighting();
}
foreach ($questionList as $questionId) { foreach ($questionList as $questionId) {
$counter++; $counter++;
$choice=$exerciseResult[$questionId]; $choice=$exerciseResult[$questionId];
@ -372,7 +378,7 @@ if ($show_results) {
//var_dump($question_result); //var_dump($question_result);
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
$questionWeighting += $question_result['weight']; //$questionWeighting += $question_result['weight'];
echo '</table>'; echo '</table>';
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
@ -393,8 +399,7 @@ if ($show_results) {
</tr> </tr>
<?php <?php
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true); $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true);
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
@ -574,10 +579,11 @@ if ($show_results) {
</table> </table>
<?php <?php
$my_total_score = float_format($questionScore,1); $my_total_score = float_format($questionScore,1);
$my_total_weight = float_format($questionWeighting,1); $my_total_weight = float_format($questionWeighting,1);
echo '<div id="question_score">'; echo '<div id="question_score">';
echo get_lang('Score')." : $my_total_score/$my_total_weight"; //echo get_lang('Score')." : $my_total_score/$my_total_weight";
echo get_lang('Score')." : ".show_score($my_total_score,$total_weighting,false);
echo '</div>'; echo '</div>';
unset($objAnswerTmp); unset($objAnswerTmp);
@ -588,18 +594,14 @@ if ($show_results) {
} //end of condition if $show_results } //end of condition if $show_results
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results) { if ($show_results) {
echo '<div id="question_score">'.get_lang('YourTotalScore').": ";
echo '<div id="question_score">'.get_lang('YourTotalScore')." ";
if ($dsp_percent) { if ($dsp_percent) {
$my_result = number_format(($totalScore/$totalWeighting)*100,1,'.',''); $my_result = number_format(($totalScore/$totalWeighting)*100,1,'.','');
$my_result = float_format($my_result,1); $my_result = float_format($my_result,1);
echo $my_result."%"; echo $my_result."%";
} else { } else {
echo show_score($my_total_score,$my_total_weight,false);
$my_total_score = float_format($totalScore,1);
$my_total_weight = float_format($totalWeighting,1);
echo $my_total_score."/".$my_total_weight;
} }
echo '</div>'; echo '</div>';
} }
@ -611,8 +613,7 @@ if (is_array($arrid) && is_array($arrmarks)) {
} }
if ($is_allowedToEdit) { if ($is_allowedToEdit) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo ' <form name="myform" id="myform" action="exercice.php?show=result&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">'; echo ' <form name="myform" id="myform" action="exercice.php?show=result&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
echo ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">'; echo ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">';
echo '<input type = "hidden" name="lp_item_id" value="'.$lp_id.'">'; echo '<input type = "hidden" name="lp_item_id" value="'.$lp_id.'">';

@ -240,20 +240,19 @@ class MultipleAnswerTrueFalse extends Question {
} }
} }
//Getting quiz_question_options (true, false, doubt) because it's possible that there are more options in the future
$new_options = Question::readQuestionOption($this->id); $new_options = Question::readQuestionOption($this->id);
$sorted_by_position = array(); $sorted_by_position = array();
foreach($new_options as $item) { foreach($new_options as $item) {
$sorted_by_position[$item['position']] = $item; $sorted_by_position[$item['position']] = $item;
} }
//Saving quiz_question.extra values //Saving quiz_question.extra values that has the correct scores of the true, false, doubt options registered in this format XX:YY:ZZZ where XX is a float score value
$extra_values = array(); $extra_values = array();
for ($i=1 ; $i <= 3 ; $i++) { for ($i=1 ; $i <= 3 ; $i++) {
$score = trim($form -> getSubmitValue('option['.$i.']')); $score = trim($form -> getSubmitValue('option['.$i.']'));
$extra_values[]= $score; $extra_values[]= $score;
} }
$this->setExtra(implode(':',$extra_values)); $this->setExtra(implode(':',$extra_values));
for ($i=1 ; $i <= $nb_answers ; $i++) { for ($i=1 ; $i <= $nb_answers ; $i++) {
@ -261,10 +260,10 @@ class MultipleAnswerTrueFalse extends Question {
$comment = trim($form -> getSubmitValue('comment['.$i.']')); $comment = trim($form -> getSubmitValue('comment['.$i.']'));
$goodAnswer = trim($form -> getSubmitValue('correct['.$i.']')); $goodAnswer = trim($form -> getSubmitValue('correct['.$i.']'));
if (empty($options)) { if (empty($options)) {
//new //If this is the first time that the question is created when change the default values from the form 1 and 2 by the correct "option id" registered
$goodAnswer = $sorted_by_position[$goodAnswer]['id']; $goodAnswer = $sorted_by_position[$goodAnswer]['id'];
} }
$questionWeighting += $correct[1]; $questionWeighting += $extra_values[0]; //By default 0 has the correct answers
$objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i); $objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i);
} }

@ -782,9 +782,9 @@ VALUES
('pdf_export_watermark_text', NULL,'textfield', 'Platform', '', 'PDFExportWatermarkTextTitle', 'PDFExportWatermarkTextComment', 'platform',NULL, 1), ('pdf_export_watermark_text', NULL,'textfield', 'Platform', '', 'PDFExportWatermarkTextTitle', 'PDFExportWatermarkTextComment', 'platform',NULL, 1),
('enabled_insertHtml', NULL,'radio', 'Editor', 'false','EnabledInsertHtmlTitle', 'EnabledInsertHtmlComment',NULL,NULL, 0), ('enabled_insertHtml', NULL,'radio', 'Editor', 'false','EnabledInsertHtmlTitle', 'EnabledInsertHtmlComment',NULL,NULL, 0),
('students_export2pdf', NULL,'radio', 'Tools', 'true', 'EnabledStudentExport2PDFTitle', 'EnabledStudentExport2PDFComment',NULL,NULL, 0), ('students_export2pdf', NULL,'radio', 'Tools', 'true', 'EnabledStudentExport2PDFTitle', 'EnabledStudentExport2PDFComment',NULL,NULL, 0),
('exercise_min_note', NULL,'textfield', 'Course', '', 'ExerciseMinNoteTitle', 'ExerciseMinNoteComment','platform',NULL, 1), ('exercise_min_score', NULL,'textfield', 'Course', '', 'ExerciseMinScoreTitle', 'ExerciseMinScoreComment','platform',NULL, 1),
('exercise_max_note', NULL,'textfield', 'Course', '', 'ExerciseMaxNoteTitle', 'ExerciseMaxNoteComment','platform',NULL, 1), ('exercise_max_score', NULL,'textfield', 'Course', '', 'ExerciseMaxScoreTitle', 'ExerciseMaxScoreComment','platform',NULL, 1),
('chamilo_database_version', NULL,'textfield', NULL, '1.8.8.13050','DokeosDatabaseVersion','', NULL, NULL, 0); ('chamilo_database_version', NULL,'textfield', NULL, '1.8.8.13174','DokeosDatabaseVersion','', NULL, NULL, 0);
UNLOCK TABLES; UNLOCK TABLES;

@ -94,8 +94,8 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value,
INSERT INTO settings_options (variable, value, display_text) VALUES ('students_export2pdf', 'true', 'Yes'); INSERT INTO settings_options (variable, value, display_text) VALUES ('students_export2pdf', 'true', 'Yes');
INSERT INTO settings_options (variable, value, display_text) VALUES ('students_export2pdf', 'false', 'No'); INSERT INTO settings_options (variable, value, display_text) VALUES ('students_export2pdf', 'false', 'No');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('exercise_min_note', NULL,'textfield', 'Course', '', 'ExerciseMinNoteTitle', 'ExerciseMinNoteComment','platform',NULL, 1); INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('exercise_min_score', NULL,'textfield', 'Course', '', 'ExerciseMinScoreTitle', 'ExerciseMinScoreComment','platform',NULL, 1);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('exercise_max_note', NULL,'textfield', 'Course', '', 'ExerciseMaxNoteTitle', 'ExerciseMaxNoteComment','platform',NULL, 1); INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('exercise_max_score', NULL,'textfield', 'Course', '', 'ExerciseMaxScoreTitle', 'ExerciseMaxScoreComment','platform',NULL, 1);
-- xxSTATSxx -- xxSTATSxx

Loading…
Cancel
Save