diff --git a/main/inc/ajax/work.ajax.php b/main/inc/ajax/work.ajax.php index 20c542b0a9..6243483b8c 100755 --- a/main/inc/ajax/work.ajax.php +++ b/main/inc/ajax/work.ajax.php @@ -151,13 +151,10 @@ switch ($action) { api_protect_course_script(true); // User access same as upload.php $is_allowed_to_edit = api_is_allowed_to_edit(null, true); - $itemId = isset($_GET['item_id']) ? intval($_GET['item_id']) : ''; - + $itemId = isset($_GET['item_id']) ? (int) $_GET['item_id'] : ''; $result = []; - if (!empty($_FILES) && !empty($itemId)) { $file = $_FILES['file']; - $courseInfo = api_get_course_info(); $workInfo = get_work_data_by_id($itemId); $workInfoParent = get_work_data_by_id($workInfo['parent_id']); @@ -166,9 +163,7 @@ switch ($action) { echo 'false'; break; } - $work_table = Database::get_course_table( - TABLE_STUDENT_PUBLICATION - ); + $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); if (isset($resultUpload['url']) && !empty($resultUpload['url'])) { $title = isset($resultUpload['filename']) && !empty($resultUpload['filename']) ? $resultUpload['filename'] : get_lang('Untitled'); diff --git a/main/inc/lib/PortfolioController.php b/main/inc/lib/PortfolioController.php index 025c8e8e1e..cafca6d676 100644 --- a/main/inc/lib/PortfolioController.php +++ b/main/inc/lib/PortfolioController.php @@ -1393,6 +1393,137 @@ class PortfolioController $fs->remove($tempZipFile); } + public function qualifyItem(Portfolio $item) + { + global $interbreadcrumb; + + $em = Database::getManager(); + + $formAction = $this->baseUrl.http_build_query(['action' => 'qualify', 'item' => $item->getId()]); + + $form = new FormValidator('frm_qualify', 'post', $formAction); + $form->addUserAvatar('user', get_lang('Author')); + $form->addLabel(get_lang('Title'), $item->getTitle()); + + $itemContent = $this->generateItemContent($item); + + $form->addLabel(get_lang('Content'), $itemContent); + $form->addNumeric( + 'score', + [get_lang('QualifyNumeric'), null, ' / '.api_get_course_setting('portfolio_max_score')] + ); + $form->addButtonSave(get_lang('QualifyThisPortfolioItem')); + + if ($form->validate()) { + $values = $form->exportValues(); + + $item->setScore($values['score']); + + $em->persist($item); + $em->flush(); + + Display::addFlash( + Display::return_message(get_lang('PortfolioItemGraded'), 'success') + ); + + header("Location: $formAction"); + exit(); + } + + $form->setDefaults( + [ + 'user' => $item->getUser(), + 'score' => (float) $item->getScore(), + ] + ); + + $interbreadcrumb[] = [ + 'name' => get_lang('Portfolio'), + 'url' => $this->baseUrl, + ]; + $interbreadcrumb[] = [ + 'name' => $item->getTitle(), + 'url' => $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]), + ]; + + $actions = []; + $actions[] = Display::url( + Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM), + $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]) + ); + + return $this->renderView($form->returnForm(), get_lang('Qualify'), $actions); + } + + public function qualifyComment(PortfolioComment $comment) + { + global $interbreadcrumb; + + $em = Database::getManager(); + + $item = $comment->getItem(); + $commentPath = $em->getRepository(PortfolioComment::class)->getPath($comment); + + $template = new Template('', false, false, false, true, false, false); + $template->assign('item', $item); + $template->assign('comments_path', $commentPath); + $commentContext = $template->fetch( + $template->get_template('portfolio/comment_context.html.twig') + ); + + $formAction = $this->baseUrl.http_build_query(['action' => 'qualify', 'comment' => $comment->getId()]); + + $form = new FormValidator('frm_qualify', 'post', $formAction); + $form->addHtml($commentContext); + $form->addUserAvatar('user', get_lang('Author')); + $form->addLabel(get_lang('Comment'), $comment->getContent()); + $form->addNumeric( + 'score', + [get_lang('QualifyNumeric'), null, '/ '.api_get_course_setting('portfolio_max_score')] + ); + $form->addButtonSave(get_lang('QualifyThisPortfolioComment')); + + if ($form->validate()) { + $values = $form->exportValues(); + + $comment->setScore($values['score']); + + $em->persist($comment); + $em->flush(); + + Display::addFlash( + Display::return_message(get_lang('PortfolioCommentGraded'), 'success') + ); + + header("Location: $formAction"); + exit(); + } + + $form->setDefaults( + [ + 'user' => $comment->getAuthor(), + 'score' => (float) $comment->getScore(), + ] + ); + + $interbreadcrumb[] = [ + 'name' => get_lang('Portfolio'), + 'url' => $this->baseUrl, + ]; + $interbreadcrumb[] = [ + 'name' => $item->getTitle(), + 'url' => $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]), + ]; + + $actions = []; + $actions[] = Display::url( + Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM), + $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]) + ); + + return $this->renderView($form->returnForm(), get_lang('Qualify'), $actions); + } + /** * @param bool $showHeader */ @@ -1807,135 +1938,4 @@ class PortfolioController return $commentsHtml; } - - public function qualifyItem(Portfolio $item) - { - global $interbreadcrumb; - - $em = Database::getManager(); - - $formAction = $this->baseUrl.http_build_query(['action' => 'qualify', 'item' => $item->getId()]); - - $form = new FormValidator('frm_qualify', 'post', $formAction); - $form->addUserAvatar('user', get_lang('Author')); - $form->addLabel(get_lang('Title'), $item->getTitle()); - - $itemContent = $this->generateItemContent($item); - - $form->addLabel(get_lang('Content'), $itemContent); - $form->addNumeric( - 'score', - [get_lang('QualifyNumeric'), null, ' / '.api_get_course_setting('portfolio_max_score')] - ); - $form->addButtonSave(get_lang('QualifyThisPortfolioItem')); - - if ($form->validate()) { - $values = $form->exportValues(); - - $item->setScore($values['score']); - - $em->persist($item); - $em->flush(); - - Display::addFlash( - Display::return_message(get_lang('PortfolioItemGraded'), 'success') - ); - - header("Location: $formAction"); - exit(); - } - - $form->setDefaults( - [ - 'user' => $item->getUser(), - 'score' => (float) $item->getScore(), - ] - ); - - $interbreadcrumb[] = [ - 'name' => get_lang('Portfolio'), - 'url' => $this->baseUrl, - ]; - $interbreadcrumb[] = [ - 'name' => $item->getTitle(), - 'url' => $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]), - ]; - - $actions = []; - $actions[] = Display::url( - Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM), - $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]) - ); - - return $this->renderView($form->returnForm(), get_lang('Qualify'), $actions); - } - - public function qualifyComment(PortfolioComment $comment) - { - global $interbreadcrumb; - - $em = Database::getManager(); - - $item = $comment->getItem(); - $commentPath = $em->getRepository(PortfolioComment::class)->getPath($comment); - - $template = new Template('', false, false, false, true, false, false); - $template->assign('item', $item); - $template->assign('comments_path', $commentPath); - $commentContext = $template->fetch( - $template->get_template('portfolio/comment_context.html.twig') - ); - - $formAction = $this->baseUrl.http_build_query(['action' => 'qualify', 'comment' => $comment->getId()]); - - $form = new FormValidator('frm_qualify', 'post', $formAction); - $form->addHtml($commentContext); - $form->addUserAvatar('user', get_lang('Author')); - $form->addLabel(get_lang('Comment'), $comment->getContent()); - $form->addNumeric( - 'score', - [get_lang('QualifyNumeric'), null, '/ '.api_get_course_setting('portfolio_max_score')] - ); - $form->addButtonSave(get_lang('QualifyThisPortfolioComment')); - - if ($form->validate()) { - $values = $form->exportValues(); - - $comment->setScore($values['score']); - - $em->persist($comment); - $em->flush(); - - Display::addFlash( - Display::return_message(get_lang('PortfolioCommentGraded'), 'success') - ); - - header("Location: $formAction"); - exit(); - } - - $form->setDefaults( - [ - 'user' => $comment->getAuthor(), - 'score' => (float) $comment->getScore(), - ] - ); - - $interbreadcrumb[] = [ - 'name' => get_lang('Portfolio'), - 'url' => $this->baseUrl, - ]; - $interbreadcrumb[] = [ - 'name' => $item->getTitle(), - 'url' => $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]), - ]; - - $actions = []; - $actions[] = Display::url( - Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM), - $this->baseUrl.http_build_query(['action' => 'view', 'id' => $item->getId()]) - ); - - return $this->renderView($form->returnForm(), get_lang('Qualify'), $actions); - } } diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index 59fcd78bec..0bb71082d7 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -3908,11 +3908,11 @@ EOT; /** * Get student results (only in completed exercises) stats by question. * - * @param int $question_id - * @param int $exercise_id - * @param int $courseId - * @param int $session_id - * @param bool $onlyStudent Filter only enrolled students + * @param int $question_id + * @param int $exercise_id + * @param int $courseId + * @param int $session_id + * @param bool $onlyStudent Filter only enrolled students * * @return array */ diff --git a/plugin/xapi/src/Hook/XApiActivityHookObserver.php b/plugin/xapi/src/Hook/XApiActivityHookObserver.php index 5fd18e5aff..c622e5eeec 100644 --- a/plugin/xapi/src/Hook/XApiActivityHookObserver.php +++ b/plugin/xapi/src/Hook/XApiActivityHookObserver.php @@ -31,10 +31,9 @@ abstract class XApiActivityHookObserver extends HookObserver } /** - * @param \Xabbuh\XApi\Model\Statement $statement - * * @throws \Doctrine\ORM\ORMException * @throws \Doctrine\ORM\OptimisticLockException + * * @return \Chamilo\PluginBundle\Entity\XApi\SharedStatement|null */ protected function saveSharedStatement(Statement $statement) diff --git a/plugin/xapi/src/Hook/XApiLearningPathItemViewedHookObserver.php b/plugin/xapi/src/Hook/XApiLearningPathItemViewedHookObserver.php index 78c19b8ff6..676b504c3d 100644 --- a/plugin/xapi/src/Hook/XApiLearningPathItemViewedHookObserver.php +++ b/plugin/xapi/src/Hook/XApiLearningPathItemViewedHookObserver.php @@ -7,8 +7,7 @@ use Chamilo\PluginBundle\XApi\ToolExperience\Statement\LearningPathItemViewed; /** * Class XApiLearningPathItemViewedHookObserver. */ -class XApiLearningPathItemViewedHookObserver extends XApiActivityHookObserver - implements HookLearningPathItemViewedObserverInterface +class XApiLearningPathItemViewedHookObserver extends XApiActivityHookObserver implements HookLearningPathItemViewedObserverInterface { /** * {@inheritdoc} diff --git a/plugin/xapi/src/Hook/XApiPortfolioItemAddedHookObserver.php b/plugin/xapi/src/Hook/XApiPortfolioItemAddedHookObserver.php index 3bfab2addb..5738a1f4fb 100644 --- a/plugin/xapi/src/Hook/XApiPortfolioItemAddedHookObserver.php +++ b/plugin/xapi/src/Hook/XApiPortfolioItemAddedHookObserver.php @@ -7,11 +7,10 @@ use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioItemShared; /** * Class XApiPortfolioItemAddedHookObserver. */ -class XApiPortfolioItemAddedHookObserver extends XApiActivityHookObserver - implements HookPortfolioItemAddedObserverInterface +class XApiPortfolioItemAddedHookObserver extends XApiActivityHookObserver implements HookPortfolioItemAddedObserverInterface { /** - * @inheritDoc + * {@inheritDoc} */ public function hookItemAdded(HookPortfolioItemAddedEventInterface $hookEvent) { diff --git a/plugin/xapi/src/Hook/XApiPortfolioItemCommentedHookObserver.php b/plugin/xapi/src/Hook/XApiPortfolioItemCommentedHookObserver.php index 1a5b85d785..32bc4a8d8a 100644 --- a/plugin/xapi/src/Hook/XApiPortfolioItemCommentedHookObserver.php +++ b/plugin/xapi/src/Hook/XApiPortfolioItemCommentedHookObserver.php @@ -7,11 +7,10 @@ use Chamilo\PluginBundle\XApi\ToolExperience\Statement\PortfolioItemCommented; /** * Class XApiPortfolioItemCommentedHookObserver. */ -class XApiPortfolioItemCommentedHookObserver extends XApiActivityHookObserver - implements HookPortfolioItemCommentedObserverInterface +class XApiPortfolioItemCommentedHookObserver extends XApiActivityHookObserver implements HookPortfolioItemCommentedObserverInterface { /** - * @inheritDoc + * {@inheritDoc} */ public function hookItemCommented(HookPortfolioItemCommentedEventInterface $hookEvent) { diff --git a/plugin/xapi/src/Hook/XApiQuizQuestionAnsweredHookObserver.php b/plugin/xapi/src/Hook/XApiQuizQuestionAnsweredHookObserver.php index b51b573e0d..f164542559 100644 --- a/plugin/xapi/src/Hook/XApiQuizQuestionAnsweredHookObserver.php +++ b/plugin/xapi/src/Hook/XApiQuizQuestionAnsweredHookObserver.php @@ -11,8 +11,7 @@ use Chamilo\PluginBundle\XApi\ToolExperience\Statement\QuizQuestionAnswered; /** * Class XApiQuizQuestionAnsweredHook. */ -class XApiQuizQuestionAnsweredHookObserver extends XApiActivityHookObserver - implements HookQuizQuestionAnsweredObserverInterface +class XApiQuizQuestionAnsweredHookObserver extends XApiActivityHookObserver implements HookQuizQuestionAnsweredObserverInterface { /** * {@inheritdoc} diff --git a/plugin/xapi/src/ToolExperience/Activity/BaseActivity.php b/plugin/xapi/src/ToolExperience/Activity/BaseActivity.php index 72172d9a23..c169021714 100644 --- a/plugin/xapi/src/ToolExperience/Activity/BaseActivity.php +++ b/plugin/xapi/src/ToolExperience/Activity/BaseActivity.php @@ -26,7 +26,7 @@ abstract class BaseActivity */ protected $session; - public abstract function generate(): Activity; + abstract public function generate(): Activity; protected function generateIri(string $path, string $resource, array $params = []): string { diff --git a/plugin/xapi/src/ToolExperience/Activity/QuizQuestion.php b/plugin/xapi/src/ToolExperience/Activity/QuizQuestion.php index efbc1b6cff..74c9a81101 100644 --- a/plugin/xapi/src/ToolExperience/Activity/QuizQuestion.php +++ b/plugin/xapi/src/ToolExperience/Activity/QuizQuestion.php @@ -97,7 +97,7 @@ class QuizQuestion extends BaseActivity $choices = []; for ($i = 1; $i <= $objAnswer->nbrAnswers; $i++) { - if ((int)$objAnswer->correct[$i] > 0) { + if ((int) $objAnswer->correct[$i] > 0) { $choices[] = new InteractionComponent( $objAnswer->correct[$i], LanguageMap::create([$languageIso => $objAnswer->answer[$i]]) @@ -130,7 +130,7 @@ class QuizQuestion extends BaseActivity LanguageMap::create([$languageIso => $objAnswer->selectAnswer($i)]) ); - if ((int)$objAnswer->correct[$i] > 0) { + if ((int) $objAnswer->correct[$i] > 0) { $source[] = $interactionComponent; $correctResponsesPattern[] = $objAnswer->selectAutoId($i).'[.]'.$objAnswer->correct[$i]; diff --git a/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php b/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php index bb4526a2da..6811cb59d9 100644 --- a/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php +++ b/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php @@ -14,7 +14,7 @@ use Xabbuh\XApi\Model\Uuid; use XApiPlugin; /** - * Class BaseStatement + * Class BaseStatement. * * @package Chamilo\PluginBundle\XApi\ToolExperience\Statement */ diff --git a/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php b/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php index d603fcc0e0..7a23708aac 100644 --- a/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php +++ b/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php @@ -17,7 +17,7 @@ use Xabbuh\XApi\Model\Result; use Xabbuh\XApi\Model\Statement; /** - * Class LearningPathItemViewed + * Class LearningPathItemViewed. * * @package Chamilo\PluginBundle\XApi\ToolExperience\Statement */ diff --git a/plugin/xapi/src/ToolExperience/Verb/Answered.php b/plugin/xapi/src/ToolExperience/Verb/Answered.php index 3d1d725ef6..4007892f38 100644 --- a/plugin/xapi/src/ToolExperience/Verb/Answered.php +++ b/plugin/xapi/src/ToolExperience/Verb/Answered.php @@ -4,10 +4,6 @@ namespace Chamilo\PluginBundle\XApi\ToolExperience\Verb; -use Xabbuh\XApi\Model\IRI; -use Xabbuh\XApi\Model\LanguageMap; -use Xabbuh\XApi\Model\Verb; - /** * Class Answered. * diff --git a/plugin/xapi/src/ToolExperience/Verb/BaseVerb.php b/plugin/xapi/src/ToolExperience/Verb/BaseVerb.php index f7aba9467f..0efadb8718 100644 --- a/plugin/xapi/src/ToolExperience/Verb/BaseVerb.php +++ b/plugin/xapi/src/ToolExperience/Verb/BaseVerb.php @@ -9,7 +9,7 @@ use Xabbuh\XApi\Model\LanguageMap; use Xabbuh\XApi\Model\Verb; /** - * Class BaseVerb + * Class BaseVerb. * * @package Chamilo\PluginBundle\XApi\ToolExperience\Verb */ @@ -38,7 +38,7 @@ abstract class BaseVerb IRI::fromString($this->iri), LanguageMap::create( [ - $langIso => get_lang($this->display) + $langIso => get_lang($this->display), ] ) ); diff --git a/plugin/xapi/src/ToolExperience/Verb/Commented.php b/plugin/xapi/src/ToolExperience/Verb/Commented.php index f8810b9982..34865a6b38 100644 --- a/plugin/xapi/src/ToolExperience/Verb/Commented.php +++ b/plugin/xapi/src/ToolExperience/Verb/Commented.php @@ -4,10 +4,6 @@ namespace Chamilo\PluginBundle\XApi\ToolExperience\Verb; -use Xabbuh\XApi\Model\IRI; -use Xabbuh\XApi\Model\LanguageMap; -use Xabbuh\XApi\Model\Verb; - /** * Class Commented. * diff --git a/plugin/xapi/src/ToolExperience/Verb/Completed.php b/plugin/xapi/src/ToolExperience/Verb/Completed.php index 7bdfcec300..51cc17ad1d 100644 --- a/plugin/xapi/src/ToolExperience/Verb/Completed.php +++ b/plugin/xapi/src/ToolExperience/Verb/Completed.php @@ -4,10 +4,6 @@ namespace Chamilo\PluginBundle\XApi\ToolExperience\Verb; -use Xabbuh\XApi\Model\IRI; -use Xabbuh\XApi\Model\LanguageMap; -use Xabbuh\XApi\Model\Verb; - /** * Class Completed. * diff --git a/plugin/xapi/src/ToolExperience/Verb/Replied.php b/plugin/xapi/src/ToolExperience/Verb/Replied.php index a38f19d84c..418a089436 100644 --- a/plugin/xapi/src/ToolExperience/Verb/Replied.php +++ b/plugin/xapi/src/ToolExperience/Verb/Replied.php @@ -4,10 +4,6 @@ namespace Chamilo\PluginBundle\XApi\ToolExperience\Verb; -use Xabbuh\XApi\Model\IRI; -use Xabbuh\XApi\Model\LanguageMap; -use Xabbuh\XApi\Model\Verb; - /** * Class Replied. * diff --git a/plugin/xapi/src/ToolExperience/Verb/Shared.php b/plugin/xapi/src/ToolExperience/Verb/Shared.php index 1f9b3dba61..4867f8dff2 100644 --- a/plugin/xapi/src/ToolExperience/Verb/Shared.php +++ b/plugin/xapi/src/ToolExperience/Verb/Shared.php @@ -4,10 +4,6 @@ namespace Chamilo\PluginBundle\XApi\ToolExperience\Verb; -use Xabbuh\XApi\Model\IRI; -use Xabbuh\XApi\Model\LanguageMap; -use Xabbuh\XApi\Model\Verb; - /** * Class Shared. * diff --git a/plugin/xapi/src/ToolExperience/Verb/Viewed.php b/plugin/xapi/src/ToolExperience/Verb/Viewed.php index 64605ed00f..15fc7f6321 100644 --- a/plugin/xapi/src/ToolExperience/Verb/Viewed.php +++ b/plugin/xapi/src/ToolExperience/Verb/Viewed.php @@ -4,10 +4,6 @@ namespace Chamilo\PluginBundle\XApi\ToolExperience\Verb; -use Xabbuh\XApi\Model\IRI; -use Xabbuh\XApi\Model\LanguageMap; -use Xabbuh\XApi\Model\Verb; - /** * Class Viewed. * diff --git a/src/Chamilo/CoreBundle/Entity/Portfolio.php b/src/Chamilo/CoreBundle/Entity/Portfolio.php index fcba96c673..6ab41d53fd 100644 --- a/src/Chamilo/CoreBundle/Entity/Portfolio.php +++ b/src/Chamilo/CoreBundle/Entity/Portfolio.php @@ -399,17 +399,11 @@ class Portfolio return $excerpt; } - /** - * @return float|null - */ public function getScore(): ?float { return $this->score; } - /** - * @param float|null $score - */ public function setScore(?float $score): void { $this->score = $score; diff --git a/src/Chamilo/CoreBundle/Entity/PortfolioComment.php b/src/Chamilo/CoreBundle/Entity/PortfolioComment.php index ae8ccaced2..a147b21c35 100644 --- a/src/Chamilo/CoreBundle/Entity/PortfolioComment.php +++ b/src/Chamilo/CoreBundle/Entity/PortfolioComment.php @@ -231,17 +231,11 @@ class PortfolioComment return $excerpt; } - /** - * @return float|null - */ public function getScore(): ?float { return $this->score; } - /** - * @param float|null $score - */ public function setScore(?float $score): void { $this->score = $score; @@ -255,9 +249,6 @@ class PortfolioComment return $this->root; } - /** - * @return int - */ public function getLvl(): int { return $this->lvl;