diff --git a/public/main/exercise/answer.class.php b/public/main/exercise/answer.class.php
index d49ef074c8..4fabe9b84a 100644
--- a/public/main/exercise/answer.class.php
+++ b/public/main/exercise/answer.class.php
@@ -830,14 +830,11 @@ class Answer
$fixed_list = [];
$tableAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
- if (MULTIPLE_ANSWER_TRUE_FALSE == self::getQuestionType() ||
- MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY == self::getQuestionType()
+ if (MULTIPLE_ANSWER_TRUE_FALSE === self::getQuestionType() ||
+ MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY === self::getQuestionType()
) {
// Selecting origin options
- $origin_options = Question::readQuestionOption(
- $this->selectQuestionId(),
- $this->course['real_id']
- );
+ $origin_options = Question::readQuestionOption($this->selectQuestionId(), $this->course['real_id']);
if (!empty($origin_options)) {
foreach ($origin_options as $item) {
@@ -845,10 +842,7 @@ class Answer
}
}
- $destination_options = Question::readQuestionOption(
- $newQuestionId,
- $course_info['real_id']
- );
+ $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']);
$i = 0;
if (!empty($destination_options)) {
foreach ($destination_options as $item) {
@@ -858,6 +852,8 @@ class Answer
}
}
+ $repo = Container::getQuestionRepository();
+
// if at least one answer
if ($this->nbrAnswers) {
// inserts new answers into data base
@@ -903,9 +899,11 @@ class Answer
);
}
+ $question = $repo->find($newQuestionId);
+
$quizAnswer = new CQuizAnswer();
$quizAnswer
- ->setQuestionId($newQuestionId)
+ ->setQuestion($question)
->setAnswer($answer['answer'])
->setCorrect($answer['correct'])
->setComment($answer['comment'])
@@ -950,9 +948,10 @@ class Answer
$correct = $fixed_list[(int) $correct];
}
+ $question = $repo->find($newQuestionId);
$quizAnswer = new CQuizAnswer();
$quizAnswer
- ->setQuestionId($newQuestionId)
+ ->setQuestion($question)
->setAnswer($this->answer[$i])
->setCorrect($correct)
->setComment($this->comment[$i])
diff --git a/public/main/exercise/fill_blanks.class.php b/public/main/exercise/fill_blanks.class.php
index 9f142ca375..dff7288b89 100644
--- a/public/main/exercise/fill_blanks.class.php
+++ b/public/main/exercise/fill_blanks.class.php
@@ -781,7 +781,7 @@ class FillBlanks extends Question
$blankCharEnd = self::getEndSeparator($blankSeparatorNumber);
$blankCharStartForRegexp = self::escapeForRegexp($blankCharStart);
$blankCharEndForRegexp = self::escapeForRegexp($blankCharEnd);
-
+ $listWords = [];
// Get all blanks words
$listAnswerResults['words_count'] = api_preg_match_all(
'/'.$blankCharStartForRegexp.'[^'.$blankCharEndForRegexp.']*'.$blankCharEndForRegexp.'/',
diff --git a/public/main/exercise/question.class.php b/public/main/exercise/question.class.php
index 6f5ccf10c8..2d8e7f17e1 100644
--- a/public/main/exercise/question.class.php
+++ b/public/main/exercise/question.class.php
@@ -163,7 +163,7 @@ abstract class Question
if ($object = Database::fetch_object($result)) {
$objQuestion = self::getInstance($object->type);
if (!empty($objQuestion)) {
- $objQuestion->id = (int) $id;
+ $objQuestion->id = $id;
$objQuestion->iid = (int) $object->iid;
$objQuestion->question = $object->question;
$objQuestion->description = $object->description;
@@ -426,7 +426,7 @@ abstract class Question
* delete any category entry for question id
* delete the category for question
*
- * @deprecated
+ * @todo Check if deprecated
*
* @return bool
*/
@@ -1063,7 +1063,6 @@ abstract class Question
$question = new CQuizQuestion();
$question
- ->setCId($course_id)
->setQuestion($questionText)
->setDescription($description)
->setPonderation($this->weighting)
@@ -1073,9 +1072,7 @@ abstract class Question
->setLevel($this->level)
->setFeedback($this->feedback)
->setParent($courseEntity)
- ->addCourseLink(
- $courseEntity
- )
+ ->addCourseLink($courseEntity)
;
$em->persist($question);
@@ -1288,7 +1285,7 @@ abstract class Question
);
if (MEDIA_QUESTION != $this->type) {
- // Advanced parameters
+ // Advanced parameters.
$form->addElement(
'select',
'questionLevel',
@@ -1296,8 +1293,7 @@ abstract class Question
self::get_default_levels()
);
- // Categories
-
+ // Categories.
$form->addElement(
'select',
'questionCategory',
@@ -1313,8 +1309,8 @@ abstract class Question
);
}
- global $text;
-
+ //global $text;
+ $text = get_lang('Save the question');
switch ($this->type) {
case UNIQUE_ANSWER:
$buttonGroup = [];
@@ -1755,10 +1751,13 @@ abstract class Question
['class' => 'question_description']
);
} else {
- if (true == $score['pass']) {
+ /** @var ReadingComprehension $this */
+ if (true === $score['pass']) {
$message = Display::div(
sprintf(
- get_lang('Congratulations, you have reached and correctly understood, at a speed of %s words per minute, a text of a total %s words.'),
+ get_lang(
+ 'Congratulations, you have reached and correctly understood, at a speed of %s words per minute, a text of a total %s words.'
+ ),
ReadingComprehension::$speeds[$this->level],
$this->getWordsCount()
)
@@ -1766,7 +1765,9 @@ abstract class Question
} else {
$message = Display::div(
sprintf(
- get_lang('Sorry, it seems like a speed of %s words/minute was too fast for this text of %s words.'),
+ get_lang(
+ 'Sorry, it seems like a speed of %s words/minute was too fast for this text of %s words.'
+ ),
ReadingComprehension::$speeds[$this->level],
$this->getWordsCount()
)
diff --git a/public/main/lp/learnpath.class.php b/public/main/lp/learnpath.class.php
index 33252ddf94..6aed867853 100644
--- a/public/main/lp/learnpath.class.php
+++ b/public/main/lp/learnpath.class.php
@@ -6609,7 +6609,7 @@ class learnpath
$course_id = api_get_course_int_id();
$return = '';
- if (empty($lpItem)) {
+ if (null === $lpItem) {
return '';
}
$item_id = $lpItem->getIid();
diff --git a/public/main/lp/lp_upload.php b/public/main/lp/lp_upload.php
index d9adf7f50d..0f9d36e96a 100644
--- a/public/main/lp/lp_upload.php
+++ b/public/main/lp/lp_upload.php
@@ -121,14 +121,12 @@ if (isset($_POST) && $is_error) {
$em->flush();
break;
case 'oogie':
- require_once 'openoffice_presentation.class.php';
$take_slide_name = empty($_POST['take_slide_name']) ? false : true;
$o_ppt = new OpenofficePresentation($take_slide_name);
$first_item_id = $o_ppt->convert_document($_FILES['user_file'], 'make_lp', $_POST['slide_size']);
Display::addFlash(Display::return_message(get_lang('File upload succeeded!')));
break;
case 'woogie':
- require_once 'openoffice_text.class.php';
$split_steps = empty($_POST['split_steps']) || 'per_page' === $_POST['split_steps'] ? 'per_page' : 'per_chapter';
$o_doc = new OpenofficeText($split_steps);
$first_item_id = $o_doc->convert_document($_FILES['user_file']);
diff --git a/public/main/lp/lp_view.php b/public/main/lp/lp_view.php
index 15ed8724a6..9dda0765a0 100644
--- a/public/main/lp/lp_view.php
+++ b/public/main/lp/lp_view.php
@@ -37,10 +37,8 @@ $session = api_get_session_entity($sessionId);
$lpRepo = Container::getLpRepository();
/** @var learnpath $lp */
-//$oLP = Session::read('oLP');
+$oLP = Session::read('oLP');
/** @var CLp $lp */
-$lp = $lp;
-
// Check if the learning path is visible for student - (LP requisites)
if (!api_is_platform_admin()) {
if (!api_is_allowed_to_edit(null, true, false, false) &&
@@ -76,11 +74,7 @@ if (!$is_allowed_to_edit) {
}
}
- $isVisible = learnpath::categoryIsVisibleForStudent(
- $category,
- $user
- );
-
+ $isVisible = learnpath::categoryIsVisibleForStudent($category, $user, $course, $session);
if ($isVisible) {
$block = false;
}
@@ -101,7 +95,7 @@ var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\';
-->
';
-$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = '';
$htmlHeadXtra[] = '';
+ $htmlHeadXtra[] = '';
$preReqCheck = $oLP->prerequisites_match($lp_item_id);
if (true === $preReqCheck) {
$src = $oLP->get_link('http', $lp_item_id, $get_toc_list);
@@ -267,7 +261,7 @@ if (!isset($src)) {
break;
case CLp::AICC_TYPE:
$oLP->stop_previous_item(); // save status manually if asset
- $htmlHeadXtra[] = '';
+ $htmlHeadXtra[] = '';
$preReqCheck = $oLP->prerequisites_match($lp_item_id);
if (true === $preReqCheck) {
$src = $oLP->get_link(
@@ -290,9 +284,9 @@ $autostart = 'true';
if ($debug) {
error_log('$type_quiz: '.$type_quiz);
- error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId'] ?? 0));
+ error_log('$_REQUEST[exeId]: '.(int) ($_REQUEST['exeId'] ?? 0));
error_log('$lp_id: '.$lp_id);
- error_log('$_REQUEST[lp_item_id]: '.intval($_REQUEST['lp_item_id'] ?? 0));
+ error_log('$_REQUEST[lp_item_id]: '.(int) ($_REQUEST['lp_item_id'] ?? 0));
}
if (!empty($_REQUEST['exeId']) &&
@@ -325,8 +319,8 @@ $oLP->set_previous_item($lp_item_id);
$nameTools = Security::remove_XSS($oLP->get_name());
$save_setting = api_get_setting('show_navigation_menu');
-global $_setting;
-$_setting['show_navigation_menu'] = 'false';
+/*global $_setting;
+$_setting['show_navigation_menu'] = 'false';*/
$scorm_css_header = true;
$lp_theme_css = $oLP->get_theme();
// Sets the css theme of the LP this call is also use at the frames (toc, nav, message).
@@ -578,7 +572,7 @@ $template->assign('frame_ready', $frameReady);
$template->displayTemplate('@ChamiloCore/LearnPath/view.html.twig');
// Restore a global setting.
-$_setting['show_navigation_menu'] = $save_setting;
+//$_setting['show_navigation_menu'] = $save_setting;
//Session::write('oLP', $lp);
diff --git a/public/main/lp/openoffice_document.class.php b/public/main/lp/openoffice_document.class.php
index 84b7fb0169..9f508903f5 100644
--- a/public/main/lp/openoffice_document.class.php
+++ b/public/main/lp/openoffice_document.class.php
@@ -100,7 +100,7 @@ abstract class OpenofficeDocument extends learnpath
$ppt2lp_host = api_get_setting('service_ppt2lp', 'host');
- if ('localhost' == $ppt2lp_host) {
+ if ('localhost' === $ppt2lp_host) {
move_uploaded_file($file['tmp_name'], $this->base_work_dir.'/'.$this->file_path);
//var_dump( $this->base_work_dir.$this->created_dir.$this->file_path);
$perm = api_get_setting('permissions_for_new_files');
diff --git a/public/main/lp/openoffice_presentation.class.php b/public/main/lp/openoffice_presentation.class.php
index 0642df28ac..d5677445cb 100644
--- a/public/main/lp/openoffice_presentation.class.php
+++ b/public/main/lp/openoffice_presentation.class.php
@@ -10,11 +10,6 @@
* @license GNU/GPL
*/
-/**
- * Defines the "OpenofficePresentation" child of class "OpenofficeDocument".
- */
-require_once 'openoffice_document.class.php';
-
class OpenofficePresentation extends OpenofficeDocument
{
public $take_slide_name;
diff --git a/public/main/lp/openoffice_text.class.php b/public/main/lp/openoffice_text.class.php
index 1b3cb8fa62..f63b761e02 100644
--- a/public/main/lp/openoffice_text.class.php
+++ b/public/main/lp/openoffice_text.class.php
@@ -13,8 +13,6 @@
/**
* Defines the "OpenofficeText" child of class "learnpath".
*/
-require_once 'openoffice_document.class.php';
-
class OpenofficeText extends OpenofficeDocument
{
public $split_steps;
diff --git a/public/main/lp/openoffice_text_document.class.php b/public/main/lp/openoffice_text_document.class.php
index 1c56668743..e002ea18df 100644
--- a/public/main/lp/openoffice_text_document.class.php
+++ b/public/main/lp/openoffice_text_document.class.php
@@ -12,8 +12,6 @@
/**
* Defines the "OpenOfficeTextDocument" child of class "learnpath".
*/
-require_once 'openoffice_document.class.php';
-
class OpenOfficeTextDocument extends OpenofficeDocument
{
public $split_steps;
diff --git a/public/main/lp/readout_text.php b/public/main/lp/readout_text.php
index 77beef2291..f5acffa250 100644
--- a/public/main/lp/readout_text.php
+++ b/public/main/lp/readout_text.php
@@ -1,6 +1,7 @@
getRepository('ChamiloCourseBundle:CDocument');
+$documentRepo = Container::getDocumentRepository();
// This page can only be shown from inside a learning path
if (!$id && !$lpId) {
@@ -31,23 +32,18 @@ if (!$id && !$lpId) {
}
/** @var CDocument $document */
-$document = $documentRepo->findOneBy(['cId' => $courseId, 'iid' => $id]);
+$document = $documentRepo->find($id);
-if (empty($document)) {
- // Try with normal id
- /** @var CDocument $document */
- $document = $documentRepo->findOneBy(['cId' => $courseId, 'id' => $id]);
-
- if (empty($document)) {
- Display::return_message(get_lang('The file was not found'), 'error');
- exit;
- }
+if (null === $document) {
+ Display::return_message(get_lang('The file was not found'), 'error');
+ exit;
}
-$documentPathInfo = pathinfo($document->getPath());
+$documentText = $documentRepo->getResourceFileContent($document);
+/*$documentPathInfo = pathinfo($document->getPath());
$coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['directory'];
$documentPath = '/document'.$document->getPath();
-$documentText = file_get_contents($coursePath.$documentPath);
+$documentText = file_get_contents($coursePath.$documentPath);*/
$documentText = api_remove_tags_with_space($documentText);
$wordsInfo = preg_split('/ |\n/', $documentText, -1, PREG_SPLIT_OFFSET_CAPTURE);
diff --git a/public/main/lp/scorm.class.php b/public/main/lp/scorm.class.php
index 593f6375d2..89c4e01102 100644
--- a/public/main/lp/scorm.class.php
+++ b/public/main/lp/scorm.class.php
@@ -96,7 +96,7 @@ class scorm extends learnpath
if (!empty($xmlErrors)) {
if ($this->debug > 0) {
- error_log('In scorm::parse_manifest() - Exception thrown when loading '.$file.' in DOMDocument');
+ error_log('In scorm::parse_manifest() - Exception thrown when loading DOMDocument');
}
// Throw exception?
return null;
@@ -356,7 +356,6 @@ class scorm extends learnpath
$myname = api_utf8_decode($oOrganization->get_name());
$lp = new CLp();
$lp
- ->setCId($courseId)
->setLpType(CLp::SCORM_TYPE)
->setName($myname)
->setRef($oOrganization->get_ref())
@@ -366,7 +365,6 @@ class scorm extends learnpath
->setDisplayOrder($dsp)
->setUseMaxScore($userMaxScore)
->setAsset($this->asset)
- ->setSessionId($sessionId)
->setParent($courseEntity)
->addCourseLink($courseEntity, api_get_session_entity())
;
diff --git a/public/main/lp/scorm_api.php b/public/main/lp/scorm_api.php
index 9b1e071dd5..ced295fa80 100644
--- a/public/main/lp/scorm_api.php
+++ b/public/main/lp/scorm_api.php
@@ -27,8 +27,8 @@ $use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php';
/** @var learnpath $oLP */
-//$oLP = UnserializeApi::unserialize('lp', Session::read('lpobject'));
$oLP = Session::read('oLP');
+//$oLP = UnserializeApi::unserialize('lp', Session::read('lpobject'));
if (!is_object($oLP)) {
error_log('New LP - scorm_api - Could not load oLP object', 0);
exit;
diff --git a/public/main/survey/surveyUtil.class.php b/public/main/survey/surveyUtil.class.php
index d091f06182..8d3d6724dd 100644
--- a/public/main/survey/surveyUtil.class.php
+++ b/public/main/survey/surveyUtil.class.php
@@ -73,7 +73,6 @@ class SurveyUtil
$table = Database::get_course_table(TABLE_SURVEY_ANSWER);
$sql = "DELETE FROM $table
WHERE
- c_id = $course_id AND
user = '".Database::escape_string($user)."' AND
survey_id = '".intval($survey_id)."' AND
question_id = '".intval($question_id)."'";
@@ -110,9 +109,6 @@ class SurveyUtil
return false;
}
- // Table definition
- $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
-
// Make the survey anonymous
if (1 == $survey_data['anonymous']) {
$surveyUser = Session::read('surveyuser');
@@ -130,7 +126,6 @@ class SurveyUtil
$answer = new CSurveyAnswer();
$answer
- ->setCId($survey_data['c_id'])
->setUser($user)
->setSurveyId($survey_id)
->setQuestionId($question_id)
@@ -649,7 +644,6 @@ class SurveyUtil
// Getting the question information
$sql = "SELECT * FROM $table_survey_question
WHERE
- c_id = $course_id AND
survey_id = $surveyId AND
survey_question NOT LIKE '%{{%' AND
type <>'pagebreak'
diff --git a/src/CoreBundle/Traits/Repository/ORM/TreeRepositoryTrait.php b/src/CoreBundle/Traits/Repository/ORM/TreeRepositoryTrait.php
index 84c2e59b93..27e0bd5499 100644
--- a/src/CoreBundle/Traits/Repository/ORM/TreeRepositoryTrait.php
+++ b/src/CoreBundle/Traits/Repository/ORM/TreeRepositoryTrait.php
@@ -94,8 +94,6 @@ trait TreeRepositoryTrait
* Sets the RepositoryUtilsInterface instance
*
* @param \Gedmo\Tree\RepositoryUtilsInterface $repoUtils
- *
- * @return static
*/
public function setRepoUtils(RepositoryUtilsInterface $repoUtils)
{