Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
pull/2487/head
Scrutinizer Auto-Fixer 9 years ago
parent 41906da056
commit e4fb96b1e4
  1. 108
      main/exercise/question.class.php
  2. 2
      src/Chamilo/CourseBundle/Component/CourseCopy/Course.php
  3. 2
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php

@ -22,7 +22,7 @@ abstract class Question
public $type;
public $level;
public $picture;
public $exerciseList; // array with the list of exercises which this question is in
public $exerciseList; // array with the list of exercises which this question is in
public $category_list;
public $parent_id;
public $category;
@ -47,8 +47,8 @@ abstract class Question
'multiple_answer_combination_true_false.class.php',
'MultipleAnswerCombinationTrueFalse'
),
GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'),
GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php', 'GlobalMultipleAnswer'),
CALCULATED_ANSWER => array('calculated_answer.class.php', 'CalculatedAnswer'),
UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'],
DRAGGABLE => ['Draggable.php', 'Draggable'],
MATCHING_DRAGGABLE => ['MatchingDraggable.php', 'MatchingDraggable'],
@ -108,7 +108,7 @@ abstract class Question
$id = intval($id);
if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
$course_info = api_get_course_info_by_id($course_id);
} else {
$course_info = api_get_course_info();
}
@ -360,7 +360,7 @@ abstract class Question
*/
public function updateTitle($title)
{
$this->question=$title;
$this->question = $title;
}
/**
@ -459,7 +459,7 @@ abstract class Question
// DO nothing
} else {
$sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id)
VALUES (" . api_get_course_int_id() . ", $question_id, $category_id)";
VALUES (".api_get_course_int_id().", $question_id, $category_id)";
Database::query($sql);
}
}
@ -485,7 +485,7 @@ abstract class Question
$sql = "SELECT count(*) AS nb FROM $table
WHERE
question_id = $question_id AND
c_id=" . api_get_course_int_id();
c_id=".api_get_course_int_id();
$res = Database::query($sql);
$row = Database::fetch_array($res);
if ($row['nb'] > 0) {
@ -493,11 +493,11 @@ abstract class Question
SET category_id = $category_id
WHERE
question_id = $question_id AND
c_id = " . api_get_course_int_id();
c_id = ".api_get_course_int_id();
Database::query($sql);
} else {
$sql = "INSERT INTO $table (c_id, question_id, category_id)
VALUES (" . api_get_course_int_id().", $question_id, $category_id)";
VALUES (".api_get_course_int_id().", $question_id, $category_id)";
Database::query($sql);
}
}
@ -515,7 +515,7 @@ abstract class Question
$sql = "DELETE FROM $table
WHERE
question_id = $question_id AND
c_id = " . api_get_course_int_id();
c_id = ".api_get_course_int_id();
Database::query($sql);
}
@ -568,11 +568,11 @@ abstract class Question
) {
// removes old answers
$sql = "DELETE FROM $TBL_REPONSES
WHERE c_id = $course_id AND question_id = " . intval($this->id);
WHERE c_id = $course_id AND question_id = ".intval($this->id);
Database::query($sql);
}
$this->type=$type;
$this->type = $type;
}
}
@ -687,7 +687,7 @@ abstract class Question
// if the question has an ID
if ($this->id) {
// Get dimensions from current image.
$my_image = new Image($picturePath . '/' . $this->picture);
$my_image = new Image($picturePath.'/'.$this->picture);
$current_image_size = $my_image->get_image_size();
$current_width = $current_image_size['width'];
@ -728,7 +728,7 @@ abstract class Question
}
$my_image->resize($new_width, $new_height);
$result = $my_image->send_image($picturePath . '/' . $this->picture);
$result = $my_image->send_image($picturePath.'/'.$this->picture);
if ($result) {
return true;
@ -753,7 +753,7 @@ abstract class Question
$picture = $this->picture;
$this->picture = '';
return @unlink($picturePath . '/' . $picture) ? true : false;
return @unlink($picturePath.'/'.$picture) ? true : false;
}
return false;
@ -770,27 +770,27 @@ abstract class Question
{
$course_id = $course_info['real_id'];
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$destination_path = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/images';
$source_path = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . '/document/images';
$destination_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images';
$source_path = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images';
// if the question has got an ID and if the picture exists
if ($this->id && !empty($this->picture)) {
$picture = explode('.', $this->picture);
$extension = $picture[sizeof($picture) - 1];
$picture = 'quiz-' . $questionId . '.' . $extension;
$result = @copy($source_path . '/' . $this->picture, $destination_path . '/' . $picture) ? true : false;
$picture = 'quiz-'.$questionId.'.'.$extension;
$result = @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture) ? true : false;
// If copy was correct then add to the database
if ($result) {
$sql = "UPDATE $TBL_QUESTIONS SET
picture = '" . Database::escape_string($picture) . "'
WHERE c_id = $course_id AND id='" . intval($questionId) . "'";
picture = '".Database::escape_string($picture)."'
WHERE c_id = $course_id AND id='".intval($questionId)."'";
Database::query($sql);
$document_id = add_document(
$course_info,
'/images/' . $picture,
'/images/'.$picture,
'file',
filesize($destination_path . '/' . $picture),
filesize($destination_path.'/'.$picture),
$picture
);
if ($document_id) {
@ -825,7 +825,7 @@ abstract class Question
$Extension = $pictureName[sizeof($pictureName) - 1];
// saves the picture into a temporary file
@move_uploaded_file($picture, $picturePath . '/tmp.' . $Extension);
@move_uploaded_file($picture, $picturePath.'/tmp.'.$Extension);
}
/**
@ -916,12 +916,12 @@ abstract class Question
$TBL_EXERCISE_QUESTION as test_question
WHERE
question.id = test_question.question_id AND
test_question.exercice_id = " . intval($exerciseId) . " AND
test_question.exercice_id = ".intval($exerciseId)." AND
question.c_id = $c_id AND
test_question.c_id = $c_id ";
$result = Database::query($sql);
$current_position = Database::result($result, 0, 0);
$this->updatePosition($current_position+1);
$this->updatePosition($current_position + 1);
$position = $this->position;
$params = [
@ -1029,7 +1029,7 @@ abstract class Question
$rmQs = false
) {
// update search engine and its values table if enabled
if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
$course_id = api_get_course_id();
// get search_did
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
@ -1047,8 +1047,8 @@ abstract class Question
$res = Database::query($sql);
if (Database::num_rows($res) > 0 || $addQs) {
require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
$di = new ChamiloIndexer();
if ($addQs) {
@ -1061,7 +1061,7 @@ abstract class Question
// retrieve others exercise ids
$se_ref = Database::fetch_array($res);
$se_doc = $di->get_document((int)$se_ref['search_did']);
$se_doc = $di->get_document((int) $se_ref['search_did']);
if ($se_doc !== false) {
if (($se_doc_data = $di->get_document_data($se_doc)) !== FALSE) {
$se_doc_data = unserialize($se_doc_data);
@ -1099,16 +1099,16 @@ abstract class Question
SE_DATA => array(
'type' => SE_DOCTYPE_EXERCISE_QUESTION,
'exercise_ids' => $question_exercises,
'question_id' => (int)$this->id
'question_id' => (int) $this->id
),
SE_USER => (int)api_get_user_id(),
SE_USER => (int) api_get_user_id(),
);
$ic_slide->xapian_data = serialize($xapian_data);
$ic_slide->addValue("content", $this->description);
//TODO: index answers, see also form validation on question_admin.inc.php
$di->remove_document((int)$se_ref['search_did']);
$di->remove_document((int) $se_ref['search_did']);
$di->addChunk($ic_slide);
//index and return search engine document id
@ -1187,7 +1187,7 @@ abstract class Question
$count = $new_exercise->selectNbrQuestions();
$count++;
$sql = "INSERT INTO $exerciseRelQuestionTable (c_id, question_id, exercice_id, question_order)
VALUES ({$this->course['real_id']}, " . intval($id) . ", " . intval($exerciseId) . ", '$count')";
VALUES ({$this->course['real_id']}, ".intval($id).", ".intval($exerciseId).", '$count')";
Database::query($sql);
// we do not want to reindex if we had just saved adnd indexed the question
@ -1224,17 +1224,17 @@ abstract class Question
FROM $TBL_EXERCISE_QUESTION
WHERE
c_id = $course_id
AND question_id = " . intval($id) . "
AND question_id = ".intval($id)."
AND exercice_id = " . intval($exerciseId);
$res = Database::query($sql);
if (Database::num_rows($res)>0) {
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);
if (!empty($row['question_order'])) {
$sql = "UPDATE $TBL_EXERCISE_QUESTION
SET question_order = question_order-1
WHERE
c_id = $course_id
AND exercice_id = " . intval($exerciseId) . "
AND exercice_id = ".intval($exerciseId)."
AND question_order > " . $row['question_order'];
Database::query($sql);
}
@ -1243,7 +1243,7 @@ abstract class Question
$sql = "DELETE FROM $TBL_EXERCISE_QUESTION
WHERE
c_id = $course_id
AND question_id = " . intval($id) . "
AND question_id = ".intval($id)."
AND exercice_id = " . intval($exerciseId);
Database::query($sql);
@ -1284,7 +1284,7 @@ abstract class Question
SET question_order = question_order-1
WHERE
c_id= $course_id
AND exercice_id = " . intval($row['exercice_id']) . "
AND exercice_id = ".intval($row['exercice_id'])."
AND question_order > " . $row['question_order'];
Database::query($sql);
}
@ -1292,22 +1292,22 @@ abstract class Question
}
$sql = "DELETE FROM $TBL_EXERCISE_QUESTION
WHERE c_id = $course_id AND question_id = " . $id;
WHERE c_id = $course_id AND question_id = ".$id;
Database::query($sql);
$sql = "DELETE FROM $TBL_QUESTIONS
WHERE c_id = $course_id AND id = " . $id;
WHERE c_id = $course_id AND id = ".$id;
Database::query($sql);
$sql = "DELETE FROM $TBL_REPONSES
WHERE c_id = $course_id AND question_id = " . $id;
WHERE c_id = $course_id AND question_id = ".$id;
Database::query($sql);
// remove the category of this question in the question_rel_category table
$sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY
WHERE
c_id = $course_id AND
question_id = " . $id;
question_id = ".$id;
Database::query($sql);
api_item_property_update(
@ -1476,7 +1476,7 @@ abstract class Question
if (class_exists($class_name)) {
return new $class_name();
} else {
echo 'Can\'t instanciate class ' . $class_name . ' of type ' . $type;
echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
}
}
}
@ -1660,7 +1660,7 @@ abstract class Question
if ($feedback_type == 1) {
//2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
$question_type_custom_list = array (
$question_type_custom_list = array(
UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],
HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]
);
@ -1676,14 +1676,14 @@ abstract class Question
require_once $a_type[0];
// get the picture of the type and the langvar which describes it
$img = $explanation = '';
eval('$img = ' . $a_type[1] . '::$typePicture;');
eval('$explanation = get_lang(' . $a_type[1] . '::$explanationLangVar);');
eval('$img = '.$a_type[1].'::$typePicture;');
eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);');
echo '<li>';
echo '<div class="icon-image">';
$icon = '<a href="admin.php?' . api_get_cidreq() . '&newQuestion=yes&answerType=' . $i . '">' .
Display::return_icon($img, $explanation, null, ICON_SIZE_BIG) . '</a>';
$icon = '<a href="admin.php?'.api_get_cidreq().'&newQuestion=yes&answerType='.$i.'">'.
Display::return_icon($img, $explanation, null, ICON_SIZE_BIG).'</a>';
if ($objExercise->force_edit_exercise_in_lp === false) {
if ($objExercise->exercise_was_added_in_lp == true) {
@ -1704,9 +1704,9 @@ abstract class Question
echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
} else {
if ($feedback_type == 1) {
echo $url = "<a href=\"question_pool.php?" . api_get_cidreq() . "&type=1&fromExercise=$exerciseId\">";
echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">";
} else {
echo $url = '<a href="question_pool.php?' . api_get_cidreq() . '&fromExercise=' . $exerciseId . '">';
echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">';
}
echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
}
@ -1839,7 +1839,7 @@ abstract class Question
$header .= $this->show_media_content();
}
$header .= Display::page_subheader2($counter_label . ". " . $question_title);
$header .= Display::page_subheader2($counter_label.". ".$question_title);
$header .= Display::div(
"<div class=\"rib rib-$class\"><h3>$score_label</h3></div> <h4>{$score['result']}</h4>",
array('class' => 'ribbon')
@ -1930,8 +1930,8 @@ abstract class Question
require_once $tabQuestionList[$type][0];
$img = $explanation = null;
eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;');
eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);');
eval('$img = '.$tabQuestionList[$type][1].'::$typePicture;');
eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);');
return array($img, $explanation);
}

@ -67,7 +67,7 @@ class Course
* @param int $resource_type Check if this course has resources of the
* given type. If no type is given, check if course has resources of any
* type.
* @return int
* @return boolean
*/
public function has_resources($resource_type = null)
{

@ -549,7 +549,7 @@ class CourseRecycler
if (trim($learnpath->path) != '') {
// when $learnpath->path value is incorrect for some reason.
// The directory trat contains files of the SCORM package is to be deleted.
$scorm_package_dir = realpath($this->course->path . 'scorm/' . $learnpath->path);
$scorm_package_dir = realpath($this->course->path.'scorm/'.$learnpath->path);
rmdirr($scorm_package_dir);
}
}

Loading…
Cancel
Save