Merge branch 'master' of github.com:chamilo/chamilo-lms

pull/5101/head
Yannick Warnier 10 months ago
commit a3917cbb87
  1. 7
      assets/css/scss/atoms/_form.scss
  2. 8
      assets/vue/components/documents/FormNewDocument.vue
  3. 32
      public/main/inc/lib/formvalidator/Element/HtmlEditor.php
  4. 4
      public/main/session/session_add.php
  5. 16
      src/CoreBundle/Controller/CourseController.php
  6. 6
      src/CoreBundle/Entity/CourseRelUser.php
  7. 2
      src/CoreBundle/Entity/TrackEAttemptQualify.php
  8. 30
      src/CoreBundle/EventSubscriber/AnonymousUserSubscriber.php
  9. 2
      src/CoreBundle/Migrations/Schema/V200/Version20170524130000.php

@ -75,16 +75,21 @@
input:focus, input:focus,
input.p-filled, input.p-filled,
.html-editor-container,
textarea:focus, textarea:focus,
textarea.p-filled, textarea.p-filled,
.p-inputwrapper-focus, .p-inputwrapper-focus,
.p-inputwrapper-filled { .p-inputwrapper-filled {
~ label { ~ label {
@apply bg-white px-1 text-primary top-0 left-2; @apply bg-white px-1 text-primary top-0 left-2 text-tiny;
top: 0 !important; top: 0 !important;
} }
} }
.html-editor-container > div {
@apply pt-2 border-support-3 rounded-lg;
}
.p-invalid ~ label { .p-invalid ~ label {
@apply text-error; @apply text-error;
} }

@ -7,6 +7,9 @@
:label="$t('Title')" :label="$t('Title')"
/> />
<div class="field">
<div class="p-float-label">
<div class="html-editor-container">
<TinyEditor <TinyEditor
v-if=" v-if="
(item.resourceNode && (item.resourceNode &&
@ -37,6 +40,11 @@
}" }"
required required
/> />
</div>
<label v-t="'Content'"/>
</div>
</div>
<!-- For extra content--> <!-- For extra content-->
<slot></slot> <slot></slot>
</form> </form>

@ -104,4 +104,36 @@ class HtmlEditor extends HTML_QuickForm_textarea
return $result; return $result;
} }
public function getTemplate(string $layout): string
{
if (FormValidator::LAYOUT_HORIZONTAL === $layout) {
return '
<div class="field">
<div class="p-float-label">
<div class="html-editor-container">
{element}
{icon}
</div>
<label {label-for}>
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
</div>
<!-- BEGIN label_2 -->
<small>{label_2}</small>
<!-- END label_2 -->
<!-- BEGIN label_3 -->
<small>{label_3}</small>
<!-- END label_3 -->
<!-- BEGIN error -->
<small class="p-error">{error}</small>
<!-- END error -->
</div>';
}
return parent::getTemplate($layout);
}
} }

@ -253,7 +253,7 @@ $form->setDefaults($formDefaults);
if ($form->validate()) { if ($form->validate()) {
$params = $form->getSubmitValues(); $params = $form->getSubmitValues();
$name = $params['name']; $title = $params['title'];
$startDate = $params['access_start_date']; $startDate = $params['access_start_date'];
$endDate = $params['access_end_date']; $endDate = $params['access_end_date'];
$displayStartDate = $params['display_start_date']; $displayStartDate = $params['display_start_date'];
@ -309,7 +309,7 @@ if ($form->validate()) {
} }
$return = SessionManager::create_session( $return = SessionManager::create_session(
$name, $title,
$startDate, $startDate,
$endDate, $endDate,
$displayStartDate, $displayStartDate,

@ -22,7 +22,6 @@ use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
use Chamilo\CoreBundle\Repository\TagRepository; use Chamilo\CoreBundle\Repository\TagRepository;
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter; use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter;
use Chamilo\CoreBundle\Settings\SettingsManager; use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CoreBundle\Tool\AbstractTool;
use Chamilo\CoreBundle\Tool\ToolChain; use Chamilo\CoreBundle\Tool\ToolChain;
use Chamilo\CourseBundle\Controller\ToolBaseController; use Chamilo\CourseBundle\Controller\ToolBaseController;
use Chamilo\CourseBundle\Entity\CCourseDescription; use Chamilo\CourseBundle\Entity\CCourseDescription;
@ -129,9 +128,7 @@ class CourseController extends ToolBaseController
#[Entity('course', expr: 'repository.find(cid)')] #[Entity('course', expr: 'repository.find(cid)')]
public function indexJson( public function indexJson(
Request $request, Request $request,
CToolRepository $toolRepository,
CShortcutRepository $shortcutRepository, CShortcutRepository $shortcutRepository,
ToolChain $toolChain,
EntityManagerInterface $em, EntityManagerInterface $em,
): Response { ): Response {
$requestData = json_decode($request->getContent(), true); $requestData = json_decode($request->getContent(), true);
@ -851,19 +848,6 @@ class CourseController extends ToolBaseController
} }
} }
private function generateToolUrl(AbstractTool $tool): string
{
$link = $tool->getLink();
$course = $this->getCourse();
if (strpos($link, 'nodeId')) {
$nodeId = (string) $course->getResourceNode()->getId();
$link = str_replace(':nodeId', $nodeId, $link);
}
return $link.'?'.$this->getCourseUrlQuery();
}
// Implement the real logic to check course enrollment // Implement the real logic to check course enrollment
private function isUserEnrolledInAnyCourse(User $user, EntityManagerInterface $em): bool private function isUserEnrolledInAnyCourse(User $user, EntityManagerInterface $em): bool
{ {

@ -60,12 +60,12 @@ class CourseRelUser implements Stringable
protected ?int $id = null; protected ?int $id = null;
#[Groups(['course:read', 'user:read', 'course_rel_user:read'])] #[Groups(['course:read', 'user:read', 'course_rel_user:read'])]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'courses', cascade: ['persist'])] #[ORM\ManyToOne(targetEntity: User::class, cascade: ['persist'], inversedBy: 'courses')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected User $user; protected User $user;
#[Groups(['course_rel_user:read'])] #[Groups(['course_rel_user:read'])]
#[ORM\ManyToOne(targetEntity: Course::class, inversedBy: 'users', cascade: ['persist'])] #[ORM\ManyToOne(targetEntity: Course::class, cascade: ['persist'], inversedBy: 'users')]
#[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', onDelete: 'CASCADE')] #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected Course $course; protected Course $course;

@ -53,7 +53,7 @@ class TrackEAttemptQualify
protected ?string $answer; protected ?string $answer;
#[ORM\ManyToOne(inversedBy: 'revisedAttempts')] #[ORM\ManyToOne(inversedBy: 'revisedAttempts')]
#[ORM\JoinColumn(name: 'exe_id', referencedColumnName: 'exe_id', nullable: false)] #[ORM\JoinColumn(name: 'exe_id', referencedColumnName: 'exe_id', nullable: false, onDelete: 'CASCADE')]
private ?TrackEExercise $trackExercise = null; private ?TrackEExercise $trackExercise = null;
public function __construct() public function __construct()

@ -6,8 +6,6 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\EventSubscriber; namespace Chamilo\CoreBundle\EventSubscriber;
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Entity\TrackELogin; use Chamilo\CoreBundle\Entity\TrackELogin;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Settings\SettingsManager; use Chamilo\CoreBundle\Settings\SettingsManager;
@ -125,8 +123,6 @@ class AnonymousUserSubscriber implements EventSubscriberInterface
if ($oldestAnonymousUser) { if ($oldestAnonymousUser) {
error_log('Deleting oldest anonymous user: '.$oldestAnonymousUser->getId()); error_log('Deleting oldest anonymous user: '.$oldestAnonymousUser->getId());
$this->handleRelatedEntities($oldestAnonymousUser);
$this->entityManager->remove($oldestAnonymousUser); $this->entityManager->remove($oldestAnonymousUser);
$this->entityManager->flush(); $this->entityManager->flush();
} }
@ -158,30 +154,4 @@ class AnonymousUserSubscriber implements EventSubscriberInterface
return $anonymousUser->getId(); return $anonymousUser->getId();
} }
private function handleRelatedEntities(User $user): void
{
$trackEExercisesRepository = $this->entityManager->getRepository(TrackEExercise::class);
$exercises = $trackEExercisesRepository->findBy(['user' => $user->getId()]);
foreach ($exercises as $exercise) {
$this->handleAttemptRecordings($exercise);
$this->entityManager->remove($exercise);
}
$this->entityManager->flush();
}
private function handleAttemptRecordings(TrackEExercise $exercise): void
{
$trackEAttemptRecordingRepository = $this->entityManager->getRepository(TrackEAttemptQualify::class);
$attemptRecordings = $trackEAttemptRecordingRepository->findBy(['trackExercise' => $exercise->getExeId()]);
foreach ($attemptRecordings as $attemptRecording) {
$this->entityManager->remove($attemptRecording);
}
}
} }

@ -7,7 +7,7 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
final class Version20230622150000 extends AbstractMigrationChamilo final class Version20170524130000 extends AbstractMigrationChamilo
{ {
public function getDescription(): string public function getDescription(): string
{ {
Loading…
Cancel
Save