Api Platform - Add Api track_e_exercises and rename entity - refs BT#19741

Api platform: Add missing file to get user track exercise - refs BT#19741

Api Platform - Clean partial code - refs BT#19741

Minor: Fix format code
pull/4197/head
Christian 3 years ago committed by Angel Fernando Quiroz Campos
parent d6b7f90337
commit b30f154a03
  1. 4
      public/main/exercise/exercise.class.php
  2. 4
      public/main/exercise/recalculate.php
  3. 4
      public/main/exercise/recalculate_all.php
  4. 6
      public/main/inc/ajax/exercise.ajax.php
  5. 6
      public/main/inc/ajax/record_audio_rtc.ajax.php
  6. 6
      public/main/inc/lib/events.lib.php
  7. 14
      public/main/inc/lib/exercise.lib.php
  8. 6
      public/main/inc/lib/exercise_show_functions.lib.php
  9. 2
      public/plugin/questionoptionsevaluation/QuestionOptionsEvaluationPlugin.php
  10. 8
      src/CoreBundle/Entity/TrackEAttempt.php
  11. 4
      src/CoreBundle/Entity/TrackEExercise.php
  12. 6
      src/CoreBundle/Framework/Container.php
  13. 8
      src/CoreBundle/Repository/TrackEExerciseRepository.php
  14. 8
      src/CoreBundle/Serializer/UserToJsonNormalizer.php
  15. 18
      tests/CoreBundle/Repository/TrackExerciseRepositoryTest.php

@ -6,7 +6,7 @@ use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\GradebookLink;
use Chamilo\CoreBundle\Entity\TrackEExerciseConfirmation;
use Chamilo\CoreBundle\Entity\TrackEHotspot;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CExerciseCategory;
use Chamilo\CourseBundle\Entity\CQuiz;
@ -3087,7 +3087,7 @@ class Exercise
$questionList = array_map('intval', $questionList);
$em = Database::getManager();
$trackExercise = (new TrackExercise())
$trackExercise = (new TrackEExercise())
->setSession(api_get_session_entity())
->setCourse(api_get_course_entity())
->setMaxScore($weight)

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
require_once __DIR__.'/../inc/global.inc.php';
@ -22,7 +22,7 @@ $studentId = (int) $_REQUEST['user'];
$exerciseId = (int) $_REQUEST['exercise'];
$exeId = (int) $_REQUEST['id'];
/** @var TrackExercise $trackedExercise */
/** @var TrackEExercise $trackedExercise */
$trackedExercise = ExerciseLib::recalculateResult(
$_REQUEST['id'],
$_REQUEST['user'],

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
require_once __DIR__.'/../inc/global.inc.php';
@ -41,7 +41,7 @@ $result = ExerciseLib::get_exam_results_data(
);
foreach ($result as $track) {
/** @var TrackExercise $trackedExercise */
/** @var TrackEExercise $trackedExercise */
$trackedExercise = ExerciseLib::recalculateResult(
$track['id'],
$track['user_id'],

@ -3,7 +3,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\TrackEExerciseConfirmation;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use ChamiloSession as Session;
require_once __DIR__.'/../global.inc.php';
@ -67,8 +67,8 @@ switch ($action) {
$onlyUpdateValue = 10;
$em = Database::getManager();
/** @var TrackExercise $attempt */
$attempt = $em->getRepository(TrackExercise::class)->find($exeId);
/** @var TrackEExercise $attempt */
$attempt = $em->getRepository(TrackEExercise::class)->find($exeId);
if (null === $attempt) {
if ($debug) {

@ -4,7 +4,7 @@
use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Entity\AttemptFeedback;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Framework\Container;
use Symfony\Component\HttpFoundation\Request;
@ -55,8 +55,8 @@ switch ($type) {
$attemptFeedback = (new AttemptFeedback())
->setAsset($asset);
/** @var TrackExercise $exeAttempt */
$exeAttempt = Container::getTrackExerciseRepository()->find($trackExerciseId);
/** @var TrackEExercise $exeAttempt */
$exeAttempt = Container::getTrackEExerciseRepository()->find($trackExerciseId);
$attempt = $exeAttempt->getAttemptByQuestionId($questionId);
if (null === $attempt) {

@ -7,7 +7,7 @@ use Chamilo\CoreBundle\Entity\Course as CourseEntity;
use Chamilo\CoreBundle\Entity\Session as SessionEntity;
use Chamilo\CoreBundle\Entity\TrackEAttemptRecording;
use Chamilo\CoreBundle\Entity\TrackEDefault;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container;
use ChamiloSession as Session;
@ -1232,10 +1232,10 @@ class Event
$sessionCondition
";
$result = Database::query($sql);
$repo = Container::getTrackExerciseRepository();
$repo = Container::getTrackEExerciseRepository();
while ($row = Database::fetch_array($result, 'ASSOC')) {
$exeId = $row['exe_id'];
/** @var TrackExercise $track */
/** @var TrackEExercise $track */
$track = $repo->find($exeId);
self::addEvent(

@ -5,7 +5,7 @@
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
use ChamiloSession as Session;
@ -4830,7 +4830,7 @@ EOT;
{
$em = Database::getManager();
$dql = 'SELECT DISTINCT te.exeUserId FROM ChamiloCoreBundle:TrackExercise te WHERE te.exeExoId = :id AND te.course = :cId';
$dql = 'SELECT DISTINCT te.exeUserId FROM ChamiloCoreBundle:TrackEExercise te WHERE te.exeExoId = :id AND te.course = :cId';
$dql .= api_get_session_condition($sessionId, true, false, 'te.sessionId');
$result = $em
@ -5118,8 +5118,8 @@ EOT;
*/
public static function getOralFeedbackAudio($attemptId, $questionId, $userId)
{
/** @var TrackExercise $tExercise */
$tExercise = Container::getTrackExerciseRepository()->find($attemptId);
/** @var TrackEExercise $tExercise */
$tExercise = Container::getTrackEExerciseRepository()->find($attemptId);
if (null === $tExercise) {
return '';
@ -5373,7 +5373,7 @@ EOT;
* @param int $exerciseId Exercise ID
* @param int $courseId Optional. Coure ID.
*
* @return TrackExercise|null
* @return TrackEExercise|null
*/
public static function recalculateResult($exeId, $userId, $exerciseId, $courseId = 0)
{
@ -5382,8 +5382,8 @@ EOT;
}
$em = Database::getManager();
/** @var TrackExercise $trackedExercise */
$trackedExercise = $em->getRepository(TrackExercise::class)->find($exeId);
/** @var TrackEExercise $trackedExercise */
$trackedExercise = $em->getRepository(TrackEExercise::class)->find($exeId);
if (empty($trackedExercise)) {
return null;

@ -1,7 +1,7 @@
<?php
/* See license terms in /license.txt */
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Framework\Container;
class ExerciseShowFunctions
@ -154,8 +154,8 @@ class ExerciseShowFunctions
$questionScore = 0,
$showAlertIfNotCorrected = false
) {
/** @var TrackExercise $trackExercise */
$trackExercise = Container::getTrackExerciseRepository()->find($trackExerciseId);
/** @var TrackEExercise $trackExercise */
$trackExercise = Container::getTrackEExerciseRepository()->find($trackExerciseId);
if (null === $trackExerciseId) {
return;

@ -152,7 +152,7 @@ class QuestionOptionsEvaluationPlugin extends Plugin
{
$em = Database::getManager();
$eTrack = $em->find('ChamiloCoreBundle:TrackExercise', $trackId);
$eTrack = $em->find('ChamiloCoreBundle:TrackEExercise', $trackId);
$qTracks = $em
->createQuery(

@ -39,11 +39,11 @@ class TrackEAttempt
protected int $id;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\TrackExercise", inversedBy="attempts")
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\TrackEExercise", inversedBy="attempts")
* @ORM\JoinColumn(name="exe_id", referencedColumnName="exe_id", nullable=false, onDelete="CASCADE")
*/
#[Assert\NotNull]
protected TrackExercise $trackExercise;
protected TrackEExercise $trackExercise;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="trackEAttempts")
@ -262,12 +262,12 @@ class TrackEAttempt
return $this;
}
public function getTrackExercise(): TrackExercise
public function getTrackEExercise(): TrackEExercise
{
return $this->trackExercise;
}
public function setTrackExercise(TrackExercise $trackExercise): self
public function setTrackEExercise(TrackEExercise $trackExercise): self
{
$this->trackExercise = $trackExercise;

@ -23,7 +23,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* })
* @ORM\Entity
*/
class TrackExercise
class TrackEExercise
{
/**
* @ORM\Column(name="exe_id", type="integer")
@ -454,7 +454,7 @@ class TrackExercise
{
if (!$this->attempts->contains($attempt)) {
$this->attempts[] = $attempt;
$attempt->setTrackExercise($this);
$attempt->setTrackEExercise($this);
}
return $this;

@ -33,7 +33,7 @@ use Chamilo\CoreBundle\Repository\SkillRepository;
use Chamilo\CoreBundle\Repository\SocialPostRepository;
use Chamilo\CoreBundle\Repository\SysAnnouncementRepository;
use Chamilo\CoreBundle\Repository\TagRepository;
use Chamilo\CoreBundle\Repository\TrackExerciseRepository;
use Chamilo\CoreBundle\Repository\TrackEExerciseRepository;
use Chamilo\CoreBundle\Serializer\UserToJsonNormalizer;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CoreBundle\Tool\ToolChain;
@ -566,9 +566,9 @@ class Container
return self::$container->get(CThematicAdvanceRepository::class);
}
public static function getTrackExerciseRepository(): TrackExerciseRepository
public static function getTrackEExerciseRepository(): TrackEExerciseRepository
{
return self::$container->get(TrackExerciseRepository::class);
return self::$container->get(TrackEExerciseRepository::class);
}
public static function getWikiRepository(): CWikiRepository

@ -6,18 +6,18 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Repository;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class TrackExerciseRepository extends ServiceEntityRepository
class TrackEExerciseRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, TrackExercise::class);
parent::__construct($registry, TrackEExercise::class);
}
public function delete(TrackExercise $track): void
public function delete(TrackEExercise $track): void
{
$this->getEntityManager()->remove($track);
$this->getEntityManager()->flush();

@ -16,11 +16,11 @@ use Chamilo\CoreBundle\Entity\TrackEAttempt;
use Chamilo\CoreBundle\Entity\TrackECourseAccess;
use Chamilo\CoreBundle\Entity\TrackEDefault;
use Chamilo\CoreBundle\Entity\TrackEDownloads;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Entity\TrackELastaccess;
use Chamilo\CoreBundle\Entity\TrackELogin;
use Chamilo\CoreBundle\Entity\TrackEOnline;
use Chamilo\CoreBundle\Entity\TrackEUploads;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Entity\UserCourseCategory;
use Chamilo\CoreBundle\Entity\UserRelCourseVote;
@ -135,9 +135,9 @@ final class UserToJsonNormalizer
$criteria = [
'user' => $userId,
];
$result = $em->getRepository(TrackExercise::class)->findBy($criteria);
$result = $em->getRepository(TrackEExercise::class)->findBy($criteria);
$trackEExercises = [];
/** @var TrackExercise $item */
/** @var TrackEExercise $item */
foreach ($result as $item) {
$date = $item->getExeDate()->format($dateFormat);
$list = [
@ -160,7 +160,7 @@ final class UserToJsonNormalizer
foreach ($result as $item) {
$date = $item->getTms()->format($dateFormat);
$list = [
'Attempt #'.$item->getTrackExercise()->getExeId(),
'Attempt #'.$item->getTrackEExercise()->getExeId(),
//'Answer: '.$item->getAnswer(),
//'Marks: '.$item->getMarks(),
'Position: '.$item->getPosition(),

@ -10,17 +10,17 @@ use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Entity\AttemptFeedback;
use Chamilo\CoreBundle\Entity\AttemptFile;
use Chamilo\CoreBundle\Entity\TrackEAttempt;
use Chamilo\CoreBundle\Entity\TrackExercise;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
use Chamilo\CoreBundle\Repository\SessionRepository;
use Chamilo\CoreBundle\Repository\TrackExerciseRepository;
use Chamilo\CoreBundle\Repository\TrackEExerciseRepository;
use Chamilo\CourseBundle\Entity\CQuiz;
use Chamilo\CourseBundle\Repository\CQuizRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;
use DateTime;
class TrackExerciseRepositoryTest extends AbstractApiTest
class TrackEExerciseRepositoryTest extends AbstractApiTest
{
use ChamiloTestTrait;
@ -34,7 +34,7 @@ class TrackExerciseRepositoryTest extends AbstractApiTest
$student = $this->createUser('student');
$courseRepo = self::getContainer()->get(CourseRepository::class);
$trackExerciseRepo = self::getContainer()->get(TrackExerciseRepository::class);
$trackExerciseRepo = self::getContainer()->get(TrackEExerciseRepository::class);
$exerciseRepo = self::getContainer()->get(CQuizRepository::class);
$this->assertSame(1, $courseRepo->count([]));
@ -47,7 +47,7 @@ class TrackExerciseRepositoryTest extends AbstractApiTest
$em->persist($exercise);
$em->flush();
$trackExercise = (new TrackExercise())
$trackExercise = (new TrackEExercise())
->setQuestionsToCheck('')
->setExeDate(new DateTime())
->setStartDate(new DateTime())
@ -100,7 +100,7 @@ class TrackExerciseRepositoryTest extends AbstractApiTest
$courseRepo = self::getContainer()->get(CourseRepository::class);
$sessionRepo = self::getContainer()->get(SessionRepository::class);
$trackExerciseRepo = self::getContainer()->get(TrackExerciseRepository::class);
$trackExerciseRepo = self::getContainer()->get(TrackEExerciseRepository::class);
$exerciseRepo = self::getContainer()->get(CQuizRepository::class);
$this->assertSame(1, $courseRepo->count([]));
@ -113,7 +113,7 @@ class TrackExerciseRepositoryTest extends AbstractApiTest
$em->persist($exercise);
$em->flush();
$trackExercise = (new TrackExercise())
$trackExercise = (new TrackEExercise())
->setQuestionsToCheck('')
->setExeDate(new DateTime())
->setStartDate(new DateTime())
@ -161,7 +161,7 @@ class TrackExerciseRepositoryTest extends AbstractApiTest
$em = $this->getEntityManager();
$courseRepo = self::getContainer()->get(CourseRepository::class);
$trackExerciseRepo = self::getContainer()->get(TrackExerciseRepository::class);
$trackExerciseRepo = self::getContainer()->get(TrackEExerciseRepository::class);
$exerciseRepo = self::getContainer()->get(CQuizRepository::class);
$course = $this->createCourse('new');
@ -188,7 +188,7 @@ class TrackExerciseRepositoryTest extends AbstractApiTest
->setUser($student)
;
$trackExercise = (new TrackExercise())
$trackExercise = (new TrackEExercise())
->setQuestionsToCheck('')
->setExeDate(new DateTime())
->setStatus('completed')

Loading…
Cancel
Save