Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent 4735112fef
commit 407faaab43
  1. 27
      main/exercise/Annotation.php
  2. 2
      main/exercise/Draggable.php
  3. 13
      main/exercise/adminhp.php
  4. 2
      main/exercise/annotation_user.php
  5. 683
      main/exercise/answer.class.php
  6. 10
      main/exercise/calculated_answer.class.php
  7. 24
      main/exercise/exercise_admin.php
  8. 28
      main/exercise/exercise_history.php
  9. 26
      main/exercise/exercise_reminder.php
  10. 23
      main/exercise/exercise_report.php
  11. 46
      main/exercise/exercise_result.php
  12. 8
      main/exercise/exercise_show.php
  13. 10
      main/exercise/freeanswer.class.php

@ -34,7 +34,12 @@ class Annotation extends Question
{ {
parent::createForm($form, $fck_config); parent::createForm($form, $fck_config);
$form->addElement('number', 'weighting', get_lang('Weighting'), ['step' => '0.1']); $form->addElement(
'number',
'weighting',
get_lang('Weighting'),
['step' => '0.1']
);
if (!empty($this->id)) { if (!empty($this->id)) {
$form->setDefaults(array('weighting' => float_format($this->weighting, 1))); $form->setDefaults(array('weighting' => float_format($this->weighting, 1)));
@ -55,14 +60,26 @@ class Annotation extends Question
'imageUpload', 'imageUpload',
array( array(
Display::img( Display::img(
Display::return_icon('annotation.png', null, null, ICON_SIZE_BIG, false, true) Display::return_icon(
'annotation.png',
null,
null,
ICON_SIZE_BIG,
false,
true
)
), ),
get_lang('UploadJpgPicture'), get_lang('UploadJpgPicture'),
) )
); );
$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
$form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array('jpg', 'jpeg', 'png', 'gif')); $form->addRule(
'imageUpload',
get_lang('OnlyImagesAllowed'),
'filetype',
array('jpg', 'jpeg', 'png', 'gif')
);
$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
} }
@ -92,7 +109,7 @@ class Annotation extends Question
/** /**
* @param FormValidator $form * @param FormValidator $form
*/ */
function createAnswersForm($form) public function createAnswersForm($form)
{ {
// nothing // nothing
} }
@ -100,7 +117,7 @@ class Annotation extends Question
/** /**
* @param FormValidator $form * @param FormValidator $form
*/ */
function processAnswersCreation($form) public function processAnswersCreation($form)
{ {
$this->weighting = $form->getSubmitValue('weighting'); $this->weighting = $form->getSubmitValue('weighting');
$this->save(); $this->save();

@ -57,7 +57,6 @@ class Draggable extends Question
if (count($answer->nbrAnswers) > 0) { if (count($answer->nbrAnswers) > 0) {
$nb_matches = $nb_options = 0; $nb_matches = $nb_options = 0;
for ($i = 1; $i <= $answer->nbrAnswers; $i++) { for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
if ($answer->isCorrect($i)) { if ($answer->isCorrect($i)) {
$nb_matches++; $nb_matches++;
@ -107,7 +106,6 @@ class Draggable extends Question
for ($i = 1; $i <= $nb_matches; ++$i) { for ($i = 1; $i <= $nb_matches; ++$i) {
$renderer = &$form->defaultRenderer(); $renderer = &$form->defaultRenderer();
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>',
"answer[$i]" "answer[$i]"

@ -2,9 +2,9 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* HotPotatoes administration. * HotPotatoes administration.
* @package chamilo.exercise * @package chamilo.exercise
* @author Istvan Mandak * @author Istvan Mandak
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
@ -27,10 +27,10 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true);
$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
// picture path // picture path
$picturePath=$documentPath.'/images'; $picturePath = $documentPath.'/images';
// audio path // audio path
$audioPath=$documentPath.'/audio'; $audioPath = $documentPath.'/audio';
// Database table definitions // Database table definitions
if (!$is_allowedToEdit) { if (!$is_allowedToEdit) {
@ -56,13 +56,10 @@ Display::display_header($nameTools,"Exercise");
/** @todo probably wrong !!!! */ /** @todo probably wrong !!!! */
require_once api_get_path(SYS_CODE_PATH).'/exercise/hotpotatoes.lib.php'; require_once api_get_path(SYS_CODE_PATH).'/exercise/hotpotatoes.lib.php';
?> ?>
<h4> <h4>
<?php echo $nameTools; ?> <?php echo $nameTools; ?>
</h4> </h4>
<?php <?php
if (isset($newName)) { if (isset($newName)) {
if ($newName!="") { if ($newName!="") {

@ -50,14 +50,12 @@ if (!empty($attemptList) && isset($attemptList[$questionId])) {
foreach ($parts as $partPoint) { foreach ($parts as $partPoint) {
$points[] = Geometry::decodePoint($partPoint); $points[] = Geometry::decodePoint($partPoint);
} }
$data['answers']['paths'][] = $points; $data['answers']['paths'][] = $points;
break; break;
case 'T': case 'T':
$text = [ $text = [
'text' => array_shift($parts) 'text' => array_shift($parts)
]; ];
$data['answers']['texts'][] = $text + Geometry::decodePoint($parts[0]); $data['answers']['texts'][] = $text + Geometry::decodePoint($parts[0]);
break; break;
} }

@ -39,8 +39,8 @@ class Answer
public $new_destination; // id of the next question if feedback option is set to Directfeedback public $new_destination; // id of the next question if feedback option is set to Directfeedback
public $course; //Course information public $course; //Course information
public $iid; public $iid;
public $questionJSId; public $questionJSId;
public $standalone; public $standalone;
/** /**
* constructor of the class * constructor of the class
@ -186,34 +186,34 @@ class Answer
} }
return $id; return $id;
} }
/** /**
* Reads answer information from the data base ordered by parameter * Reads answer information from the data base ordered by parameter
* @param string Field we want to order by * @param string $field Field we want to order by
* @param string DESC or ASC * @param string $order DESC or ASC
* @param string $field *
* @author Frederic Vauthier * @author Frederic Vauthier
*/ */
public function readOrderedBy($field, $order = 'ASC') public function readOrderedBy($field, $order = 'ASC')
{ {
$field = Database::escape_string($field); $field = Database::escape_string($field);
if (empty($field)) { if (empty($field)) {
$field = 'position'; $field = 'position';
} }
if ($order != 'ASC' && $order != 'DESC') { if ($order != 'ASC' && $order != 'DESC') {
$order = 'ASC'; $order = 'ASC';
} }
$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
$TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
$questionId = intval($this->questionId); $questionId = intval($this->questionId);
$sql = "SELECT type FROM $TBL_QUIZ $sql = "SELECT type FROM $TBL_QUIZ
WHERE c_id = {$this->course_id} AND id = $questionId"; WHERE c_id = {$this->course_id} AND id = $questionId";
$result_question = Database::query($sql); $result_question = Database::query($sql);
$questionType = Database::fetch_array($result_question); $questionType = Database::fetch_array($result_question);
if ($questionType['type'] == DRAGGABLE) { if ($questionType['type'] == DRAGGABLE) {
// Random is done by submit.js.tpl // Random is done by submit.js.tpl
@ -222,32 +222,32 @@ class Answer
return true; return true;
} }
$sql = "SELECT $sql = "SELECT
answer, answer,
correct, correct,
comment, comment,
ponderation, ponderation,
position, position,
hotspot_coordinates, hotspot_coordinates,
hotspot_type, hotspot_type,
destination, destination,
id_auto, id_auto,
iid iid
FROM $TBL_ANSWER FROM $TBL_ANSWER
WHERE WHERE
c_id = {$this->course_id} AND c_id = {$this->course_id} AND
question_id='".$questionId."' question_id='".$questionId."'
ORDER BY $field $order"; ORDER BY $field $order";
$result = Database::query($sql); $result = Database::query($sql);
$i = 1; $i = 1;
// while a record is found // while a record is found
$doubt_data = null; $doubt_data = null;
while ($object = Database::fetch_object($result)) { while ($object = Database::fetch_object($result)) {
if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) { if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
$doubt_data = $object; $doubt_data = $object;
continue; continue;
} }
$this->answer[$i] = $object->answer; $this->answer[$i] = $object->answer;
$this->correct[$i] = $object->correct; $this->correct[$i] = $object->correct;
$this->comment[$i] = $object->comment; $this->comment[$i] = $object->comment;
@ -259,9 +259,9 @@ class Answer
$this->autoId[$i] = $object->id_auto; $this->autoId[$i] = $object->id_auto;
$this->iid[$i] = $object->iid; $this->iid[$i] = $object->iid;
$i++; $i++;
} }
if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) { if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
$this->answer[$i] = $doubt_data->answer; $this->answer[$i] = $doubt_data->answer;
$this->correct[$i] = $doubt_data->correct; $this->correct[$i] = $doubt_data->correct;
$this->comment[$i] = $doubt_data->comment; $this->comment[$i] = $doubt_data->comment;
@ -273,88 +273,88 @@ class Answer
$this->autoId[$i] = $doubt_data->id_auto; $this->autoId[$i] = $doubt_data->id_auto;
$this->iid[$i] = $doubt_data->iid; $this->iid[$i] = $doubt_data->iid;
$i++; $i++;
} }
$this->nbrAnswers = $i - 1; $this->nbrAnswers = $i - 1;
} }
/** /**
* returns the autoincrement id identificator * returns the autoincrement id identificator
* *
* @author Juan Carlos Ra<EFBFBD>a * @author Juan Carlos Ra<EFBFBD>a
* @return integer - answer num * @return integer - answer num
*/ */
public function selectAutoId($id) public function selectAutoId($id)
{ {
return isset($this->autoId[$id]) ? $this->autoId[$id] : 0; return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
} }
/** /**
* returns the number of answers in this question * returns the number of answers in this question
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @return integer - number of answers * @return integer - number of answers
*/ */
public function selectNbrAnswers() public function selectNbrAnswers()
{ {
return $this->nbrAnswers; return $this->nbrAnswers;
} }
/** /**
* returns the question ID which the answers belong to * returns the question ID which the answers belong to
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @return integer - the question ID * @return integer - the question ID
*/ */
public function selectQuestionId() public function selectQuestionId()
{ {
return $this->questionId; return $this->questionId;
} }
/** /**
* returns the question ID of the destination question * returns the question ID of the destination question
* *
* @author Julio Montoya * @author Julio Montoya
* @param integer $id * @param integer $id
* @return integer - the question ID * @return integer - the question ID
*/ */
public function selectDestination($id) public function selectDestination($id)
{
return isset($this->destination[$id]) ? $this->destination[$id] : null;
}
/**
* returns the answer title
*
* @author Olivier Brouckaert
* @param - integer $id - answer ID
* @return string - answer title
*/
public function selectAnswer($id)
{ {
return isset($this->destination[$id]) ? $this->destination[$id] : null; return isset($this->answer[$id]) ? $this->answer[$id] : null;
} }
/** /**
* returns the answer title * return array answer by id else return a bool
* * @param integer $auto_id
* @author Olivier Brouckaert */
* @param - integer $id - answer ID public function selectAnswerByAutoId($auto_id)
* @return string - answer title {
*/ $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
public function selectAnswer($id)
{ $auto_id = intval($auto_id);
return isset($this->answer[$id]) ? $this->answer[$id] : null; $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
} WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
$rs = Database::query($sql);
/**
* return array answer by id else return a bool if (Database::num_rows($rs) > 0) {
* @param integer $auto_id $row = Database::fetch_array($rs, 'ASSOC');
*/
public function selectAnswerByAutoId($auto_id) return $row;
{ }
$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
return false;
$auto_id = intval($auto_id); }
$sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs, 'ASSOC');
return $row;
}
return false;
}
/** /**
* returns the answer title from an answer's position * returns the answer title from an answer's position
@ -363,18 +363,18 @@ class Answer
* @param - integer $id - answer ID * @param - integer $id - answer ID
* @return bool - answer title * @return bool - answer title
*/ */
public function selectAnswerIdByPosition($pos) public function selectAnswerIdByPosition($pos)
{ {
foreach ($this->position as $k => $v) { foreach ($this->position as $k => $v) {
if ($v != $pos) { if ($v != $pos) {
continue; continue;
} }
return $k; return $k;
} }
return false; return false;
} }
/** /**
* Returns a list of answers * Returns a list of answers
@ -383,18 +383,25 @@ class Answer
* of (id, answer, comment, grade) and grade=weighting * of (id, answer, comment, grade) and grade=weighting
*/ */
public function getAnswersList($decode = false) public function getAnswersList($decode = false)
{ {
$list = array(); $list = array();
for ($i = 1; $i <= $this->nbrAnswers; $i++) { for ($i = 1; $i <= $this->nbrAnswers; $i++) {
if (!empty($this->answer[$i])) { if (!empty($this->answer[$i])) {
//Avoid problems when parsing elements with accents
//Avoid problems when parsing elements with accents if ($decode) {
if ($decode) { $this->answer[$i] = api_html_entity_decode(
$this->answer[$i] = api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); $this->answer[$i],
$this->comment[$i] = api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); ENT_QUOTES,
} api_get_system_encoding()
);
$list[] = array( $this->comment[$i] = api_html_entity_decode(
$this->comment[$i],
ENT_QUOTES,
api_get_system_encoding()
);
}
$list[] = array(
'id' => $i, 'id' => $i,
'answer' => $this->answer[$i], 'answer' => $this->answer[$i],
'comment' => $this->comment[$i], 'comment' => $this->comment[$i],
@ -402,138 +409,137 @@ class Answer
'hotspot_coord' => $this->hotspot_coordinates[$i], 'hotspot_coord' => $this->hotspot_coordinates[$i],
'hotspot_type' => $this->hotspot_type[$i], 'hotspot_type' => $this->hotspot_type[$i],
'correct' => $this->correct[$i], 'correct' => $this->correct[$i],
'destination' => $this->destination[$i] 'destination' => $this->destination[$i],
); );
} }
} }
return $list; return $list;
} }
/** /**
* Returns a list of grades * Returns a list of grades
* @author Yannick Warnier <ywarnier@beeznest.org> * @author Yannick Warnier <ywarnier@beeznest.org>
* @return array List of grades where grade=weighting (?) * @return array List of grades where grade=weighting (?)
*/ */
public function getGradesList() public function getGradesList()
{ {
$list = array(); $list = array();
for ($i = 0; $i < $this->nbrAnswers; $i++) { for ($i = 0; $i < $this->nbrAnswers; $i++) {
if (!empty($this->answer[$i])) { if (!empty($this->answer[$i])) {
$list[$i] = $this->weighting[$i]; $list[$i] = $this->weighting[$i];
} }
} }
return $list;
} return $list;
}
/**
* Returns the question type /**
* @author Yannick Warnier <ywarnier@beeznest.org> * Returns the question type
* @return integer The type of the question this answer is bound to * @author Yannick Warnier <ywarnier@beeznest.org>
*/ * @return integer The type of the question this answer is bound to
*/
public function getQuestionType() public function getQuestionType()
{ {
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT type FROM $TBL_QUESTIONS $sql = "SELECT type FROM $TBL_QUESTIONS
WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'"; WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) <= 0) { if (Database::num_rows($res) <= 0) {
return null; return null;
} }
$row = Database::fetch_array($res); $row = Database::fetch_array($res);
return $row['type']; return $row['type'];
} }
/** /**
* tells if answer is correct or not * tells if answer is correct or not
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @param - integer $id - answer ID * @param - integer $id - answer ID
* @return integer - 0 if bad answer, not 0 if good answer * @return integer - 0 if bad answer, not 0 if good answer
*/ */
public function isCorrect($id) public function isCorrect($id)
{ {
return isset($this->correct[$id]) ? $this->correct[$id] : null; return isset($this->correct[$id]) ? $this->correct[$id] : null;
} }
/** /**
* returns answer comment * returns answer comment
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @param - integer $id - answer ID * @param - integer $id - answer ID
* @return string - answer comment * @return string - answer comment
*/ */
public function selectComment($id) public function selectComment($id)
{ {
return isset($this->comment[$id]) ? $this->comment[$id] : null; return isset($this->comment[$id]) ? $this->comment[$id] : null;
} }
/** /**
* returns answer weighting * returns answer weighting
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @param - integer $id - answer ID * @param - integer $id - answer ID
* @param integer $id * @param integer $id
* @return integer - answer weighting * @return integer - answer weighting
*/ */
public function selectWeighting($id) public function selectWeighting($id)
{ {
return isset($this->weighting[$id]) ? $this->weighting[$id] : null; return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
} }
/** /**
* returns answer position * returns answer position
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @param - integer $id - answer ID * @param - integer $id - answer ID
* @return integer - answer position * @return integer - answer position
*/ */
function selectPosition($id) function selectPosition($id)
{ {
return isset($this->position[$id]) ? $this->position[$id] : null; return isset($this->position[$id]) ? $this->position[$id] : null;
} }
/** /**
* returns answer hotspot coordinates * returns answer hotspot coordinates
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @param integer Answer ID * @param integer $id Answer ID
* @param integer $id * @return integer Answer position
* @return integer Answer position */
*/
public function selectHotspotCoordinates($id) public function selectHotspotCoordinates($id)
{ {
return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null; return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
} }
/** /**
* returns answer hotspot type * returns answer hotspot type
* *
* @author Toon Keppens * @author Toon Keppens
* @param integer Answer ID * @param integer $id Answer ID
* @param integer $id * @return integer Answer position
* @return integer Answer position */
*/
public function selectHotspotType($id) public function selectHotspotType($id)
{ {
return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null; return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
} }
/** /**
* Creates a new answer * Creates a new answer
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @param string $answer answer title * @param string $answer answer title
* @param integer $correct 0 if bad answer, not 0 if good answer * @param integer $correct 0 if bad answer, not 0 if good answer
* @param string $comment answer comment * @param string $comment answer comment
* @param integer $weighting answer weighting * @param integer $weighting answer weighting
* @param integer $position answer position * @param integer $position answer position
* @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional) * @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
* @param integer $new_hotspot_type Type for hotspot exercises (optional) * @param integer $new_hotspot_type Type for hotspot exercises (optional)
* @param string $destination * @param string $destination
*/ */
public function createAnswer( public function createAnswer(
$answer, $answer,
$correct, $correct,
@ -544,7 +550,7 @@ class Answer
$new_hotspot_type = null, $new_hotspot_type = null,
$destination = '' $destination = ''
) { ) {
$this->new_nbrAnswers++; $this->new_nbrAnswers++;
$id = $this->new_nbrAnswers; $id = $this->new_nbrAnswers;
$this->new_answer[$id] = $answer; $this->new_answer[$id] = $answer;
$this->new_correct[$id] = $correct; $this->new_correct[$id] = $correct;
@ -554,7 +560,7 @@ class Answer
$this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates; $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates;
$this->new_hotspot_type[$id] = $new_hotspot_type; $this->new_hotspot_type[$id] = $new_hotspot_type;
$this->new_destination[$id] = $destination; $this->new_destination[$id] = $destination;
} }
/** /**
* Updates an answer * Updates an answer
@ -597,32 +603,32 @@ class Answer
$em->merge($quizAnswer); $em->merge($quizAnswer);
$em->flush(); $em->flush();
} }
/** /**
* Records answers into the data base * Records answers into the data base
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
*/ */
public function save() public function save()
{ {
$answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER); $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
$em = Database::getManager(); $em = Database::getManager();
$questionId = intval($this->questionId); $questionId = intval($this->questionId);
$c_id = $this->course['real_id']; $c_id = $this->course['real_id'];
$correctList = []; $correctList = [];
$answerList = []; $answerList = [];
for ($i = 1; $i <= $this->new_nbrAnswers; $i++) { for ($i = 1; $i <= $this->new_nbrAnswers; $i++) {
$answer = $this->new_answer[$i]; $answer = $this->new_answer[$i];
$correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : ''; $correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : '';
$comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : ''; $comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : '';
$weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : ''; $weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : '';
$position = isset($this->new_position[$i]) ? $this->new_position[$i] : ''; $position = isset($this->new_position[$i]) ? $this->new_position[$i] : '';
$hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : ''; $hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : '';
$hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : ''; $hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : '';
$destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : ''; $destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : '';
$autoId = $this->selectAutoId($i); $autoId = $this->selectAutoId($i);
$iid = isset($this->iid[$i]) ? $this->iid[$i] : 0; $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;
@ -664,11 +670,11 @@ class Answer
$answer->read(); $answer->read();
$correctAnswerId = $answer->selectAnswerIdByPosition($correct); $correctAnswerId = $answer->selectAnswerIdByPosition($correct);
// Continue to avoid matching question bug if $correctAnswerId returns false // Continue to avoid matching question bug if $correctAnswerId returns false
// See : https://support.chamilo.org/issues/8334 // See : https://support.chamilo.org/issues/8334
if ($questionType == MATCHING && !$correctAnswerId) { if ($questionType == MATCHING && !$correctAnswerId) {
continue; continue;
} }
$correctAnswerAutoId = $answer->selectAutoId($correct); $correctAnswerAutoId = $answer->selectAutoId($correct);
$quizAnswer->setCorrect($correctAnswerAutoId ? $correctAnswerAutoId : 0); $quizAnswer->setCorrect($correctAnswerAutoId ? $correctAnswerAutoId : 0);
@ -725,36 +731,36 @@ class Answer
while ($this->position[$i]) { while ($this->position[$i]) {
$position = $this->position[$i]; $position = $this->position[$i];
$sql = "DELETE FROM $answerTable $sql = "DELETE FROM $answerTable
WHERE WHERE
c_id = {$this->course_id} AND c_id = {$this->course_id} AND
question_id = '".$questionId."' AND question_id = '".$questionId."' AND
position ='$position'"; position ='$position'";
Database::query($sql); Database::query($sql);
$i++; $i++;
} }
} }
// moves $new_* arrays // moves $new_* arrays
$this->answer = $this->new_answer; $this->answer = $this->new_answer;
$this->correct = $this->new_correct; $this->correct = $this->new_correct;
$this->comment = $this->new_comment; $this->comment = $this->new_comment;
$this->weighting = $this->new_weighting; $this->weighting = $this->new_weighting;
$this->position = $this->new_position; $this->position = $this->new_position;
$this->hotspot_coordinates = $this->new_hotspot_coordinates; $this->hotspot_coordinates = $this->new_hotspot_coordinates;
$this->hotspot_type = $this->new_hotspot_type; $this->hotspot_type = $this->new_hotspot_type;
$this->nbrAnswers = $this->new_nbrAnswers; $this->nbrAnswers = $this->new_nbrAnswers;
$this->destination = $this->new_destination; $this->destination = $this->new_destination;
$this->cancel(); $this->cancel();
} }
/** /**
* Duplicates answers by copying them into another question * Duplicates answers by copying them into another question
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
* @param Question $newQuestion * @param Question $newQuestion
* @param array $course_info destination course info (result of the function api_get_course_info() ) * @param array $course_info destination course info (result of the function api_get_course_info() )
*/ */
public function duplicate($newQuestion, $course_info = null) public function duplicate($newQuestion, $course_info = null)
{ {
$newQuestionId = $newQuestion->id; $newQuestionId = $newQuestion->id;
@ -777,7 +783,7 @@ class Answer
if (!empty($origin_options)) { if (!empty($origin_options)) {
foreach ($origin_options as $item) { foreach ($origin_options as $item) {
$new_option_list[] = $item['id']; $new_option_list[] = $item['id'];
} }
} }
@ -794,15 +800,15 @@ class Answer
} }
} }
// if at least one answer // if at least one answer
if ($this->nbrAnswers) { if ($this->nbrAnswers) {
// inserts new answers into data base // inserts new answers into data base
$courseId = $course_info['real_id']; $courseId = $course_info['real_id'];
$correctAnswers = []; $correctAnswers = [];
$onlyAnswers = []; $onlyAnswers = [];
$allAnswers = []; $allAnswers = [];
$em = Database::getManager(); $em = Database::getManager();
if (in_array($newQuestion->type, [MATCHING, MATCHING_DRAGGABLE])) { if (in_array($newQuestion->type, [MATCHING, MATCHING_DRAGGABLE])) {
$temp = array(); $temp = array();
@ -868,7 +874,7 @@ class Answer
$correctAnswers[$answerId] = $answer['correct']; $correctAnswers[$answerId] = $answer['correct'];
$onlyAnswers[$answerId] = $answer['answer']; $onlyAnswers[$answerId] = $answer['answer'];
} }
} }
} else { } else {
for ($i = 1; $i <= $this->nbrAnswers; $i++) { for ($i = 1; $i <= $this->nbrAnswers; $i++) {
if ($this->course['id'] != $course_info['id']) { if ($this->course['id'] != $course_info['id']) {
@ -945,7 +951,7 @@ class Answer
} }
} }
} }
} }
/** /**
* Get the necessary JavaScript for some answers * Get the necessary JavaScript for some answers
@ -963,25 +969,24 @@ class Answer
</script>"; </script>";
} }
/** /**
* Check if a answer is correct by an answer auto id * Check if a answer is correct by an answer auto id
* @param $needle int The answer auto id * @param $needle int The answer auto id
* @return bool * @return bool
*/ */
public function isCorrectByAutoId($needle) public function isCorrectByAutoId($needle)
{ {
$key = 0; $key = 0;
foreach ($this->autoId as $autoIdKey => $autoId) {
foreach ($this->autoId as $autoIdKey => $autoId) { if ($autoId == $needle) {
if ($autoId == $needle) { $key = $autoIdKey;
$key = $autoIdKey; }
} }
}
if (!$key) {
if (!$key) { return false;
return false; }
}
return $this->isCorrect($key) ? true : false;
return $this->isCorrect($key) ? true : false; }
}
} }

@ -31,7 +31,6 @@ class CalculatedAnswer extends Question
public function createAnswersForm($form) public function createAnswersForm($form)
{ {
$defaults = array(); $defaults = array();
if (!empty($this->id)) { if (!empty($this->id)) {
$objAnswer = new Answer($this->id); $objAnswer = new Answer($this->id);
$preArray = explode('@@', $objAnswer->selectAnswer(1)); $preArray = explode('@@', $objAnswer->selectAnswer(1));
@ -125,9 +124,14 @@ class CalculatedAnswer extends Question
Display::return_icon('fill_field.png'), Display::return_icon('fill_field.png'),
array( array(
'id' => 'answer', 'id' => 'answer',
'onkeyup' => 'javascript: updateBlanks(this);' 'onkeyup' => 'javascript: updateBlanks(this);',
), ),
array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350')); array(
'ToolbarSet' => 'TestQuestionDescription',
'Width' => '100%',
'Height' => '350',
)
);
$form->addRule('answer', get_lang('GiveText'), 'required'); $form->addRule('answer', get_lang('GiveText'), 'required');
$form->addRule('answer', get_lang('DefineBlanks'), 'regex', '/\[.*\]/'); $form->addRule('answer', get_lang('DefineBlanks'), 'regex', '/\[.*\]/');

@ -109,11 +109,8 @@ $htmlHeadXtra[] = '<script>
disabledHideRandom(); disabledHideRandom();
$("#hidden_matrix").show(); $("#hidden_matrix").show();
break; break;
} }
} }
</script>'; </script>';
// to correct #4029 Random and number of attempt menu empty added window.onload=advanced_parameters; // to correct #4029 Random and number of attempt menu empty added window.onload=advanced_parameters;
@ -153,9 +150,13 @@ $objExercise->createForm($form);
if ($form->validate()) { if ($form->validate()) {
$objExercise->processCreation($form); $objExercise->processCreation($form);
if ($form->getSubmitValue('edit') == 'true') { if ($form->getSubmitValue('edit') == 'true') {
Display::addFlash(Display::return_message(get_lang('ExerciseEdited'))); Display::addFlash(
Display::return_message(get_lang('ExerciseEdited'), 'success')
);
} else { } else {
Display::addFlash(Display::return_message(get_lang('ExerciseAdded'))); Display::addFlash(
Display::return_message(get_lang('ExerciseAdded'), 'success')
);
} }
$exercise_id = $objExercise->id; $exercise_id = $objExercise->id;
Session::erase('objExercise'); Session::erase('objExercise');
@ -168,7 +169,7 @@ if ($form->validate()) {
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array ( $interbreadcrumb[]= array(
'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
@ -191,8 +192,8 @@ if ($form->validate()) {
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">' . echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">' .
Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
} else { } else {
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){ if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) {
if (!empty($_POST['lp_id'])){ if (!empty($_POST['lp_id'])) {
$lp_id = intval($_POST['lp_id']); $lp_id = intval($_POST['lp_id']);
//TODO:this remains to be implemented after press the first post //TODO:this remains to be implemented after press the first post
} else { } else {
@ -207,12 +208,15 @@ if ($form->validate()) {
} }
echo '</div>'; echo '</div>';
if ($objExercise->feedback_type == 1) if ($objExercise->feedback_type == 1) {
Display::display_normal_message( Display::display_normal_message(
get_lang('DirectFeedbackCantModifyTypeQuestion') get_lang('DirectFeedbackCantModifyTypeQuestion')
); );
}
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('SearchXapianModuleNotInstalled')); Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));
} }

@ -2,13 +2,12 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Exercise list: This script shows the list of exercises for administrators and students. * Exercise list: This script shows the list of exercises for administrators and students.
* @package chamilo.exercise * @package chamilo.exercise
* @author Olivier Brouckaert, original author * @author Olivier Brouckaert, original author
* @author Denes Nagy, HotPotatoes integration * @author Denes Nagy, HotPotatoes integration
* @author Wolfgang Schneider, code/html cleanup * @author Wolfgang Schneider, code/html cleanup
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
api_protect_course_script(true); api_protect_course_script(true);
@ -25,9 +24,18 @@ if (!$is_allowedToEdit) {
exit; exit;
} }
$interbreadcrumb[] = array('url' => 'exercise_report.php?'.api_get_cidreq(), 'name' => get_lang('Exercises')); $interbreadcrumb[] = array(
$interbreadcrumb[] = array('url' => 'exercise_report.php?filter=2&'.api_get_cidreq(), 'name' => get_lang('StudentScore')); 'url' => 'exercise_report.php?'.api_get_cidreq(),
$interbreadcrumb[] = array('url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(), 'name' => get_lang('Details')); 'name' => get_lang('Exercises'),
);
$interbreadcrumb[] = array(
'url' => 'exercise_report.php?filter=2&'.api_get_cidreq(),
'name' => get_lang('StudentScore'),
);
$interbreadcrumb[] = array(
'url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(),
'name' => get_lang('Details'),
);
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -86,6 +94,6 @@ while ($row = Database::fetch_array($query)) {
echo '<td>'.(empty($row['firstname']) && empty($row['lastname']) ? '<i>'.get_lang('OriginalValue').'</i>' : api_get_person_name($row['firstname'], $row['lastname'])).'</td>'; echo '<td>'.(empty($row['firstname']) && empty($row['lastname']) ? '<i>'.get_lang('OriginalValue').'</i>' : api_get_person_name($row['firstname'], $row['lastname'])).'</td>';
echo '<td>'.api_convert_and_format_date($row['insert_date'], DATE_TIME_FORMAT_LONG).'</td>'; echo '<td>'.api_convert_and_format_date($row['insert_date'], DATE_TIME_FORMAT_LONG).'</td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table>'; echo '</table>';
Display::display_footer(); Display::display_footer();

@ -1,7 +1,7 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use \ChamiloSession as Session; use ChamiloSession as Session;
/** /**
* Exercise reminder overview * Exercise reminder overview
@ -22,7 +22,7 @@ if ($debug>0) {
} }
// general parameters passed via POST/GET // general parameters passed via POST/GET
if (empty ($origin)) { if (empty($origin)) {
if (!empty($_REQUEST['origin'])) { if (!empty($_REQUEST['origin'])) {
$origin = Security::remove_XSS($_REQUEST['origin']); $origin = Security::remove_XSS($_REQUEST['origin']);
} else { } else {
@ -71,19 +71,23 @@ if (empty($objExercise)) {
if (!$objExercise) { if (!$objExercise) {
//Redirect to the exercise overview //Redirect to the exercise overview
//Check if the exe_id exists //Check if the exe_id exists
header("Location: overview.php?exerciseId=".$exerciseId); header("Location: overview.php?exerciseId=".$exerciseId.'&'.api_get_cidreq());
exit; exit;
} }
$time_control = false; $time_control = false;
$clock_expired_time = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id); $clock_expired_time = ExerciseLib::get_session_time_control_key(
$objExercise->id,
$learnpath_id,
$learnpath_item_id
);
if ($objExercise->expired_time != 0 && !empty($clock_expired_time)) { if ($objExercise->expired_time != 0 && !empty($clock_expired_time)) {
$time_control = true; $time_control = true;
} }
if ($time_control) { if ($time_control) {
// Get time left for exipiring time // Get time left for expiring time
$time_left = api_strtotime($clock_expired_time, 'UTC') - time(); $time_left = api_strtotime($clock_expired_time, 'UTC') - time();
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css'); $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css'); $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
@ -93,7 +97,6 @@ if ($time_control) {
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left); $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
} }
if (isset($_SESSION['exe_id'])) { if (isset($_SESSION['exe_id'])) {
$exe_id = intval($_SESSION['exe_id']); $exe_id = intval($_SESSION['exe_id']);
} }
@ -132,7 +135,6 @@ if ($time_control) {
} }
echo Display::div('', array('id'=>'message')); echo Display::div('', array('id'=>'message'));
echo '<script> echo '<script>
lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'}); lp_data = $.param({"learnpath_id": '.$learnpath_id.', "learnpath_item_id" : '.$learnpath_item_id.', "learnpath_item_view_id": '.$learnpath_item_view_id.'});
@ -176,7 +178,6 @@ echo '<script>
$attempt_list = Event::getAllExerciseEventByExeId($exe_id); $attempt_list = Event::getAllExerciseEventByExeId($exe_id);
$remind_list = $exercise_stat_info['questions_to_check']; $remind_list = $exercise_stat_info['questions_to_check'];
$remind_list = explode(',', $remind_list); $remind_list = explode(',', $remind_list);
$exercise_result = array(); $exercise_result = array();
foreach ($attempt_list as $question_id => $options) { foreach ($attempt_list as $question_id => $options) {
@ -225,10 +226,13 @@ foreach ($question_list as $questionId) {
$counter++; $counter++;
if ($objExercise->type == ONE_PER_PAGE) { if ($objExercise->type == ONE_PER_PAGE) {
$question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url); $question_title = Display::url(
$question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); $counter.'. '.cut($objQuestionTmp->selectTitle(), 40),
$url
);
$question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
} else { } else {
$question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
} }
//Check if the question doesn't have an answer //Check if the question doesn't have an answer
if (!in_array($questionId, $exercise_result)) { if (!in_array($questionId, $exercise_result)) {

@ -126,7 +126,7 @@ if (isset($_REQUEST['comments']) &&
$_REQUEST['comments'] == 'update' && $_REQUEST['comments'] == 'update' &&
($is_allowedToEdit || $is_tutor || $allowCoachFeedbackExercises) ($is_allowedToEdit || $is_tutor || $allowCoachFeedbackExercises)
) { ) {
//filtered by post-condition // Filtered by post-condition
$id = intval($_GET['exeid']); $id = intval($_GET['exeid']);
$track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id); $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
@ -140,7 +140,6 @@ if (isset($_REQUEST['comments']) &&
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id']; $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$exerciseId = $track_exercise_info['exe_exo_id']; $exerciseId = $track_exercise_info['exe_exo_id'];
$course_info = api_get_course_info(); $course_info = api_get_course_info();
$url = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq().'&show_headers=1&id_session='.$session_id; $url = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq().'&show_headers=1&id_session='.$session_id;
$my_post_info = array(); $my_post_info = array();
@ -281,7 +280,9 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
); );
} }
} else { } else {
$actions .= '<a href="exercise.php">'.Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; $actions .= '<a href="exercise.php">'.
Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).
'</a>';
} }
//Deleting an attempt //Deleting an attempt
@ -326,11 +327,12 @@ if (($is_allowedToEdit || $is_tutor || api_is_coach()) &&
Database::query($sql); Database::query($sql);
} }
Display :: display_header($nameTools); Display :: display_header($nameTools);
// Clean all results for this test before the selected date // Clean all results for this test before the selected date
if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete_before_date']) && $locked == false) { if (($is_allowedToEdit || $is_tutor || api_is_coach()) &&
isset($_GET['delete_before_date']) && $locked == false
) {
// ask for the date // ask for the date
$check = Security::check_token('get'); $check = Security::check_token('get');
if ($check) { if ($check) {
@ -399,15 +401,14 @@ if ($is_allowedToEdit) {
} }
echo $actions; echo $actions;
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results&exerciseId='.$exercise_id.'&filter_by_user='.$filter_user.'&'.api_get_cidreq(); $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results&exerciseId='.$exercise_id.'&filter_by_user='.$filter_user.'&'.api_get_cidreq();
$action_links = ''; $action_links = '';
// Generating group list
//Generating group list
$group_list = GroupManager::get_group_list(); $group_list = GroupManager::get_group_list();
$group_parameters = array('group_all:'.get_lang('All'), 'group_none:'.get_lang('None')); $group_parameters = array(
'group_all:'.get_lang('All'),
'group_none:'.get_lang('None'),
);
foreach ($group_list as $group) { foreach ($group_list as $group) {
$group_parameters[] = $group['id'].':'.$group['name']; $group_parameters[] = $group['id'].':'.$group['name'];

@ -1,21 +1,21 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use \ChamiloSession as Session; use ChamiloSession as Session;
/** /**
* Exercise result * Exercise result
* This script gets information from the script "exercise_submit.php", * This script gets information from the script "exercise_submit.php",
* through the session, and calculates the score of the student for * through the session, and calculates the score of the student for
* that exercise. * that exercise.
* Then it shows the results on the screen. * Then it shows the results on the screen.
* @package chamilo.exercise * @package chamilo.exercise
* @author Olivier Brouckaert, main author * @author Olivier Brouckaert, main author
* @author Roan Embrechts, some refactoring * @author Roan Embrechts, some refactoring
* @author Julio Montoya switchable fill in blank option added * @author Julio Montoya switchable fill in blank option added
* *
* @todo split more code up in functions, move functions to library? * @todo split more code up in functions, move functions to library?
*/ */
$debug = false; $debug = false;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
@ -58,7 +58,7 @@ if (empty($objExercise)) {
$gradebook = ''; $gradebook = '';
if (isset($_SESSION['gradebook'])) { if (isset($_SESSION['gradebook'])) {
$gradebook = $_SESSION['gradebook']; $gradebook = $_SESSION['gradebook'];
} }
if (!empty($gradebook) && $gradebook == 'view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array( $interbreadcrumb[] = array(
@ -79,8 +79,8 @@ $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PA
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>'; $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
// So we are not in learnpath tool // So we are not in learnpath tool
Display::display_header($nameTools, get_lang('Exercise')); Display::display_header($nameTools, get_lang('Exercise'));
} else { } else {
$htmlHeadXtra[] = " $htmlHeadXtra[] = "
<style> <style>
@ -106,7 +106,7 @@ $feedback_type = $objExercise->feedback_type;
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info['data_tracking'])) { if (!empty($exercise_stat_info['data_tracking'])) {
$question_list = explode(',', $exercise_stat_info['data_tracking']); $question_list = explode(',', $exercise_stat_info['data_tracking']);
} }
$learnpath_id = isset($exercise_stat_info['orig_lp_id']) ? $exercise_stat_info['orig_lp_id'] : 0; $learnpath_id = isset($exercise_stat_info['orig_lp_id']) ? $exercise_stat_info['orig_lp_id'] : 0;
@ -115,8 +115,8 @@ $learnpath_item_view_id = isset($exercise_stat_info['orig_lp_item_view_id']) ? $
if ($origin == 'learnpath') { if ($origin == 'learnpath') {
?> ?>
<form method="GET" action="exercise.php?<?php echo api_get_cidreq() ?>"> <form method="GET" action="exercise.php?<?php echo api_get_cidreq() ?>">
<input type="hidden" name="origin" value="<?php echo $origin; ?>" /> <input type="hidden" name="origin" value="<?php echo $origin; ?>" />
<input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" /> <input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
<input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" /> <input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
<input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" /> <input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" />
@ -205,7 +205,7 @@ if ($origin != 'learnpath') {
Session::erase('objExercise'); Session::erase('objExercise');
Session::erase('exe_id'); Session::erase('exe_id');
} }
Display::display_footer(); Display::display_footer();
} else { } else {
$lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null; $lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;
$url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type.'#atoc_'.$learnpath_item_id; $url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type.'#atoc_'.$learnpath_item_id;
@ -218,8 +218,8 @@ if ($origin != 'learnpath') {
Session::write('attempt_remaining', $remainingMessage); Session::write('attempt_remaining', $remainingMessage);
// Record the results in the learning path, using the SCORM interface (API) // Record the results in the learning path, using the SCORM interface (API)
echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>"; echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
echo '<script type="text/javascript">'.$href.'</script>'; echo '<script type="text/javascript">'.$href.'</script>';
echo '</body></html>'; echo '</body></html>';
} }

@ -136,8 +136,6 @@ if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook')); $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
} }
$fromlink = '';
$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises')); $interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'));
$interbreadcrumb[] = array("url" => "overview.php?exerciseId=".$exercise_id.'&'.api_get_cidreq(), "name" => $objExercise->name); $interbreadcrumb[] = array("url" => "overview.php?exerciseId=".$exercise_id.'&'.api_get_cidreq(), "name" => $objExercise->name);
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result')); $interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result'));
@ -895,7 +893,6 @@ if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress
'details' => 'true', 'details' => 'true',
'course' => Security::remove_XSS($_GET['cidReq']) 'course' => Security::remove_XSS($_GET['cidReq'])
]); ]);
$formUrl .= $fromlink;
$emailForm = new FormValidator('myform', 'post', $formUrl, '', ['id' => 'myform']); $emailForm = new FormValidator('myform', 'post', $formUrl, '', ['id' => 'myform']);
$emailForm->addHidden('lp_item_id', $learnpath_id); $emailForm->addHidden('lp_item_id', $learnpath_id);
@ -950,7 +947,6 @@ if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress
); );
echo $emailForm->returnForm(); echo $emailForm->returnForm();
} }
//Came from lpstats in a lp //Came from lpstats in a lp
@ -995,7 +991,7 @@ if ($origin != 'learnpath') {
// Destroying the session // Destroying the session
Session::erase('questionList'); Session::erase('questionList');
unset ($questionList); unset($questionList);
Session::erase('exerciseResult'); Session::erase('exerciseResult');
unset ($exerciseResult); unset($exerciseResult);

@ -2,11 +2,11 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* File containing the FreeAnswer class. * File containing the FreeAnswer class.
* This class allows to instantiate an object of type FREE_ANSWER, * This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question * extending the class question
* @package chamilo.exercise * @package chamilo.exercise
* @author Eric Marguin * @author Eric Marguin
*/ */
class FreeAnswer extends Question class FreeAnswer extends Question
{ {

Loading…
Cancel
Save