skala
Julio Montoya 14 years ago
commit 5aca47639d
  1. 8
      main/exercice/admin.php
  2. 151
      main/exercice/exercise.class.php
  3. 89
      main/exercice/exercise.lib.php
  4. 4
      main/exercice/exercise_show.php
  5. 13
      main/exercice/multiple_answer_combination.class.php
  6. 42
      main/exercice/multiple_answer_combination_true_false.class.php
  7. 11
      main/exercice/multiple_answer_true_false.class.php
  8. 3
      main/exercice/question.class.php
  9. 71
      main/inc/lib/display.lib.php
  10. 81
      main/inc/lib/exercise_show_functions.lib.php
  11. 4
      main/inc/lib/main_api.lib.php
  12. 10
      main/install/db_main.sql
  13. 3
      main/install/migrate-db-1.8.7-1.8.8-pre.sql
  14. 64
      main/session/index.php
  15. 3
      user_portal.php

@ -293,11 +293,15 @@ $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jqu
$htmlHeadXtra[] = '<script type="text/javascript"> $htmlHeadXtra[] = '<script type="text/javascript">
function multiple_answer_true_false_onchange(variable) { function multiple_answer_true_false_onchange(variable) {
var result = variable.value; var result = variable.checked;
var id = variable.id; var id = variable.id;
var weight_id = "weighting_" + id; var weight_id = "weighting_" + id;
var array_result=new Array(); array_result[1]="1"; array_result[0]= "-0.50"; array_result[-1]= "0"; var array_result=new Array(); array_result[1]="1"; array_result[0]= "-0.50"; array_result[-1]= "0";
if (result) {
result = 1;
} else {
result = 0;
}
document.getElementById(weight_id).value = array_result[result]; document.getElementById(weight_id).value = array_result[result];
} }

@ -1698,6 +1698,7 @@ class Exercise {
switch ($answerType) { switch ($answerType) {
// for unique answer // for unique answer
case UNIQUE_ANSWER : case UNIQUE_ANSWER :
case UNIQUE_ANSWER_NO_OPTION :
if ($from_database) { if ($from_database) {
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'"; $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$resultans = Database::query($queryans); $resultans = Database::query($queryans);
@ -1719,35 +1720,114 @@ class Exercise {
} }
break; break;
// for multiple answers // for multiple answers
case MULTIPLE_ANSWER_TRUE_FALSE : case MULTIPLE_ANSWER_TRUE_FALSE :
case MULTIPLE_ANSWER_ :
if ($from_database) { if ($from_database) {
$choice=array(); $choice=array();
$queryans = "SELECT * FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'"; $queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$resultans = Database::query($queryans);
while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer'];
$result = explode(':',$ind);
$my_answer_id = $result[0];
$option = $result[1];
$choice[$my_answer_id] = $option;
}
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice =$choice[$numAnswer];
} else {
$studentChoice =$choice[$numAnswer]; // 0, 1 or 2
//echo $studentChoice.' - '.$answerCorrect.'<br />';
}
if ($studentChoice == $answerCorrect ) {
if ($studentChoice == 1) {
$questionScore +=1;
$totalScore +=1;
}
} else {
if ($studentChoice == 0 || $studentChoice == 1) {
$questionScore +=-0.5;
$totalScore +=-0.5;
}
}
break;
case MULTIPLE_ANSWER :
if ($from_database) {
$choice=array();
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$resultans = Database::query($queryans); $resultans = Database::query($queryans);
while ($row = Database::fetch_array($resultans)) { while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer']; $ind = $row['answer'];
$choice[$ind] = 1; $choice[$ind] = 1;
} }
$numAnswer=$objAnswerTmp->selectAutoId($answerId); $numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice=$choice[$numAnswer]; $studentChoice=$choice[$numAnswer];
if ($studentChoice) { if ($studentChoice) {
$questionScore+=$answerWeighting; $questionScore +=$answerWeighting;
$totalScore+=$answerWeighting; $totalScore +=$answerWeighting;
} }
} else { } else {
$studentChoice=$choice[$numAnswer]; $studentChoice=$choice[$numAnswer];
if ($studentChoice) { if ($studentChoice) {
$questionScore+=$answerWeighting; $questionScore +=$answerWeighting;
$totalScore+=$answerWeighting; $totalScore +=$answerWeighting;
} }
} }
break; break;
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
if ($from_database) {
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$resultans = Database::query($queryans);
while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer'];
$result = explode(':',$ind);
$my_answer_id = $result[0];
$option = $result[1];
$choice[$my_answer_id] = $option;
}
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice=$choice[$numAnswer];
if ($answerCorrect == 1) {
if ($studentChoice) {
$real_answers[$answerId] = true;
} else {
$real_answers[$answerId] = false;
}
} else {
if ($studentChoice) {
$real_answers[$answerId] = false;
} else {
$real_answers[$answerId] = true;
}
}
} else {
$studentChoice=$choice[$numAnswer];
if ($answerCorrect == 1) {
if ($studentChoice) {
$real_answers[$answerId] = true;
} else {
$real_answers[$answerId] = false;
}
} else {
if ($studentChoice) {
$real_answers[$answerId] = false;
} else {
$real_answers[$answerId] = true;
}
}
$final_answer = true;
foreach($real_answers as $my_answer) {
if (!$my_answer) {
$final_answer = false;
}
}
}
break;
case MULTIPLE_ANSWER_COMBINATION: case MULTIPLE_ANSWER_COMBINATION:
if ($from_database) { if ($from_database) {
$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$queryans = "SELECT * FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
$resultans = Database::query($queryans); $resultans = Database::query($queryans);
while ($row = Database::fetch_array($resultans)) { while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer']; $ind = $row['answer'];
@ -2046,8 +2126,7 @@ class Exercise {
} }
// for hotspot with no order // for hotspot with no order
case HOT_SPOT : case HOT_SPOT :
if ($from_database) { if ($from_database) {
if ($show_result) { if ($show_result) {
$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); $TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
@ -2083,10 +2162,14 @@ class Exercise {
if ($from == 'exercise_result') { if ($from == 'exercise_result') {
//display answers (if not matching type, or if the answer is correct) //display answers (if not matching type, or if the answer is correct)
if ($answerType != MATCHING || $answerCorrect) { if ($answerType != MATCHING || $answerCorrect) {
if (in_array($answerType, array(UNIQUE_ANSWER, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, MULTIPLE_ANSWER_TRUE_FALSE))) { if (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION))) {
if ($origin!='learnpath') { if ($origin!='learnpath') {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,0,0); ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,0,0);
} }
} elseif($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($origin!='learnpath') {
ExerciseShowFunctions::display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,0,0,0);
}
} elseif($answerType == FILL_IN_BLANKS) { } elseif($answerType == FILL_IN_BLANKS) {
if ($origin!='learnpath') { if ($origin!='learnpath') {
ExerciseShowFunctions::display_fill_in_blanks_answer($answer,0,0); ExerciseShowFunctions::display_fill_in_blanks_answer($answer,0,0);
@ -2114,16 +2197,24 @@ class Exercise {
} }
} else { } else {
switch($answerType) { switch($answerType) {
case UNIQUE_ANSWER : case UNIQUE_ANSWER :
case MULTIPLE_ANSWER : case UNIQUE_ANSWER_NO_OPTION:
case MULTIPLE_ANSWER_TRUE_FALSE : case MULTIPLE_ANSWER :
case MULTIPLE_ANSWER_COMBINATION : case MULTIPLE_ANSWER_COMBINATION :
if ($answerId==1) { if ($answerId==1) {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,$answerId); ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,$answerId);
} else { } else {
ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,""); ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,"");
} }
break; break;
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
case MULTIPLE_ANSWER_TRUE_FALSE :
if ($answerId==1) {
ExerciseShowFunctions::display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,$answerId);
} else {
ExerciseShowFunctions::display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$exeId,$questionId,"");
}
break;
case FILL_IN_BLANKS: case FILL_IN_BLANKS:
echo '<tr><td>'; echo '<tr><td>';
ExerciseShowFunctions::display_fill_in_blanks_answer($answer,$exeId,$questionId); ExerciseShowFunctions::display_fill_in_blanks_answer($answer,$exeId,$questionId);
@ -2169,12 +2260,12 @@ class Exercise {
} }
//we add the total score after dealing with the answers //we add the total score after dealing with the answers
if ($answerType == MULTIPLE_ANSWER_COMBINATION) { if ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($final_answer) { if ($final_answer) {
//getting only the first score where we save the weight of all the question //getting only the first score where we save the weight of all the question
$answerWeighting=$objAnswerTmp->selectWeighting(1); $answerWeighting = $objAnswerTmp->selectWeighting(1);
$questionScore+=$answerWeighting; $questionScore += $answerWeighting;
$totalScore+=$answerWeighting; $totalScore += $answerWeighting;
} }
} }
@ -2229,7 +2320,17 @@ class Exercise {
if (empty ($choice)) { if (empty ($choice)) {
$choice = 0; $choice = 0;
} }
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($choice != 0) {
$reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i];
exercise_attempt($questionScore, $ans.':'.$choice[$ans], $quesId, $exeId, $i, $this->id);
}
} else {
exercise_attempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
}
} elseif ($answerType == MULTIPLE_ANSWER) {
if ($choice != 0) { if ($choice != 0) {
$reply = array_keys($choice); $reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) { for ($i = 0; $i < sizeof($reply); $i++) {

@ -84,6 +84,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
if ($answerType == FREE_ANSWER && $freeze) { if ($answerType == FREE_ANSWER && $freeze) {
return ''; return '';
} }
$s .= '<table width="720" class="exercise_options" style="width: 720px;'.$option_ie.' background-color:#fff;">'; $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) // construction of the Answer object (also gets all answers details)
$objAnswerTmp=new Answer($questionId); $objAnswerTmp=new Answer($questionId);
@ -220,6 +221,15 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
// answers for the question as a limiter // answers for the question as a limiter
$lines_count=1; // a counter for matching-type answers $lines_count=1; // a counter for matching-type answers
$question_list = array(); $question_list = array();
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$header .= Display::tag('th', get_lang('Options'));
foreach ($objQuestionTmp->options as $key=>$item) {
$header .= Display::tag('th', $item);
}
$s.=Display::tag('tr',$header);
}
for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId); $answer = $objAnswerTmp->selectAnswer($answerId);
$answerCorrect = $objAnswerTmp->isCorrect($answerId); $answerCorrect = $objAnswerTmp->isCorrect($answerId);
@ -248,6 +258,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
} }
$answer = text_filter($answer); $answer = text_filter($answer);
$answer = Security::remove_XSS($answer, STUDENT); $answer = Security::remove_XSS($answer, STUDENT);
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'. $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
'<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;">'. '<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;">'.
'<span><input class="checkbox" type="radio" name="choice['.$questionId.']" value="'.$numAnswer.'" '.$selected.' /></span></p>'. '<span><input class="checkbox" type="radio" name="choice['.$questionId.']" value="'.$numAnswer.'" '.$selected.' /></span></p>'.
@ -266,16 +277,35 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$help = 'x-'; $help = 'x-';
$selected = 'checked="checked"'; $selected = 'checked="checked"';
} }
} }
$answer = text_filter($answer); $answer = text_filter($answer);
$answer = Security::remove_XSS($answer, STUDENT); $answer = Security::remove_XSS($answer, STUDENT);
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
'<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;">'. if ($answerType == MULTIPLE_ANSWER) {
'<span><input class="checkbox" type="checkbox" name="choice['.$questionId.']['.$numAnswer.']" value="1" '.$selected.' /></span></p>'. $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
'<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'. $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;">';
$answer.
'</div></div></td></tr>'; $options = array('type'=>'checkbox','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
if ($answerCorrect) {
$options['checked'] = 'checked';
}
$s .= Display::tag('span', Display::tag('input','',$options ));
$s .= '</p>';
$s .= '<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'.
$answer.
'</div></div></td></tr>';
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
$s .='<tr>';
$s .= Display::tag('td', $answer);
foreach ($objQuestionTmp->options as $key=>$item) {
$options['value'] = $key;
$s .= Display::tag('td', Display::tag('input','',$options ));
}
$s.='<tr>';
}
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
// multiple answers // multiple answers
// set $debug_mark_answer to true at function start to // set $debug_mark_answer to true at function start to
@ -295,7 +325,28 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
'<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'. '<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'.
$answer. $answer.
'</div></div></td></tr>'; '</div></div></td></tr>';
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
// multiple answers
// set $debug_mark_answer to true at function start to
// show the correct answer with a suffix '-x'
$help = $selected = '';
if ($debug_mark_answer) {
if ($answerCorrect) {
$help = 'x-';
$selected = 'checked="checked"';
}
}
$answer = text_filter($answer);
$answer = Security::remove_XSS($answer, STUDENT);
$options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
$s .='<tr>';
$s .= Display::tag('td', $answer);
foreach ($objQuestionTmp->options as $key=>$item) {
$options['value'] = $key;
$s .= Display::tag('td', Display::tag('input','',$options ));
}
$s.='<tr>';
} elseif ($answerType == FILL_IN_BLANKS) { } elseif ($answerType == FILL_IN_BLANKS) {
// fill in blanks // fill in blanks
$s .= '<tr><td colspan="3">'.$answer.'</td></tr>'; $s .= '<tr><td colspan="3">'.$answer.'</td></tr>';
@ -957,7 +1008,9 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
$my_res = float_format($results[$i]['exresult'],1); $my_res = float_format($results[$i]['exresult'],1);
$my_total = float_format($results[$i]['exweight'],1); $my_total = float_format($results[$i]['exweight'],1);
$result_list = round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ')'; $ex = show_score($my_res, $my_total);
$result_list = round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ') --> '.$ex;
$html_link = ''; $html_link = '';
if ($is_allowedToEdit || $is_tutor) { if ($is_allowedToEdit || $is_tutor) {
@ -1014,3 +1067,19 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
} }
return $list_info; return $list_info;
} }
function show_score($score, $weight, $show_porcentage = true) {
$html = '';
$score_rounded = $score;
if ($score != '' && $weight != '') {
$max_note = api_get_setting('exercise_max_note');
$min_note = api_get_setting('exercise_min_note');
if ($max_note != '' && $min_note != '') {
$score = $min_note + ($max_note - $min_note) * $score /$weight;
$score_rounded = round($score, 2);
$weight = $max_note;
}
$html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')';
}
return $html;
}

@ -372,7 +372,7 @@ if ($show_results) {
$questionScore = $question_result['score']; $questionScore = $question_result['score'];
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
echo '</table>'; echo '</table>';
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice=array(); $choice=array();
?> ?>
<table width="100%" border="0" cellspacing="3" cellpadding="3"> <table width="100%" border="0" cellspacing="3" cellpadding="3">
@ -395,7 +395,7 @@ if ($show_results) {
$totalScore += $question_result['score']; $totalScore += $question_result['score'];
echo '</table>'; echo '</table>';
} elseif ($answerType == UNIQUE_ANSWER) { } elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
?> ?>
<table width="100%" border="0" cellspacing="3" cellpadding="3"> <table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr> <tr>

@ -116,10 +116,7 @@ class MultipleAnswerCombination extends Question {
$answer_number=$form->addElement('text', null,null,'value="'.$i.'"'); $answer_number=$form->addElement('text', null,null,'value="'.$i.'"');
$answer_number->freeze(); $answer_number->freeze();
//$form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"'); $form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"');
$options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
$form->addElement('select', 'correct['.$i.']',null, $options);
$boxes_names[] = 'correct['.$i.']'; $boxes_names[] = 'correct['.$i.']';
$form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')); $form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
@ -154,11 +151,15 @@ class MultipleAnswerCombination extends Question {
$form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"'); $form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"'); $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"');
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="minus"'); $form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="minus"');
} else { } else {
$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"'); $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'style="float:right"; class="minus"'); $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'style="float:right"; class="minus"');
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'style="float:right"; class="plus"'); $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'style="float:right"; class="plus"');
// setting the save button here and not in the question class.php
// setting the save button here and not in the question class.php
} }
} }
$renderer->setElementTemplate('{element}&nbsp;','lessAnswers'); $renderer->setElementTemplate('{element}&nbsp;','lessAnswers');

@ -0,0 +1,42 @@
<?php // $Id: document.php 16494 2008-10-10 22:07:36Z yannoo $
/* For licensing terms, see /chamilo_license.txt */
/**
* File containing the MultipleAnswer class.
* @package dokeos.exercise
* @author Eric Marguin
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
if(!class_exists('MultipleAnswerCombinationTrueFalse')):
/**
CLASS MultipleAnswer
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @package dokeos.exercise
**/
require 'multiple_answer_combination.class.php';
class MultipleAnswerCombinationTrueFalse extends MultipleAnswerCombination {
static $typePicture = 'mcmac.gif';
static $explanationLangVar = 'MultipleAnswerCombinationTrueFalse';
var $options;
/**
* Constructor
*/
function MultipleAnswerCombinationTrueFalse(){
parent::question();
$this -> type = MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE;
$this -> isContent = $this-> getIsContent();
$this->options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
}
}
endif;
?>

@ -23,7 +23,7 @@ class MultipleAnswerTrueFalse extends Question {
static $typePicture = 'mcma.gif'; static $typePicture = 'mcma.gif';
static $explanationLangVar = 'MultipleAnswerTrueFalseSelect'; static $explanationLangVar = 'MultipleAnswerTrueFalseSelect';
var $options;
/** /**
* Constructor * Constructor
*/ */
@ -31,6 +31,7 @@ class MultipleAnswerTrueFalse extends Question {
parent::question(); parent::question();
$this -> type = MULTIPLE_ANSWER_TRUE_FALSE; $this -> type = MULTIPLE_ANSWER_TRUE_FALSE;
$this -> isContent = $this-> getIsContent(); $this -> isContent = $this-> getIsContent();
$this->options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
} }
/** /**
@ -112,11 +113,11 @@ class MultipleAnswerTrueFalse extends Question {
$answer_number=$form->addElement('text', null,null,'value="'.$i.'"'); $answer_number=$form->addElement('text', null,null,'value="'.$i.'"');
$answer_number->freeze(); $answer_number->freeze();
//$form->addElement('checkbox', 'correct['.$i.']', null, null, 'class="checkbox" style="margin-left: 0em;"'); $form->addElement('checkbox', 'correct['.$i.']', null, null, 'id="'.$i.'" class="checkbox" style="margin-left: 0em;" onchange="multiple_answer_true_false_onchange(this);" ' );
$options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('Nothing'));
$form->addElement('select', 'correct['.$i.']',null, $options, array('id'=>$i,'onchange'=>'multiple_answer_true_false_onchange(this)')); //$form->addElement('select', 'correct['.$i.']',null, $this->options, array('id'=>$i,'onchange'=>'multiple_answer_true_false_onchange(this)'));
//$boxes_names[] = 'correct['.$i.']'; $boxes_names[] = 'correct['.$i.']';
$form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')); $form->addElement('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"', array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');

@ -23,6 +23,8 @@ define('HOT_SPOT_DELINEATION', 8);
define('MULTIPLE_ANSWER_COMBINATION', 9); define('MULTIPLE_ANSWER_COMBINATION', 9);
define('UNIQUE_ANSWER_NO_OPTION', 10); define('UNIQUE_ANSWER_NO_OPTION', 10);
define('MULTIPLE_ANSWER_TRUE_FALSE', 11); define('MULTIPLE_ANSWER_TRUE_FALSE', 11);
define('MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE', 12);
/** /**
QUESTION CLASS QUESTION CLASS
@ -57,6 +59,7 @@ abstract class Question
MULTIPLE_ANSWER_COMBINATION => array('multiple_answer_combination.class.php' , 'MultipleAnswerCombination'), MULTIPLE_ANSWER_COMBINATION => array('multiple_answer_combination.class.php' , 'MultipleAnswerCombination'),
UNIQUE_ANSWER_NO_OPTION => array('unique_answer_no_option.class.php' , 'UniqueAnswerNoOption'), UNIQUE_ANSWER_NO_OPTION => array('unique_answer_no_option.class.php' , 'UniqueAnswerNoOption'),
MULTIPLE_ANSWER_TRUE_FALSE => array('multiple_answer_true_false.class.php' , 'MultipleAnswerTrueFalse'), MULTIPLE_ANSWER_TRUE_FALSE => array('multiple_answer_true_false.class.php' , 'MultipleAnswerTrueFalse'),
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE => array('multiple_answer_combination_true_false.class.php' , 'MultipleAnswerCombinationTrueFalse'),
); );

@ -700,8 +700,77 @@ class Display {
} else { } else {
$return_value = '<'.$tag.' '.$attribute_list.' > '.$content.'</'.$tag.'>'; $return_value = '<'.$tag.' '.$attribute_list.' > '.$content.'</'.$tag.'>';
} }
return $return_value; return $return_value;
}
public function select($name, $values, $default = -1, $parameter_list = array(), $show_blank_item = true) {
$extra = '';
foreach($parameter_list as $key=>$parameter) {
$extra .= $key.'="'.$parameter.'"';
}
$html .= '<select name="'.$name.'" id="'.$name.'" '.$extra.'>';
if ($show_blank_item) {
$html .= self::tag('option', '-- '.get_lang('Select').' --', array('value'=>'-1'));
}
if($values) {
foreach($values as $key => $value) {
if(is_array($value) && isset($value['name'])) {
$value = $value['name'];
}
$html .= '<option value="'.$key.'"';
if($default == $key) {
$html .= 'selected="selected"';
}
$html .= '>'.$value.'</option>';
}
}
$html .= '</select>';
return $html;
}
/**
* Creates a tab list
* Requirements: declare the jquery, jquery-ui libraries + the jquery-ui.css in the $htmlHeadXtra variable before the display_header
* Add this script
*
* <script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
* @param array list of the tab titles
* @param array content that will be showed
* @param string the id of the container of the tab
* @param array attributes for the ul
*
*/
public static function tabs($header_list, $content_list, $id = 'tabs', $ul_attributes = array()) {
if (empty($header_list) || count($header_list) == 0 ) {
return '';
}
$lis = '';
$i = 1;
foreach ($header_list as $item) {
$item =self::tag('a', $item, array('href'=>'#'.$id.'-'.$i));
$lis .=self::tag('li', $item, $ul_attributes);
$i++;
}
$ul = self::tag('ul',$lis);
$i = 1;
$divs = '';
foreach ($content_list as $content) {
$content = self::tag('p',$content);
$divs .=self::tag('div', $content, array('id'=>$id.'-'.$i));
$i++;
}
$main_div = self::tag('div',$ul.$divs, array('id'=>$id));
return $main_div ;
} }
} //end class Display } //end class Display

@ -165,7 +165,7 @@ class ExerciseShowFunctions {
* @param boolean Whether to show the answer comment or not * @param boolean Whether to show the answer comment or not
* @return void * @return void
*/ */
function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) { function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
global $feedback_type; global $feedback_type;
?> ?>
<tr> <tr>
@ -209,5 +209,82 @@ class ExerciseShowFunctions {
<?php } ?> <?php } ?>
</tr> </tr>
<?php <?php
} }
/**
* Display the answers to a multiple choice question
*
* @param integer Answer type
* @param integer Student choice
* @param string Textual answer
* @param string Comment on answer
* @param string Correct answer comment
* @param integer Exercise ID
* @param integer Question ID
* @param boolean Whether to show the answer comment or not
* @return void
*/
function display_multiple_answer_true_false($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans) {
global $feedback_type;
?>
<tr>
<td width="5%" align="center">
<?php
//var_dump($studentChoice);
if ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
$question = new MultipleAnswerCombinationTrueFalse();
} else {
$question = new MultipleAnswerTrueFalse();
}
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
echo $question->options[2];
}
?>
</td>
<td width="5%" align="center">
<?php
if (isset($question->options[$answerCorrect])) {
echo $question->options[$answerCorrect];
} else {
echo $question->options[2];
}
?>
</td>
<td width="40%" style="border-bottom: 1px solid #4171B5;">
<?php
$answer=text_filter($answer);
echo $answer;
?>
</td>
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
$answerComment=text_filter($answerComment);
if($studentChoice) {
if(!$answerCorrect) {
echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
}
} else {
echo '&nbsp;';
}
?>
</td>
<?php
if ($ans==1) {
$comm = get_comments($id,$questionId);
}
?>
<?php } else { ?>
<td>&nbsp;</td>
<?php } ?>
</tr>
<?php
}
} }

@ -1725,7 +1725,9 @@ function api_get_coachs_from_course($session_id=0,$course_code='') {
*/ */
function api_get_setting($variable, $key = null) { function api_get_setting($variable, $key = null) {
global $_setting; global $_setting;
return is_null($key) ? (!empty($_setting[$variable]) ? $_setting[$variable] : null) : $_setting[$variable][$key]; //return is_null($key) ? (!empty($_setting[$variable]) ? $_setting[$variable] : null) : $_setting[$variable][$key]; does not allow "0" values
//Allowing "0" values
return is_null($key) ? (($_setting[$variable] != '') ? $_setting[$variable] : null) : $_setting[$variable][$key];
} }
/** /**

@ -780,10 +780,12 @@ VALUES
('pdf_export_watermark_enable', NULL,'radio', 'Platform', 'false','PDFExportWatermarkEnableTitle', 'PDFExportWatermarkEnableComment', 'platform',NULL, 1), ('pdf_export_watermark_enable', NULL,'radio', 'Platform', 'false','PDFExportWatermarkEnableTitle', 'PDFExportWatermarkEnableComment', 'platform',NULL, 1),
('pdf_export_watermark_by_course', NULL,'radio', 'Platform', 'false','PDFExportWatermarkByCourseTitle', 'PDFExportWatermarkByCourseComment','platform',NULL, 1), ('pdf_export_watermark_by_course', NULL,'radio', 'Platform', 'false','PDFExportWatermarkByCourseTitle', 'PDFExportWatermarkByCourseComment','platform',NULL, 1),
('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),
('chamilo_database_version', NULL, 'textfield', NULL, '1.8.8.13050', 'DokeosDatabaseVersion', '', NULL, NULL, 0); ('exercise_min_note', NULL,'textfield', 'Course', '', 'ExerciseMinNoteTitle', 'ExerciseMinNoteComment','platform',NULL, 1),
('exercise_max_note', NULL,'textfield', 'Course', '', 'ExerciseMaxNoteTitle', 'ExerciseMaxNoteComment','platform',NULL, 1),
('chamilo_database_version', NULL,'textfield', NULL, '1.8.8.13050','DokeosDatabaseVersion','', NULL, NULL, 0);
UNLOCK TABLES; UNLOCK TABLES;
/*!40000 ALTER TABLE settings_current ENABLE KEYS */; /*!40000 ALTER TABLE settings_current ENABLE KEYS */;

@ -94,6 +94,9 @@ 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_max_note', NULL,'textfield', 'Course', '', 'ExerciseMaxNoteTitle', 'ExerciseMaxNoteComment','platform',NULL, 1);
-- xxSTATSxx -- xxSTATSxx
ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0; ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;

@ -0,0 +1,64 @@
<?php
// Language files that should be included.
$language_file = array('courses', 'index');
require_once '../inc/global.inc.php';
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath.'course.lib.php';
//require_once $libpath.'usermanager.lib.php';
require_once $libpath.'sessionmanager.lib.php';
require_once $libpath.'formvalidator/FormValidator.class.php';
api_block_anonymous_users(); // Only users who are logged in can proceed.
$this_section = SECTION_COURSES;
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/cupertino/jquery-ui-1.8.7.custom.css" type="text/css">';
$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/cupertino/jquery-ui-1.8.7.custom.min.js" type="text/javascript" language="javascript"></script>'; //jQuery
Display :: display_header($nameTools);
$session_id = intval($_GET['id_session']);
$session_info = SessionManager::fetch($session_id);
$course_list = SessionManager::get_course_list_by_session_id($session_id);
$course_select = array();
echo Display::tag('h1', $session_info['name']);
foreach ($course_list as $course_item) {
$course_select[$course_item['id']] = $course_item['title'];
}
$form = new FormValidator('exercise_admin', 'post', api_get_self());
$form->addElement('select', 'course_id', get_lang('CourseList'),$course_select,'onchange="javascript:feedbackselection()"');
$form->display();
if ($form->validate()) {
}
?>
<br />
<script>
$(function() {
$( "#tabs" ).tabs();
$( "#sub_tab" ).tabs();
});
</script>
<?php
$headers = array(get_lang('MyCourses'), get_lang('MyQCM'), get_lang('MyResults'));
$sub_header = array(get_lang('AllCourses'), get_lang('PerWeek'), get_lang('ParMatiere'));
$tabs = Display::tabs($sub_header, array('aaaa','bbb','ccc'),'sub_tab');
echo Display::tabs($headers, array($tabs,'bbb','ccc'));
exit;
// Footer
Display :: display_footer();

@ -1348,7 +1348,8 @@ if (is_array($courses_tree)) {
$extra_info = (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates']; $extra_info = (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates'];
//var_dump($s); //var_dump($s);
//echo get_lang('SessionName') . ': ' . $s['title']. ' - '.(!empty($s['coach']) ? $s['coach'].' - ' : '').$s['dates']; //echo get_lang('SessionName') . ': ' . $s['title']. ' - '.(!empty($s['coach']) ? $s['coach'].' - ' : '').$s['dates'];
echo '<span>' . $s['title']. ' </span> <span style="padding-left: 10px; font-size: 90%; font-weight: normal;">'.$extra_info.'</span>'; $session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?id_session='.$session['details']['id']));
echo '<span>' . $session_link. ' </span> <span style="padding-left: 10px; font-size: 90%; font-weight: normal;">'.$extra_info.'</span>';
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
echo '<div style="float:right;"><a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session['details']['id'].'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('align' => 'absmiddle')).'</a></div>'; echo '<div style="float:right;"><a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session['details']['id'].'">'.Display::return_icon('edit.gif', get_lang('Edit'), array('align' => 'absmiddle')).'</a></div>';
} }

Loading…
Cancel
Save