Merge with 72739e096086938ec68b085e1ffb48f00d09af27

skala
Ivan Tcholakov 15 years ago
commit e003ab11fe
  1. 24
      main/coursecopy/classes/CourseBuilder.class.php
  2. 43
      main/coursecopy/classes/CourseRestorer.class.php
  3. 18
      main/coursecopy/classes/QuizQuestion.class.php
  4. 5
      main/exercice/admin.php
  5. 39
      main/exercice/answer.class.php
  6. 3
      main/exercice/exercice.php
  7. 14
      main/exercice/exercise.class.php
  8. 32
      main/exercice/exercise.lib.php
  9. 31
      main/exercice/exercise_show.php
  10. 13
      main/exercice/multiple_answer_true_false.class.php
  11. 1
      main/exercice/question_admin.inc.php
  12. 63
      main/exercice/question_list_admin.inc.php
  13. 132
      main/exercice/unique_answer_no_option.class.php
  14. 9
      main/inc/lib/add_course.lib.inc.php
  15. 10
      main/inc/lib/database.lib.php
  16. 21
      main/inc/lib/display.lib.php
  17. 6
      main/install/db_main.sql
  18. 5
      main/install/migrate-db-1.8.7-1.8.8-pre.sql

@ -372,13 +372,11 @@ class CourseBuilder {
// Building normal tests.
$sql = 'SELECT * FROM '.$table_que;
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result))
{
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level);
while ($obj = Database::fetch_object($db_result)) {
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level, $obj->extra);
$sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.$obj->id;
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
while ($obj2 = Database::fetch_object($db_result2)) {
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
}
$this->course->add_resource($question);
@ -390,23 +388,19 @@ class CourseBuilder {
' as questions LEFT JOIN '.$table_rel.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$table_qui.
' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1'; // active = -1 means "deleted" test.
$db_result = Database::query($sql);
if (Database::num_rows($db_result) > 0)
{
if (Database::num_rows($db_result) > 0) {
$build_orphan_questions = true;
while ($obj = Database::fetch_object($db_result))
{
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level);
while ($obj = Database::fetch_object($db_result)) {
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level, $obj->extra);
$sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.(int)$obj->id;
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))
{
while ($obj2 = Database::fetch_object($db_result2)) {
$question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
}
$this->course->add_resource($question);
}
}
if ($build_orphan_questions)
{
if ($build_orphan_questions) {
//$this->course->add_resource(new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0));
}
}
@ -430,7 +424,7 @@ class CourseBuilder {
$this->course->add_resource($orphan_questions);
while ($obj = Database::fetch_object($db_result))
{
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level);
$question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture,$obj->level,$obj->extra);
$sql = 'SELECT * FROM '.$table_ans.' WHERE question_id = '.$obj->id;
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2))

@ -14,6 +14,7 @@ require_once 'CourseDescription.class.php';
require_once 'CourseCopyLearnpath.class.php';
require_once 'Survey.class.php';
require_once 'SurveyQuestion.class.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/question.class.php';
//require_once 'mkdirr.php';
//require_once 'rmdirr.php';
require_once 'Glossary.class.php';
@ -857,11 +858,9 @@ class CourseRestorer
$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION, $this->course->destination_db);
$table_doc = Database :: get_course_table(TABLE_DOCUMENT, $this->course->destination_db);
$resources = $this->course->resources;
foreach ($resources[RESOURCE_QUIZ] as $id => $quiz)
{
foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
$doc = '';
if (strlen($quiz->media) > 0)
{
if (strlen($quiz->media) > 0) {
if ($this->course->resources[RESOURCE_DOCUMENT][$quiz->media]->is_restored())
{
$sql = "SELECT path FROM ".$table_doc." WHERE id = ".$resources[RESOURCE_DOCUMENT][$quiz->media]->destination_id;
@ -870,8 +869,7 @@ class CourseRestorer
$doc = str_replace('/audio/', '', $doc->path);
}
}
if ($id != -1)
{
if ($id != -1) {
$condition_session = "";
if (!empty($session_id)) {
@ -910,11 +908,12 @@ class CourseRestorer
$qid = $this->restore_quiz_question($question_id);
$question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : 1;
$sql = "INSERT IGNORE INTO ".$table_rel." SET question_id = ".$qid.", exercice_id = ".$new_id.", question_order = ".$question_order;
Database::query($sql);
Database::query($sql);
}
}
}
}
/**
* Restore quiz-questions
*/
@ -925,24 +924,24 @@ class CourseRestorer
$new_id=0;
if(is_object($question))
{
if(is_object($question)) {
if ($question->is_restored())
{
return $question->destination_id;
}
$table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION, $this->course->destination_db);
$table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER, $this->course->destination_db);
$table_options = Database :: get_course_table(TABLE_QUIZ_QUESTION_OPTION, $this->course->destination_db);
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($question->description, $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table_que." SET question = '".addslashes($question->question)."', description = '".addslashes($question->description)."', ponderation = '".addslashes($question->ponderation)."', position = '".addslashes($question->position)."', type='".addslashes($question->quiz_type)."', picture='".addslashes($question->picture)."', level='".addslashes($question->level)."'";
$sql = "INSERT INTO ".$table_que." SET question = '".addslashes($question->question)."', description = '".addslashes($question->description)."', ponderation = '".addslashes($question->ponderation)."', position = '".addslashes($question->position)."', type='".addslashes($question->quiz_type)."', picture='".addslashes($question->picture)."', level='".addslashes($question->level)."', extra='".addslashes($question->extra)."'";
Database::query($sql);
$new_id = Database::insert_id();
if ($question->quiz_type == 4) { // for answer type matching
if ($question->quiz_type == MATCHING) { // for answer type matching
foreach ($question->answers as $index => $answer) {
$sql = "INSERT INTO ".$table_ans." SET id= '".$answer['id']."',question_id = '".$new_id."', answer = '".Database::escape_string($answer['answer'])."', correct = '".$answer['correct']."', comment = '".Database::escape_string($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'";
Database::query($sql);
@ -951,13 +950,31 @@ class CourseRestorer
foreach ($question->answers as $index => $answer) {
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($answer['answer'], $this->course->code, $this->course->destination_path);
$answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($answer['answer'], $this->course->code, $this->course->destination_path);
$answer['comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($answer['comment'], $this->course->code, $this->course->destination_path);
$sql = "INSERT INTO ".$table_ans." SET id= '". ($index +1)."',question_id = '".$new_id."', answer = '".Database::escape_string($answer['answer'])."', correct = '".$answer['correct']."', comment = '".Database::escape_string($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'";
Database::query($sql);
}
}
}
//Moving quiz_question_options
if ($question->quiz_type == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_option_list = Question::readQuestionOption($id);
$old_option_ids = array();
foreach ($question_option_list as $item) {
$old_id = $item['id'];
unset($item['id']);
$item['question_id'] = $new_id;
$question_option_id = Database::insert($table_options, $item);
$old_option_ids[$old_id] = $question_option_id;
}
$new_answers = Database::find($table_ans,'id, correct', array('question_id = ?'=>$new_id));
foreach ($new_answers as $answer_item) {
$params['correct'] = $old_option_ids[$answer_item['correct']];
$question_option_id = Database::update_query($table_ans, $params, array('id = ?'=>$answer_item['id']));
}
}
$this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id;
}
return $new_id;

@ -6,7 +6,7 @@ require_once 'Resource.class.php';
/**
* An QuizQuestion
* @author Bart Mollet <bart.mollet@hogent.be>
* @package dokeos.backup
* @package chamilo.backup
*/
class QuizQuestion extends Resource
{
@ -42,6 +42,8 @@ class QuizQuestion extends Resource
* Picture
*/
var $picture;
var $extra;
/**
* Create a new QuizQuestion
* @param string $question
@ -50,8 +52,7 @@ class QuizQuestion extends Resource
* @param int $type
* @param int $position
*/
function QuizQuestion($id,$question,$description,$ponderation,$type,$position,$picture,$level)
{
function QuizQuestion($id,$question,$description,$ponderation,$type,$position,$picture,$level, $extra) {
parent::Resource($id,RESOURCE_QUIZQUESTION);
$this->question = $question;
$this->description = $description;
@ -61,12 +62,13 @@ class QuizQuestion extends Resource
$this->picture = $picture;
$this->level = $level;
$this->answers = array();
$this->extra = $extra;
}
/**
* Add an answer to this QuizQuestion
*/
function add_answer($answer_id, $answer_text,$correct,$comment,$ponderation,$position,$hotspot_coordinates,$hotspot_type)
{
function add_answer($answer_id, $answer_text,$correct,$comment,$ponderation,$position,$hotspot_coordinates,$hotspot_type) {
$answer = array();
$answer['id'] = $answer_id;
$answer['answer'] = $answer_text;
@ -78,12 +80,12 @@ class QuizQuestion extends Resource
$answer['hotspot_type'] = $hotspot_type;
$this->answers[] = $answer;
}
/**
* Show this question
*/
function show()
{
function show() {
parent::show();
echo $this->question;
}
}
}

@ -488,7 +488,7 @@ if(!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspota
Display::display_confirmation_message(get_lang('ExerciseEdited'));
}
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 ();
echo '<br />';
@ -500,5 +500,4 @@ api_session_register('objExercise');
api_session_register('objQuestion');
api_session_register('objAnswer');
Display::display_footer();
?>
Display::display_footer();

@ -45,10 +45,9 @@ class Answer
* @author Olivier Brouckaert
* @param integer Question ID that answers belong to
*/
function Answer($questionId)
{
function Answer($questionId) {
//$this->questionType=$questionType;
$this->questionId = (int)$questionId;
$this->questionId = intval($questionId);
$this->answer = array();
$this->correct = array();
$this->comment = array();
@ -75,8 +74,7 @@ class Answer
*
* @author - Olivier Brouckaert
*/
function cancel()
{
function cancel() {
$this->new_answer = array();
$this->new_correct = array();
$this->new_comment = array();
@ -93,8 +91,7 @@ class Answer
*
* @author - Olivier Brouckaert
*/
function read()
{
function read() {
global $_course;
$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
@ -102,7 +99,7 @@ class Answer
//$answerType=$this->selectType();
$sql="SELECT id,answer,correct,comment,ponderation, position, hotspot_coordinates, hotspot_type, destination, id_auto FROM
$TBL_ANSWER WHERE question_id ='".Database::escape_string($questionId)."' ORDER BY position";
$TBL_ANSWER WHERE question_id ='".$questionId."' ORDER BY position";
$result=Database::query($sql);
@ -130,24 +127,20 @@ class Answer
* @param string DESC or ASC
* @author Frederic Vauthier
*/
function readOrderedBy($field,$order=ASC)
{
function readOrderedBy($field,$order='ASC') {
global $_course;
$field = Database::escape_string($field);
if(empty($field)) {
if (empty($field)) {
$field = 'position';
}
if($order != 'ASC' and $order!='DESC')
{
if ($order != 'ASC' && $order!='DESC') {
$order = 'ASC';
}
$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
$questionId=$this->questionId;
//$answerType=$this->selectType();
$sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type, destination, id_auto " .
"FROM $TBL_ANSWER WHERE question_id='".Database::escape_string($questionId)."' " .
"FROM $TBL_ANSWER WHERE question_id='".$questionId."' " .
"ORDER BY $field $order";
$result=Database::query($sql);
@ -155,8 +148,7 @@ class Answer
$i=1;
// while a record is found
while($object=Database::fetch_object($result))
{
while($object=Database::fetch_object($result)) {
$this->answer[$i] = $object->answer;
$this->correct[$i] = $object->correct;
$this->comment[$i] = $object->comment;
@ -231,7 +223,6 @@ class Answer
* return array answer by id else return a bool
*/
function selectAnswerByAutoId($auto_id) {
$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
$auto_id = intval($auto_id);
$sql="SELECT id, answer FROM $TBL_ANSWER WHERE id_auto='$auto_id'";
@ -252,8 +243,7 @@ class Answer
* @param - integer $id - answer ID
* @return - bool - answer title
*/
function selectAnswerIdByPosition($pos)
{
function selectAnswerIdByPosition($pos) {
foreach ($this->position as $k => $v) {
if ($v != $pos) { continue; }
return $k;
@ -266,8 +256,7 @@ class Answer
* @author Yannick Warnier <ywarnier@beeznest.org>
* @return array List of answers where each answer is an array of (id, answer, comment, grade) and grade=weighting
*/
function getAnswersList($decode = false)
{
function getAnswersList($decode = false) {
$list = array();
for($i = 1; $i<=$this->nbrAnswers;$i++){
if(!empty($this->answer[$i])){
@ -316,7 +305,7 @@ class Answer
function getQuestionType()
{
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT type FROM $TBL_QUESTIONS WHERE id = '".Database::escape_string($this->questionId)."'";
$sql = "SELECT type FROM $TBL_QUESTIONS WHERE id = '".$this->questionId."'";
$res = Database::query($sql);
if(Database::num_rows($res)<=0){
return null;

@ -827,8 +827,7 @@ if ($show == 'test') {
echo '<br />'.get_count_exam_results($row['id']).' '.get_lang('Attempts');
//Special buttons
echo '<div class="operations">';
echo '<div class="operations">';
echo Display::url(Display::return_icon('quiz.gif',get_lang('Questions'), array('width'=>'22px'))." ".get_lang('Questions'),'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']);
echo ' ';
echo Display::url(Display::return_icon('preview.gif',get_lang('Preview'), array('width'=>'22px'))." ".get_lang('Preview'), 'exercice_submit.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id']);

@ -1658,7 +1658,7 @@ class Exercise {
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
$questionWeighting = $objQuestionTmp->selectWeighting();
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
$quesId = $objQuestionTmp->selectId();
$extra = $objQuestionTmp->extra;
@ -1697,7 +1697,7 @@ class Exercise {
$real_answers = array();
$quiz_question_options = Question::readQuestionOption($questionId);
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
@ -1757,9 +1757,9 @@ class Exercise {
$questionScore += $doubt_score;
}
}
$questionWeighting+=$true_score;
//$questionWeighting+=$true_score;
$totalScore +=$true_score;
//echo $studentChoice.' - '.$answerCorrect.' '.$questionScore.'<br />';
//echo $studentChoice.' - '.$answerCorrect.' '.$questionScore.' - '.$questionWeighting.'<br />';
break;
case MULTIPLE_ANSWER :
if ($from_database) {
@ -2388,7 +2388,7 @@ class Exercise {
} elseif ($answerType == FREE_ANSWER) {
$answer = $choice;
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
} elseif ($answerType == UNIQUE_ANSWER) {
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$answer = $choice;
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
} elseif ($answerType == HOT_SPOT) {
@ -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;
Database::query($sql_update);
}
return array('score'=>$questionScore, 'weight'=>$questionWeighting);
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting);
return $return_array;
} //End function

@ -88,6 +88,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$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);
$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
$quiz_question_options = Question::readQuestionOption($questionId);
@ -255,15 +256,15 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
if ($debug_mark_answer) {
if ($answerCorrect) {
$help = 'x-';
$selected = 'checked="checked"';
$selected = 'checked';
}
}
$answer = text_filter($answer);
$answer = Security::remove_XSS($answer, STUDENT);
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
$s .= Display::input('hidden','choice2['.$questionId.']','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;">'.
'<span><input class="checkbox" type="radio" name="choice['.$questionId.']" value="'.$numAnswer.'" '.$selected.' /></span></p>'.
'<span>'.Display::input('radio','choice['.$questionId.']', $numAnswer, array('class'=>'checkbox','selected'=>$selected)).'</span></p>'.
'<div style="margin-'.($is_ltr_text_direction ? 'left' : 'right').': 24px;">'.
$answer.
'</div></div></td></tr>';
@ -413,6 +414,8 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
}
} // end for()
//Adding divs for the new MATCHING interface
if ($answerType == MATCHING && !$freeze) {
@ -1070,22 +1073,37 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
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) {
$html = '';
$score_rounded = $score;
if ($score != '' && $weight != '') {
$max_note = api_get_setting('exercise_max_note');
$min_note = api_get_setting('exercise_min_note');
$max_note = api_get_setting('exercise_max_score');
$min_note = api_get_setting('exercise_min_score');
if ($max_note != '' && $min_note != '') {
if (!empty($weight)) {
$score = $min_note + ($max_note - $min_note) * $score /$weight;
$score = $min_note + ($max_note - $min_note) * $score /$weight;
} else {
$score = $min_note;
}
$score_rounded = round($score, 2);
$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;
}

@ -314,7 +314,13 @@ if ($show_results) {
// for each question
$counter=0;
//var_dump($exerciseResult);
$total_weighting = 0;
foreach ($questionList as $questionId) {
$objQuestionTmp = Question::read($questionId);
$total_weighting +=$objQuestionTmp->selectWeighting();
}
foreach ($questionList as $questionId) {
$counter++;
$choice=$exerciseResult[$questionId];
@ -372,7 +378,7 @@ if ($show_results) {
//var_dump($question_result);
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$questionWeighting += $question_result['weight'];
//$questionWeighting += $question_result['weight'];
echo '</table>';
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
@ -393,8 +399,7 @@ if ($show_results) {
</tr>
<?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'];
$totalScore += $question_result['score'];
@ -574,10 +579,11 @@ if ($show_results) {
</table>
<?php
$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 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>';
unset($objAnswerTmp);
@ -588,18 +594,14 @@ if ($show_results) {
} //end of condition if $show_results
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results) {
echo '<div id="question_score">'.get_lang('YourTotalScore')." ";
if ($show_results) {
echo '<div id="question_score">'.get_lang('YourTotalScore').": ";
if ($dsp_percent) {
$my_result = number_format(($totalScore/$totalWeighting)*100,1,'.','');
$my_result = float_format($my_result,1);
echo $my_result."%";
} else {
$my_total_score = float_format($totalScore,1);
$my_total_weight = float_format($totalWeighting,1);
echo $my_total_score."/".$my_total_weight;
echo show_score($totalScore,$totalWeighting,false);
}
echo '</div>';
}
@ -611,8 +613,7 @@ if (is_array($arrid) && is_array($arrmarks)) {
}
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 ' <input type = "hidden" name="totalWeighting" value="'.$totalWeighting.'">';
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);
$sorted_by_position = array();
foreach($new_options as $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();
for ($i=1 ; $i <= 3 ; $i++) {
$score = trim($form -> getSubmitValue('option['.$i.']'));
$extra_values[]= $score;
}
}
$this->setExtra(implode(':',$extra_values));
for ($i=1 ; $i <= $nb_answers ; $i++) {
@ -261,10 +260,10 @@ class MultipleAnswerTrueFalse extends Question {
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$goodAnswer = trim($form -> getSubmitValue('correct['.$i.']'));
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'];
}
$questionWeighting += $correct[1];
$questionWeighting += $extra_values[0]; //By default 0 has the correct answers
$objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i);
}

@ -90,6 +90,7 @@ if(is_object($objQuestion)) {
// question
$objQuestion -> processCreation($form,$objExercise);
// answers
$objQuestion -> processAnswersCreation($form,$nb_answers);
// TODO: maybe here is the better place to index this tool, including answers text

@ -119,6 +119,7 @@ if ($nbrQuestions) {
$questionList=$my_exercise->selectQuestionList();
$i=1;
if (is_array($questionList)) {
echo '<div id="question_list">';
foreach($questionList as $id) {
@ -140,49 +141,25 @@ if ($nbrQuestions) {
echo '<div id="question_id_list_'.$id.'" >';
$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>';
echo $actions;
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">';
}
?>
<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++;
*/
echo '</p>';
echo '</div>';
echo '</div>';
unset($objQuestionTmp);
echo '<div>';
echo '<p>';
echo $actions;
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);
echo '</p>';
echo '</div>';
echo '</div>';
unset($objQuestionTmp);
}
echo '</div>';
}

@ -249,52 +249,51 @@ class UniqueAnswerNoOption extends Question {
}
//Adding I don't know question option
$i = 666;
$form -> addElement ('html', '<tr>');
$defaults['answer['.$i.']'] = get_lang('DontKnow');
$defaults['weighting['.$i.']'] = 0;
$defaults['scenario']=$temp_scenario;
$renderer = & $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>','html');
$answer_number=$form->addElement('text', null,null,'value="-"');
$answer_number->freeze();
$form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
$form->addElement('html_editor', 'answer['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) {
// feedback
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
} elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
/* // direct feedback
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
//Adding extra feedback fields
$group = array();
$group['try'.$i] =&$form->createElement('checkbox', 'try'.$i,get_lang('TryAgain').': ' );
$group['lp'.$i] =&$form->createElement('select', 'lp'.$i,get_lang('SeeTheory').': ',$select_lp_id);
$group['destination'.$i]=&$form->createElement('select', 'destination'.$i, get_lang('GoToQuestion').': ' ,$select_question);
$group['url'.$i] =&$form->createElement('text', 'url'.$i,get_lang('Other').': ',array('size'=>'25px'));
$form -> addGroup($group, 'scenario', 'scenario');
$renderer->setGroupElementTemplate('<div class="exercise_scenario_label">{label}</div><div class="exercise_scenario_element">{element}</div>','scenario');*/
}
//$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple');
$form->addElement('text', 'weighting['.$i.']', null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0" readonly="readonly" ');
$form->addElement ('html', '</tr>');
//Adding the "I don't know" question answer
if(empty($this -> id)) {
$i = 666;
$form -> addElement ('html', '<tr>');
$defaults['answer['.$i.']'] = get_lang('DontKnow');
$defaults['weighting['.$i.']'] = 0;
$defaults['scenario']=$temp_scenario;
$renderer = & $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>','html');
$answer_number=$form->addElement('text', null,null,'value="-"');
$answer_number->freeze();
$form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
$form->addElement('html_editor', 'answer['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) {
// feedback
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
} elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
/* // direct feedback
$form->addElement('html_editor', 'comment['.$i.']', null, 'style="vertical-align:middle"', $editor_config);
//Adding extra feedback fields
$group = array();
$group['try'.$i] =&$form->createElement('checkbox', 'try'.$i,get_lang('TryAgain').': ' );
$group['lp'.$i] =&$form->createElement('select', 'lp'.$i,get_lang('SeeTheory').': ',$select_lp_id);
$group['destination'.$i]=&$form->createElement('select', 'destination'.$i, get_lang('GoToQuestion').': ' ,$select_question);
$group['url'.$i] =&$form->createElement('text', 'url'.$i,get_lang('Other').': ',array('size'=>'25px'));
$form -> addGroup($group, 'scenario', 'scenario');
$renderer->setGroupElementTemplate('<div class="exercise_scenario_label">{label}</div><div class="exercise_scenario_element">{element}</div>','scenario');*/
}
//$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple');
$form->addElement('text', 'weighting['.$i.']', null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="0" readonly="readonly" ');
$form->addElement ('html', '</tr>');
}
$form -> addElement ('html', '</table>');
$form -> addElement ('html', '<br />');
$navigator_info = api_get_navigator();
@ -347,16 +346,16 @@ class UniqueAnswerNoOption extends Question {
$correct = $form -> getSubmitValue('correct');
$objAnswer = new Answer($this->id);
$nb_answers = $form -> getSubmitValue('nb_answers');
for($i=1 ; $i <= $nb_answers ; $i++)
{
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
for ($i=1 ; $i <= $nb_answers ; $i++) {
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
$scenario= $form -> getSubmitValue('scenario');
echo '<pre>';
//$list_destination = $form -> getSubmitValue('destination'.$i);
//$destination_str = $form -> getSubmitValue('destination'.$i);
@ -387,12 +386,10 @@ class UniqueAnswerNoOption extends Question {
$goodAnswer= ($correct == $i) ? true : false;
if($goodAnswer)
{
if($goodAnswer) {
$nbrGoodAnswers++;
$weighting = abs($weighting);
if($weighting > 0)
{
if($weighting > 0) {
$questionWeighting += $weighting;
}
}
@ -400,30 +397,33 @@ class UniqueAnswerNoOption extends Question {
if (empty($try))
$try=0;
if (empty($lp))
{
if (empty($lp)) {
$lp=0;
}
if (empty($destination))
{
if (empty($destination)) {
$destination=0;
}
if ($url=='')
{
if ($url=='') {
$url=0;
}
//1@@1;2;@@2;4;4;@@http://www.dokeos.com
//1@@1;2;@@2;4;4;@@http://www.chamilo.org
$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
}
//Create 666 answer
$i = 666;
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
$goodAnswer= ($correct == $i) ? true : false;
$dest = '';
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
// saves the answers into the data base
$objAnswer -> save();

@ -290,7 +290,7 @@ function update_Db_course($course_db_name) {
$TABLEQUIZQUESTION = $course_db_name . 'quiz_rel_question';
$TABLEQUIZQUESTIONLIST = $course_db_name . 'quiz_question';
$TABLEQUIZANSWERSLIST = $course_db_name . 'quiz_answer';
$TABLEQUIZQUESTIONOPTION = $course_db_name . 'quiz_question_option';
$TABLEQUIZQUESTIONOPTION = $course_db_name . 'quiz_question_option';
// Dropbox
$TABLETOOLDROPBOXPOST = $course_db_name . 'dropbox_post';
@ -646,9 +646,10 @@ function update_Db_course($course_db_name) {
description text default NULL,
ponderation float(6,2) NOT NULL default 0,
position mediumint unsigned NOT NULL default 1,
type tinyint unsigned NOT NULL default 2,
picture varchar(50) default NULL,
level int unsigned NOT NULL default 0,
type tinyint unsigned NOT NULL default 2,
picture varchar(50) default NULL,
level int unsigned NOT NULL default 0,
extra varchar(255) default NULL,
PRIMARY KEY (id)
)" . $charset_clause;
Database::query($sql);

@ -1330,15 +1330,17 @@ class Database {
public static function find($table_name, $columns = '*' , $where_conditions = array(), $option = 'ASSOC') {
$where_return = self::parse_where_conditions($where_conditions);
$columns_filtred = '';
$clean_columns = '';
if (is_array($columns)) {
$columns_filtred = implode(',', $columns);
$clean_columns = implode(',', $columns);
} else {
if ($columns == '*') {
$columns_filtred = '*';
$clean_columns = '*';
} else {
$clean_columns = (string)$columns;
}
}
$sql = "SELECT $columns_filtred FROM $table_name $where_return ";
$sql = "SELECT $clean_columns FROM $table_name $where_return ";
$result = self::query($sql);
$array = array();

@ -678,7 +678,7 @@ class Display {
/**
* Returns the htmlcode for a tag (h3, h1, div), etc
* Returns the htmlcode for a tag (h3, h1, div, a, button), etc
*
* @param string $image the filename of the file (in the main/img/ folder
* @param string $alt_text the alt text (probably a language variable)
@ -695,7 +695,7 @@ class Display {
}
}
//some tags don't have this </XXX>
if (in_array($tag, array('img','input'))) {
if (in_array($tag, array('img','input','br'))) {
$return_value = '<'.$tag.' '.$attribute_list.' />';
} else {
$return_value = '<'.$tag.' '.$attribute_list.' > '.$content.'</'.$tag.'>';
@ -710,6 +710,23 @@ class Display {
return self::tag('a', $name, $extra_attributes);
}
public static function input($type, $name, $value, $extra_attributes = array()) {
if (!empty($type)) {
$extra_attributes['type']= $type;
}
if (!empty($name)) {
$extra_attributes['name']= $name;
}
if (!empty($value)) {
$extra_attributes['value']= $value;
}
return self::tag('input', '',$extra_attributes);
}
/**
* Displays a select tag
*
*/
public function select($name, $values, $default = -1, $parameter_list = array(), $show_blank_item = true) {
$extra = '';
foreach($parameter_list as $key=>$parameter) {

@ -782,9 +782,9 @@ VALUES
('pdf_export_watermark_text', NULL,'textfield', 'Platform', '', 'PDFExportWatermarkTextTitle', 'PDFExportWatermarkTextComment', 'platform',NULL, 1),
('enabled_insertHtml', NULL,'radio', 'Editor', 'false','EnabledInsertHtmlTitle', 'EnabledInsertHtmlComment',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_max_note', NULL,'textfield', 'Course', '', 'ExerciseMaxNoteTitle', 'ExerciseMaxNoteComment','platform',NULL, 1),
('chamilo_database_version', NULL,'textfield', NULL, '1.8.8.13050','DokeosDatabaseVersion','', NULL, NULL, 0);
('exercise_min_score', NULL,'textfield', 'Course', '', 'ExerciseMinScoreTitle', 'ExerciseMinScoreComment','platform',NULL, 1),
('exercise_max_score', NULL,'textfield', 'Course', '', 'ExerciseMaxScoreTitle', 'ExerciseMaxScoreComment','platform',NULL, 1),
('chamilo_database_version', NULL,'textfield', NULL, '1.8.8.13174','DokeosDatabaseVersion','', NULL, NULL, 0);
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', '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);
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_score', NULL,'textfield', 'Course', '', 'ExerciseMaxScoreTitle', 'ExerciseMaxScoreComment','platform',NULL, 1);
-- xxSTATSxx
@ -122,6 +122,7 @@ ALTER TABLE lp ADD COLUMN expired_on DATETIME NOT NULL DEFAULT '0000-00-00 00:0
ALTER TABLE lp ADD COLUMN publicated_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';
CREATE TABLE quiz_question_option (id int NOT NULL, name varchar(255), position int unsigned NOT NULL, PRIMARY KEY (id));
ALTER TABLE quiz_question ADD COLUMN extra varchar(255) DEFAULT NULL;
INSERT INTO course_setting(variable,value,category) VALUES ('enable_lp_auto_launch',0,'learning_path');
INSERT INTO course_setting(variable,value,category) VALUES ('pdf_export_watermark_text','','course');

Loading…
Cancel
Save