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. 66
      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.p-filled,
.html-editor-container,
textarea:focus,
textarea.p-filled,
.p-inputwrapper-focus,
.p-inputwrapper-filled {
~ 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;
}
}
.html-editor-container > div {
@apply pt-2 border-support-3 rounded-lg;
}
.p-invalid ~ label {
@apply text-error;
}

@ -7,36 +7,44 @@
:label="$t('Title')"
/>
<TinyEditor
v-if="
(item.resourceNode &&
item.resourceNode.resourceFile &&
item.resourceNode.resourceFile.text) ||
item.newDocument
"
id="item_content"
v-model="item.contentFile"
:init="{
skin_url: '/build/libs/tinymce/skins/ui/oxide',
content_css: '/build/libs/tinymce/skins/content/default/content.css',
branding: false,
relative_urls: false,
height: 500,
toolbar_mode: 'sliding',
file_picker_callback: browser,
autosave_ask_before_unload: true,
plugins: [
'fullpage advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste wordcount emoticons ' +
<div class="field">
<div class="p-float-label">
<div class="html-editor-container">
<TinyEditor
v-if="
(item.resourceNode &&
item.resourceNode.resourceFile &&
item.resourceNode.resourceFile.text) ||
item.newDocument
"
id="item_content"
v-model="item.contentFile"
:init="{
skin_url: '/build/libs/tinymce/skins/ui/oxide',
content_css: '/build/libs/tinymce/skins/content/default/content.css',
branding: false,
relative_urls: false,
height: 500,
toolbar_mode: 'sliding',
file_picker_callback: browser,
autosave_ask_before_unload: true,
plugins: [
'fullpage advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste wordcount emoticons ' +
extraPlugins,
],
toolbar:
'undo redo | bold italic underline strikethrough | insertfile image media template link | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | code codesample | ltr rtl | ' +
extraPlugins,
],
toolbar:
'undo redo | bold italic underline strikethrough | insertfile image media template link | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | code codesample | ltr rtl | ' +
extraPlugins,
}"
required
/>
}"
required
/>
</div>
<label v-t="'Content'"/>
</div>
</div>
<!-- For extra content-->
<slot></slot>
</form>

@ -104,4 +104,36 @@ class HtmlEditor extends HTML_QuickForm_textarea
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()) {
$params = $form->getSubmitValues();
$name = $params['name'];
$title = $params['title'];
$startDate = $params['access_start_date'];
$endDate = $params['access_end_date'];
$displayStartDate = $params['display_start_date'];
@ -309,7 +309,7 @@ if ($form->validate()) {
}
$return = SessionManager::create_session(
$name,
$title,
$startDate,
$endDate,
$displayStartDate,

@ -22,7 +22,6 @@ use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
use Chamilo\CoreBundle\Repository\TagRepository;
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CoreBundle\Tool\AbstractTool;
use Chamilo\CoreBundle\Tool\ToolChain;
use Chamilo\CourseBundle\Controller\ToolBaseController;
use Chamilo\CourseBundle\Entity\CCourseDescription;
@ -129,9 +128,7 @@ class CourseController extends ToolBaseController
#[Entity('course', expr: 'repository.find(cid)')]
public function indexJson(
Request $request,
CToolRepository $toolRepository,
CShortcutRepository $shortcutRepository,
ToolChain $toolChain,
EntityManagerInterface $em,
): Response {
$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
private function isUserEnrolledInAnyCourse(User $user, EntityManagerInterface $em): bool
{

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

@ -53,7 +53,7 @@ class TrackEAttemptQualify
protected ?string $answer;
#[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;
public function __construct()

@ -6,8 +6,6 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\EventSubscriber;
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Entity\TrackELogin;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Settings\SettingsManager;
@ -125,8 +123,6 @@ class AnonymousUserSubscriber implements EventSubscriberInterface
if ($oldestAnonymousUser) {
error_log('Deleting oldest anonymous user: '.$oldestAnonymousUser->getId());
$this->handleRelatedEntities($oldestAnonymousUser);
$this->entityManager->remove($oldestAnonymousUser);
$this->entityManager->flush();
}
@ -158,30 +154,4 @@ class AnonymousUserSubscriber implements EventSubscriberInterface
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 Doctrine\DBAL\Schema\Schema;
final class Version20230622150000 extends AbstractMigrationChamilo
final class Version20170524130000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
Loading…
Cancel
Save