Skip to content

Commit

Permalink
[Cursus] adds plain description on course and session
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Feb 10, 2021
1 parent 584ab16 commit 87ac9c5
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/core/Resources/translations/platform.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1633,5 +1633,7 @@
"start": "Start",
"root": "Root",
"support": "Assistance",
"further_information": "Further information"
"further_information": "Further information",
"plain_description": "Summary",
"plain_description_help": "The summary is displayed in lists instead of the HTML description."
}
4 changes: 3 additions & 1 deletion src/main/core/Resources/translations/platform.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1665,5 +1665,7 @@
"start": "Début",
"root": "Racine",
"support": "Assistance",
"further_information": "Informations complémentaires"
"further_information": "Informations complémentaires",
"plain_description": "Résumé",
"plain_description_help": "Le résumé est affiché dans les listes à la place de la description HTML."
}
18 changes: 17 additions & 1 deletion src/plugin/cursus/Entity/AbstractTraining.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class AbstractTraining
{
use Id;
use Uuid;

use Code;
use Description;
use Order;
Expand All @@ -50,6 +49,13 @@ class AbstractTraining
*/
protected $name;

/**
* @ORM\Column(nullable=true)
*
* @var string
*/
protected $plainDescription;

/**
* @ORM\ManyToOne(targetEntity="Claroline\CoreBundle\Entity\Workspace\Workspace")
* @ORM\JoinColumn(name="workspace_id", nullable=true, onDelete="SET NULL")
Expand Down Expand Up @@ -96,6 +102,16 @@ public function setName($name)
$this->name = $name;
}

public function getPlainDescription(): ?string
{
return $this->plainDescription;
}

public function setPlainDescription(string $description = null)
{
$this->plainDescription = $description;
}

public function getWorkspace()
{
return $this->workspace;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/cursus/Entity/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function hasAvailableSession()
{
$now = new \DateTime();
foreach ($this->sessions as $session) {
if ($session->getEndDate() > $now) {
if (empty($session->getEndDate()) || $session->getEndDate() > $now) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Claroline\CursusBundle\Installation\Migrations\pdo_mysql;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated migration based on mapping information: modify it with caution.
*
* Generation date: 2021/02/10 07:57:03
*/
class Version20210210075649 extends AbstractMigration
{
public function up(Schema $schema)
{
$this->addSql('
ALTER TABLE claro_cursusbundle_course
ADD plainDescription VARCHAR(255) DEFAULT NULL
');
$this->addSql('
ALTER TABLE claro_cursusbundle_course_session
ADD plainDescription VARCHAR(255) DEFAULT NULL
');
}

public function down(Schema $schema)
{
$this->addSql('
ALTER TABLE claro_cursusbundle_course
DROP plainDescription
');
$this->addSql('
ALTER TABLE claro_cursusbundle_course_session
DROP plainDescription
');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CourseCard = props =>
icon="fa fa-graduation-cap"
title={props.data.name}
subtitle={props.data.code}
contentText={props.data.description}
contentText={props.data.plainDescription || props.data.description}
flags={[
get(props.data, 'restrictions.hidden') && ['fa fa-eye-slash', trans('training_hidden', {}, 'cursus')],
get(props.data, 'registration.selfRegistration') && ['fa fa-globe', trans('training_public_registration', {}, 'cursus')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const CourseForm = (props) =>
name: 'description',
type: 'html',
label: trans('description')
}, {
name: 'plainDescription',
type: 'string',
label: trans('plain_description'),
options: {long: true},
help: trans('plain_description_help')
}, {
name: 'meta.duration',
type: 'number',
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/cursus/Resources/modules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Course = {
code: T.string,
name: T.string,
description: T.string,
plainDescription: T.string,
parent: T.shape({ // This is a minimal Course
id: T.string,
code: T.string,
Expand Down Expand Up @@ -63,6 +64,7 @@ const Session = {
code: T.string,
name: T.string,
description: T.string,
plainDescription: T.string,
meta: T.shape({
default: T.bool,
course: T.shape(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SessionCard = props =>
start: displayDate(props.data.restrictions.dates[0]),
end: displayDate(props.data.restrictions.dates[1])
})}
contentText={props.data.description}
contentText={props.data.plainDescription || props.data.description}
/>

SessionCard.propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ const SessionForm = (props) =>
name: 'description',
type: 'html',
label: trans('description')
}, {
name: 'plainDescription',
type: 'string',
label: trans('plain_description'),
options: {long: true},
help: trans('plain_description_help')
}, {
name: 'meta.default',
type: 'boolean',
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/cursus/Serializer/CourseSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function serialize(Course $course, array $options = []): array
'name' => $course->getName(),
'slug' => $course->getSlug(),
'description' => $course->getDescription(),
'plainDescription' => $course->getPlainDescription(),
'poster' => $this->serializePoster($course),
'thumbnail' => $this->serializeThumbnail($course),
'permissions' => [
Expand Down Expand Up @@ -154,6 +155,7 @@ public function deserialize(array $data, Course $course, array $options): Course
$this->sipe('code', 'setCode', $data, $course);
$this->sipe('name', 'setName', $data, $course);
$this->sipe('description', 'setDescription', $data, $course);
$this->sipe('plainDescription', 'setPlainDescription', $data, $course);

$this->sipe('meta.tutorRoleName', 'setTutorRoleName', $data, $course);
$this->sipe('meta.learnerRoleName', 'setLearnerRoleName', $data, $course);
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/cursus/Serializer/SessionSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function serialize(Session $session, array $options = []): array
'code' => $session->getCode(),
'name' => $session->getName(),
'description' => $session->getDescription(),
'plainDescription' => $session->getPlainDescription(),
'poster' => $this->serializePoster($session),
'thumbnail' => $this->serializeThumbnail($session),
'permissions' => [
Expand Down Expand Up @@ -158,6 +159,7 @@ public function deserialize(array $data, Session $session): Session
$this->sipe('code', 'setCode', $data, $session);
$this->sipe('name', 'setName', $data, $session);
$this->sipe('description', 'setDescription', $data, $session);
$this->sipe('plainDescription', 'setPlainDescription', $data, $session);

$this->sipe('meta.default', 'setDefaultSession', $data, $session);
$this->sipe('meta.order', 'setOrder', $data, $session);
Expand Down

0 comments on commit 87ac9c5

Please # to comment.