diff --git a/public/main/forum/forumfunction.inc.php b/public/main/forum/forumfunction.inc.php index 35bc649588..30dbfb5a17 100644 --- a/public/main/forum/forumfunction.inc.php +++ b/public/main/forum/forumfunction.inc.php @@ -813,7 +813,6 @@ function store_forum($values, $courseInfo = [], $returnId = false) ->setModerated((bool) ($values['moderated']['moderated'] ?? false)) ->setStartTime(!empty($values['start_time']) ? api_get_utc_datetime($values['start_time'], true, true) : null) ->setEndTime(!empty($values['end_time']) ? api_get_utc_datetime($values['end_time'], true, true) : null) - ->setSessionId($session_id) ->setLp($lp) ; diff --git a/public/main/inc/lib/tracking.lib.php b/public/main/inc/lib/tracking.lib.php index b869185430..a077a71b1a 100644 --- a/public/main/inc/lib/tracking.lib.php +++ b/public/main/inc/lib/tracking.lib.php @@ -7435,8 +7435,6 @@ class Tracking $data['post_group_id'] = (int) $data['post_group_id']; $publication = new CStudentPublication(); $publication - ->setUrl($new_url) - ->setCId($course_id) ->setTitle($data['title']) ->setDescription($data['description'].' file moved') ->setActive($data['active']) diff --git a/public/main/survey/survey.lib.php b/public/main/survey/survey.lib.php index ef434048d0..f21cef3f12 100644 --- a/public/main/survey/survey.lib.php +++ b/public/main/survey/survey.lib.php @@ -261,9 +261,6 @@ class SurveyManager $extraParams['form_fields'] = ''; } $survey->setFormFields($extraParams['form_fields']); - } else { - $survey->setShowFormProfile(0); - $survey->setFormFields(0); } $extraParams['one_question_per_page'] = isset($values['one_question_per_page']) ? $values['one_question_per_page'] : 0; diff --git a/src/CoreBundle/Entity/Asset.php b/src/CoreBundle/Entity/Asset.php index a424c062d5..aca6243a90 100644 --- a/src/CoreBundle/Entity/Asset.php +++ b/src/CoreBundle/Entity/Asset.php @@ -42,17 +42,12 @@ class Asset protected int $id; /** - * @Assert\NotBlank() - * * @ORM\Column(type="string", length=255) */ + #[Assert\NotBlank] protected ?string $title = null; /** - * @todo use attributes - * - * @Assert\NotBlank() - * * @Assert\Choice({ * Asset::SCORM, * Asset::WATERMARK, @@ -64,6 +59,7 @@ class Asset * * @ORM\Column(type="string", length=255) */ + #[Assert\NotBlank] protected ?string $category = null; /** diff --git a/src/CourseBundle/Entity/CForum.php b/src/CourseBundle/Entity/CForum.php index aae1dbde1d..385a8adeff 100644 --- a/src/CourseBundle/Entity/CForum.php +++ b/src/CourseBundle/Entity/CForum.php @@ -122,11 +122,6 @@ class CForum extends AbstractResource implements ResourceInterface */ protected int $locked; - /** - * @ORM\Column(name="session_id", type="integer", nullable=false) - */ - protected int $sessionId; - /** * @ORM\Column(name="forum_image", type="string", length=255, nullable=false) */ @@ -432,23 +427,6 @@ class CForum extends AbstractResource implements ResourceInterface return $this->locked; } - public function setSessionId(int $sessionId): self - { - $this->sessionId = $sessionId; - - return $this; - } - - /** - * Get sessionId. - * - * @return int - */ - public function getSessionId() - { - return $this->sessionId; - } - public function setForumImage(string $forumImage): self { $this->forumImage = $forumImage; diff --git a/src/CourseBundle/Entity/CForumCategory.php b/src/CourseBundle/Entity/CForumCategory.php index 8a26c1d109..f40d0a2b14 100644 --- a/src/CourseBundle/Entity/CForumCategory.php +++ b/src/CourseBundle/Entity/CForumCategory.php @@ -64,6 +64,7 @@ class CForumCategory extends AbstractResource implements ResourceInterface { $this->catComment = ''; $this->locked = 0; + $this->catOrder = 0; $this->forums = new ArrayCollection(); } diff --git a/src/CourseBundle/Entity/CStudentPublication.php b/src/CourseBundle/Entity/CStudentPublication.php index d304089832..f1f887612c 100644 --- a/src/CourseBundle/Entity/CStudentPublication.php +++ b/src/CourseBundle/Entity/CStudentPublication.php @@ -36,9 +36,9 @@ class CStudentPublication extends AbstractResource implements ResourceInterface protected int $iid; /** - * @Assert\NotBlank() * @ORM\Column(name="title", type="string", length=255, nullable=false) */ + #[Assert\NotBlank] protected string $title; /** @@ -74,6 +74,8 @@ class CStudentPublication extends AbstractResource implements ResourceInterface /** * @ORM\Column(name="filetype", type="string", length=10, nullable=false) */ + #[Assert\NotBlank] + #[Assert\Choice(callback: 'getFileTypes')] protected string $filetype; /** @@ -133,6 +135,7 @@ class CStudentPublication extends AbstractResource implements ResourceInterface /** * @ORM\Column(name="weight", type="float", precision=6, scale=2, nullable=false) */ + #[Assert\NotBlank] protected float $weight; /** @@ -165,6 +168,9 @@ class CStudentPublication extends AbstractResource implements ResourceInterface $this->qualificatorId = 0; $this->qualification = 0; $this->assignment = null; + $this->postGroupId = 0; + $this->allowTextAssignment = 0; + $this->filetype = 'folder'; $this->sentDate = new DateTime(); $this->children = new ArrayCollection(); $this->comments = new ArrayCollection(); @@ -175,6 +181,11 @@ class CStudentPublication extends AbstractResource implements ResourceInterface return $this->getTitle(); } + public function getFileTypes(): array + { + return ['file', 'folder']; + } + /** * Get iid. * diff --git a/src/CourseBundle/Entity/CSurvey.php b/src/CourseBundle/Entity/CSurvey.php index 3499f31fd3..d515418e02 100644 --- a/src/CourseBundle/Entity/CSurvey.php +++ b/src/CourseBundle/Entity/CSurvey.php @@ -121,6 +121,7 @@ class CSurvey extends AbstractResource implements ResourceInterface /** * @ORM\Column(name="anonymous", type="string", length=10, nullable=false) */ + #[Assert\NotBlank] protected string $anonymous; /** @@ -227,6 +228,8 @@ class CSurvey extends AbstractResource implements ResourceInterface $this->creationDate = new DateTime(); $this->invited = 0; $this->answered = 0; + $this->anonymous = '0'; + $this->formFields = '0'; $this->subtitle = ''; $this->inviteMail = ''; $this->lang = ''; @@ -236,6 +239,7 @@ class CSurvey extends AbstractResource implements ResourceInterface $this->oneQuestionPerPage = false; $this->surveyVersion = ''; $this->surveyType = 0; + $this->showFormProfile = 0; $this->questions = new ArrayCollection(); $this->children = new ArrayCollection(); $this->invitations = new ArrayCollection(); diff --git a/src/CourseBundle/Entity/CThematic.php b/src/CourseBundle/Entity/CThematic.php index 4f73aaf726..ebb2fbe63c 100644 --- a/src/CourseBundle/Entity/CThematic.php +++ b/src/CourseBundle/Entity/CThematic.php @@ -34,10 +34,9 @@ class CThematic extends AbstractResource implements ResourceInterface protected int $iid; /** - * @Assert\NotBlank() - * * @ORM\Column(name="title", type="text", nullable=false) */ + #[Assert\NotBlank] protected string $title; /** @@ -80,6 +79,7 @@ class CThematic extends AbstractResource implements ResourceInterface $this->plans = new ArrayCollection(); $this->advances = new ArrayCollection(); $this->active = true; + $this->displayOrder = 0; } public function __toString(): string diff --git a/tests/CourseBundle/Repository/CAnnouncementAttachmentRepositoryTest.php b/tests/CourseBundle/Repository/CAnnouncementAttachmentRepositoryTest.php index dd69edd176..781764f000 100644 --- a/tests/CourseBundle/Repository/CAnnouncementAttachmentRepositoryTest.php +++ b/tests/CourseBundle/Repository/CAnnouncementAttachmentRepositoryTest.php @@ -21,7 +21,7 @@ class CAnnouncementAttachmentRepositoryTest extends AbstractApiTest { self::bootKernel(); - $em = self::getContainer()->get('doctrine')->getManager(); + $em = $this->getManager(); $repo = self::getContainer()->get(CAnnouncementRepository::class); $repoAttachment = self::getContainer()->get(CAnnouncementAttachmentRepository::class); diff --git a/tests/CourseBundle/Repository/CAnnouncementRepositoryTest.php b/tests/CourseBundle/Repository/CAnnouncementRepositoryTest.php index a28d58a9bd..387dce0348 100644 --- a/tests/CourseBundle/Repository/CAnnouncementRepositoryTest.php +++ b/tests/CourseBundle/Repository/CAnnouncementRepositoryTest.php @@ -19,7 +19,7 @@ class CAnnouncementRepositoryTest extends AbstractApiTest { self::bootKernel(); - $em = self::getContainer()->get('doctrine')->getManager(); + $em = $this->getManager(); $repo = self::getContainer()->get(CAnnouncementRepository::class); $course = $this->createCourse('new'); diff --git a/tests/CourseBundle/Repository/CAttendanceRepositoryTest.php b/tests/CourseBundle/Repository/CAttendanceRepositoryTest.php index 94101545ef..15b3c31978 100644 --- a/tests/CourseBundle/Repository/CAttendanceRepositoryTest.php +++ b/tests/CourseBundle/Repository/CAttendanceRepositoryTest.php @@ -19,7 +19,7 @@ class CAttendanceRepositoryTest extends AbstractApiTest { self::bootKernel(); - $em = self::getContainer()->get('doctrine')->getManager(); + $em = $this->getManager(); $repo = self::getContainer()->get(CAttendanceRepository::class); $course = $this->createCourse('new'); diff --git a/tests/CourseBundle/Repository/CForumCategoryRepositoryTest.php b/tests/CourseBundle/Repository/CForumCategoryRepositoryTest.php new file mode 100644 index 0000000000..dceda5d611 --- /dev/null +++ b/tests/CourseBundle/Repository/CForumCategoryRepositoryTest.php @@ -0,0 +1,48 @@ +getManager(); + $repo = self::getContainer()->get(CForumCategoryRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CForumCategory()) + ->setCatTitle('cat') + ->setParent($course) + ->setCreator($teacher) + ; + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('cat', (string) $item); + $this->assertSame(1, $repo->count([])); + } +} diff --git a/tests/CourseBundle/Repository/CForumRepositoryTest.php b/tests/CourseBundle/Repository/CForumRepositoryTest.php new file mode 100644 index 0000000000..1923a60d63 --- /dev/null +++ b/tests/CourseBundle/Repository/CForumRepositoryTest.php @@ -0,0 +1,46 @@ +getManager(); + $repo = self::getContainer()->get(CForumRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CForum()) + ->setForumTitle('forum') + ->setParent($course) + ->setCreator($teacher) + ; + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('forum', (string) $item); + $this->assertSame(1, $repo->count([])); + } +} diff --git a/tests/CourseBundle/Repository/CGroupCategoryRepositoryTest.php b/tests/CourseBundle/Repository/CGroupCategoryRepositoryTest.php index db8dafbdc0..53008837e3 100644 --- a/tests/CourseBundle/Repository/CGroupCategoryRepositoryTest.php +++ b/tests/CourseBundle/Repository/CGroupCategoryRepositoryTest.php @@ -19,7 +19,7 @@ class CGroupCategoryRepositoryTest extends AbstractApiTest { self::bootKernel(); - $em = self::getContainer()->get('doctrine')->getManager(); + $em = $this->getManager(); $repo = self::getContainer()->get(CGroupCategoryRepository::class); $course = $this->createCourse('new'); diff --git a/tests/CourseBundle/Repository/CLinkCategoryRepositoryTest.php b/tests/CourseBundle/Repository/CLinkCategoryRepositoryTest.php new file mode 100644 index 0000000000..b05beb5f76 --- /dev/null +++ b/tests/CourseBundle/Repository/CLinkCategoryRepositoryTest.php @@ -0,0 +1,47 @@ +getManager(); + $repo = self::getContainer()->get(CLinkCategoryRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CLinkCategory()) + ->setCategoryTitle('cat') + ->setParent($course) + ->setCreator($teacher) + ; + + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('cat', (string) $item); + $this->assertSame(1, $repo->count([])); + } +} diff --git a/tests/CourseBundle/Repository/CLinkRepositoryTest.php b/tests/CourseBundle/Repository/CLinkRepositoryTest.php new file mode 100644 index 0000000000..178a09fe45 --- /dev/null +++ b/tests/CourseBundle/Repository/CLinkRepositoryTest.php @@ -0,0 +1,46 @@ +getManager(); + $repo = self::getContainer()->get(CLinkRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CLink()) + ->setUrl('https://chamilo.org') + ->setTitle('link') + ->setParent($course) + ->setCreator($teacher) + ; + + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('link', (string) $item); + $this->assertSame(1, $repo->count([])); + } +} diff --git a/tests/CourseBundle/Repository/CLpCategoryRepositoryTest.php b/tests/CourseBundle/Repository/CLpCategoryRepositoryTest.php index 77c16319c9..bc2cf659aa 100644 --- a/tests/CourseBundle/Repository/CLpCategoryRepositoryTest.php +++ b/tests/CourseBundle/Repository/CLpCategoryRepositoryTest.php @@ -19,7 +19,7 @@ class CLpCategoryRepositoryTest extends AbstractApiTest { self::bootKernel(); - $em = self::getContainer()->get('doctrine')->getManager(); + $em = $this->getManager(); $repo = self::getContainer()->get(CLpCategoryRepository::class); $course = $this->createCourse('new'); diff --git a/tests/CourseBundle/Repository/CLpRepositoryTest.php b/tests/CourseBundle/Repository/CLpRepositoryTest.php index 932d72a832..a45a12b535 100644 --- a/tests/CourseBundle/Repository/CLpRepositoryTest.php +++ b/tests/CourseBundle/Repository/CLpRepositoryTest.php @@ -19,7 +19,7 @@ class CLpRepositoryTest extends AbstractApiTest { self::bootKernel(); - $em = self::getContainer()->get('doctrine')->getManager(); + $em = $this->getManager(); $repo = self::getContainer()->get(CLpRepository::class); $course = $this->createCourse('new'); diff --git a/tests/CourseBundle/Repository/CQuizRepositoryTest.php b/tests/CourseBundle/Repository/CQuizRepositoryTest.php new file mode 100644 index 0000000000..25871476ae --- /dev/null +++ b/tests/CourseBundle/Repository/CQuizRepositoryTest.php @@ -0,0 +1,44 @@ +getManager(); + $repo = self::getContainer()->get(CQuizRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CQuiz()) + ->setTitle('exercise') + ->setParent($course) + ->setCreator($teacher) + ; + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('exercise', (string) $item); + $this->assertSame(1, $repo->count([])); + } +} diff --git a/tests/CourseBundle/Repository/CStudentPublicationRepositoryTest.php b/tests/CourseBundle/Repository/CStudentPublicationRepositoryTest.php new file mode 100644 index 0000000000..129577347b --- /dev/null +++ b/tests/CourseBundle/Repository/CStudentPublicationRepositoryTest.php @@ -0,0 +1,48 @@ +getManager(); + $repo = self::getContainer()->get(CStudentPublicationRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CStudentPublication()) + ->setTitle('publi') + ->setParent($course) + ->setFiletype('folder') + ->setWeight(100) + ->setCreator($teacher) + ; + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('publi', (string) $item); + $this->assertSame(1, $repo->count([])); + } +} diff --git a/tests/CourseBundle/Repository/CSurveyRepositoryTest.php b/tests/CourseBundle/Repository/CSurveyRepositoryTest.php new file mode 100644 index 0000000000..4246f1c0ff --- /dev/null +++ b/tests/CourseBundle/Repository/CSurveyRepositoryTest.php @@ -0,0 +1,44 @@ +getManager(); + $repo = self::getContainer()->get(CSurveyRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CSurvey()) + ->setTitle('survey') + ->setCode('survey') + ->setParent($course) + ->setCreator($teacher) + ; + + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('survey', (string) $item); + $this->assertSame(1, $repo->count([])); + } +} diff --git a/tests/CourseBundle/Repository/CThematicRepositoryTest.php b/tests/CourseBundle/Repository/CThematicRepositoryTest.php new file mode 100644 index 0000000000..9968501a31 --- /dev/null +++ b/tests/CourseBundle/Repository/CThematicRepositoryTest.php @@ -0,0 +1,46 @@ +getManager(); + $repo = self::getContainer()->get(CThematicRepository::class); + + $course = $this->createCourse('new'); + $teacher = $this->createUser('teacher'); + + $item = (new CThematic()) + ->setTitle('thematic') + ->setParent($course) + ->setCreator($teacher) + ; + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $this->assertSame('thematic', (string) $item); + $this->assertSame(1, $repo->count([])); + } +}