Minor format code.

1.9.x
Julio Montoya 12 years ago
parent 83db859690
commit 0b33a18966
  1. 25
      main/exercice/exercise.class.php
  2. 36
      main/exercice/fill_blanks.class.php

@ -2283,7 +2283,8 @@ class Exercise
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;
$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'];
@ -2315,7 +2316,8 @@ class Exercise
break;
case MULTIPLE_ANSWER_COMBINATION:
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);
while ($row = Database::fetch_array($resultans)) {
$ind = $row['answer'];
@ -3787,34 +3789,40 @@ class Exercise
$lp_item_view_id = 0,
$filter_by_admin = true
) {
//1. By default the exercise is visible
// 1. By default the exercise is visible
$is_visible = true;
$message = null;
//1.1 Admins and teachers can access to the exercise
// 1.1 Admins and teachers can access to the exercise
if ($filter_by_admin) {
if (api_is_platform_admin() || api_is_course_admin()) {
return array('value' => true, 'message' => '');
}
}
//Checking visibility in the item_property table
// Checking visibility in the item_property table.
$visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id());
if ($visibility == 0) {
$this->active = 0;
}
//2. If the exercise is not active
// 2. If the exercise is not active.
if (empty($lp_id)) {
//2.1 LP is OFF
if ($this->active == 0) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
return array(
'value' => false,
'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false)
);
}
} else {
//2.1 LP is loaded
if ($this->active == 0 AND !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
return array(
'value' => false,
'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false)
);
}
}
@ -3851,6 +3859,7 @@ class Exercise
// 4. We check if the student have attempts
$exerciseAttempts = $this->selectAttempts();
if ($is_visible) {
if ($exerciseAttempts > 0) {

@ -1,21 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File containing the FillBlanks class.
* @package chamilo.exercise
* @author Eric Marguin
* @author Julio Montoya Armas switchable fill in blank option added
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/**
* Code
*/
/**
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER
* (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
* Class FillBlanks
*
* @author Eric Marguin
* @author Julio Montoya multiple fill in blank option added
@ -37,7 +24,7 @@ class FillBlanks extends Question
}
/**
* function which redifines Question::createAnswersForm
* function which redefines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm($form)
@ -164,17 +151,17 @@ class FillBlanks extends Question
$answer = $form->getSubmitValue('answer');
//remove the :: eventually written by the user
$answer = str_replace('::','',$answer);
$answer = str_replace('::', '', $answer);
// get the blanks weightings
$nb = preg_match_all('/\[[^\]]*\]/', $answer, $blanks);
if (isset($_GET['editQuestion'])) {
$this -> weighting = 0;
$this ->weighting = 0;
}
if ($nb>0) {
if ($nb > 0) {
$answer .= '::';
for($i=0 ; $i<$nb ; ++$i) {
for ($i=0 ; $i < $nb; ++$i) {
$blankItem = $blanks[0][$i];
$replace = array("[", "]");
$newBlankItem = str_replace($replace, "", $blankItem);
@ -183,12 +170,11 @@ class FillBlanks extends Question
$answer .= $form->getSubmitValue('weighting['.$i.']').',';
$this -> weighting += $form->getSubmitValue('weighting['.$i.']');
}
$answer = api_substr($answer,0,-1);
$answer = api_substr($answer, 0, -1);
}
$is_multiple = $form->getSubmitValue('multiple_answer');
$answer.='@'.$is_multiple;
$answer.= '@'.$is_multiple;
$this->save();
$objAnswer = new answer($this->id);
@ -196,6 +182,12 @@ class FillBlanks extends Question
$objAnswer->save();
}
/**
* @param null $feedback_type
* @param null $counter
* @param null $score
* @return null|string
*/
function return_header($feedback_type = null, $counter = null, $score = null)
{
$header = parent::return_header($feedback_type, $counter, $score);

Loading…
Cancel
Save