Merge remote-tracking branch 'origin/master'

pull/5401/head
Angel Fernando Quiroz Campos 1 year ago
commit 029f1463d7
  1. 16
      public/main/inc/lib/extra_field.lib.php
  2. 4
      public/main/my_space/myStudents.php
  3. 4
      src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
  4. 12
      src/CoreBundle/Entity/ExtraField.php
  5. 15
      src/CoreBundle/Entity/ExtraFieldOptions.php
  6. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201212114900.php
  7. 18
      src/CoreBundle/Migrations/Schema/V200/Version20240413234500.php
  8. 53
      tests/CoreBundle/Repository/ExtraFieldOptionsRepositoryTest.php
  9. 70
      tests/CoreBundle/Repository/ExtraFieldRepositoryTest.php
  10. 8
      translations/messages.en.po
  11. 4
      translations/messages.pot

@ -2361,23 +2361,7 @@ class ExtraField extends Model
}
$form->addElement('header', $header);
if ('edit' === $action) {
$translateUrl = api_get_path(WEB_CODE_PATH).'extrafield/translate.php?'.http_build_query(['id' => $id]);
$translateButton = Display::toolbarButton(
get_lang('Translate this term'),
$translateUrl,
'language',
'link'
);
$form->addText(
'display_text',
[get_lang('Name'), $translateButton]
);
} else {
$form->addElement('text', 'display_text', get_lang('Name'));
}
$form->addHtmlEditor('description', get_lang('Description'), false);

@ -1859,8 +1859,8 @@ if (empty($details)) {
get_lang('Average score')
).'</th>';
echo '<th>'.get_lang('Attempts').'</th>';
echo '<th>'.get_lang('LatestAttempt').'</th>';
echo '<th>'.get_lang('AllAttempts').'</th>';
echo '<th>'.get_lang('Latest attempt').'</th>';
echo '<th>'.get_lang('All attempts').'</th>';
/*$hookQuizTracking = HookMyStudentsQuizTracking::create();
if ($hookQuizTracking) {

@ -2714,12 +2714,12 @@ class SettingsCurrentFixtures extends Fixture implements FixtureGroupInterface
[
"name" => "gradebook_badge_sidebar",
"title" => "Gradebook badges sidebar",
"comment" => "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires badges and gradebooks pour être ",
"comment" => "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires gradebooks to be listed here, by (numerical) ID.",
],
[
"name" => "gradebook_dependency",
"title" => "Inter-gradebook dependencies",
"comment" => "Enables a mechanism of gradebook dependencies that lets people know ",
"comment" => "Enables a mechanism of gradebook dependencies that lets people know which other items they need to go through first in order to complete the gradbeook.",
],
[
"name" => "gradebook_dependency_mandatory_courses",

@ -97,8 +97,6 @@ class ExtraField
#[Gedmo\Translatable]
#[ORM\Column(name: 'display_text', type: 'string', length: 255, nullable: true, unique: false)]
protected ?string $displayText = null;
#[Gedmo\Locale]
protected ?string $locale = null;
#[ORM\Column(name: 'helper_text', type: 'text', nullable: true, unique: false)]
protected ?string $helperText = null;
#[ORM\Column(name: 'default_value', type: 'text', nullable: true, unique: false)]
@ -318,16 +316,6 @@ class ExtraField
return $this;
}
public function setTranslatableLocale($locale): static
{
$this->locale = $locale;
return $this;
}
public function getTranslatableLocale(): ?string
{
return $this->locale;
}
public function getAutoRemove(): bool
{

@ -33,9 +33,6 @@ class ExtraFieldOptions
#[ORM\Column(name: 'display_text', type: 'string', length: 255, nullable: true)]
protected ?string $displayText = null;
#[Gedmo\Locale]
protected ?string $locale = null;
#[ORM\Column(name: 'priority', type: 'string', length: 255, nullable: true)]
protected ?string $priority = null;
@ -133,16 +130,4 @@ class ExtraFieldOptions
return $this;
}
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
return $this;
}
public function getTranslatableLocale()
{
return $this->locale;
}
}

@ -9,7 +9,7 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20240414014200 extends AbstractMigrationChamilo
class Version20201212114900 extends AbstractMigrationChamilo
{
public function getDescription(): string
{

@ -26,15 +26,23 @@ final class Version20240413234500 extends AbstractMigrationChamilo
}
if ($schema->hasTable('portfolio_comment')) {
$table = $schema->getTable('portfolio_comment');
if (!$table->hasColumn('visibility')) {
$this->addSql('ALTER TABLE portfolio_comment ADD visibility SMALLINT DEFAULT 1 NOT NULL');
}
}
if ($schema->hasTable('portfolio_category')) {
$table = $schema->getTable('portfolio_category');
if (!$table->hasColumn('parent_id')) {
$this->addSql('ALTER TABLE portfolio_category ADD parent_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE portfolio_category ADD CONSTRAINT FK_7AC64359727ACA70 FOREIGN KEY (parent_id) REFERENCES portfolio_category (id) ON DELETE SET NULL');
}
if (!$table->hasIndex('IDX_7AC64359727ACA70')) {
$this->addSql('CREATE INDEX IDX_7AC64359727ACA70 ON portfolio_category (parent_id)');
}
}
}
public function down(Schema $schema): void
{
@ -43,13 +51,23 @@ final class Version20240413234500 extends AbstractMigrationChamilo
}
if ($schema->hasTable('portfolio_comment')) {
$table = $schema->getTable('portfolio_comment');
if ($table->hasColumn('visibility')) {
$this->addSql('ALTER TABLE portfolio_comment DROP COLUMN visibility');
}
}
if ($schema->hasTable('portfolio_category')) {
$table = $schema->getTable('portfolio_category');
if ($table->hasForeignKey('FK_7AC64359727ACA70')) {
$this->addSql('ALTER TABLE portfolio_category DROP FOREIGN KEY FK_7AC64359727ACA70');
}
if ($table->hasColumn('parent_id')) {
$this->addSql('ALTER TABLE portfolio_category DROP COLUMN parent_id');
}
if ($table->hasIndex('IDX_7AC64359727ACA70')) {
$this->addSql('DROP INDEX IDX_7AC64359727ACA70 ON portfolio_category');
}
}
}
}

@ -12,7 +12,6 @@ use Chamilo\CoreBundle\Repository\ExtraFieldOptionsRepository;
use Chamilo\CoreBundle\Repository\ExtraFieldRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;
use Gedmo\Translatable\Entity\Translation;
class ExtraFieldOptionsRepositoryTest extends AbstractApiTest
{
@ -58,56 +57,4 @@ class ExtraFieldOptionsRepositoryTest extends AbstractApiTest
$this->assertSame($defaultCount + 1, $extraFieldRepo->count([]));
$this->assertSame($defaultCountOptions + 1, $extraFieldOptionsRepo->count([]));
}
public function testCreateWithTranslation(): void
{
$this->testCreate();
$em = $this->getEntityManager();
$extraFieldOptionsRepo = static::getContainer()->get(ExtraFieldOptionsRepository::class);
/** @var ExtraFieldOptions $extraFieldOption */
$extraFieldOption = $extraFieldOptionsRepo->findOneBy(['value' => 'value']);
$this->assertNotNull($extraFieldOption);
$this->assertInstanceOf(ExtraFieldOptions::class, $extraFieldOption);
$extraFieldOption
->setTranslatableLocale('fr_FR')
->setDisplayText('test in FRENCH')
;
$em->persist($extraFieldOption);
$em->flush();
/** @var ExtraFieldOptions $extraFieldOption */
$extraFieldOption = $extraFieldOptionsRepo->find($extraFieldOption->getId());
$extraFieldOption
->setTranslatableLocale('pl')
->setDisplayText('test in POLISH')
;
$em->persist($extraFieldOption);
$em->flush();
$em->clear();
/** @var ExtraFieldOptions $extraFieldOption */
$extraFieldOption = $extraFieldOptionsRepo->find($extraFieldOption->getId());
$repository = $em->getRepository(Translation::class);
$translations = $repository->findTranslations($extraFieldOption);
$this->assertCount(2, $translations);
$expected = [
'fr_FR' => [
'displayText' => 'test in FRENCH',
],
'pl' => [
'displayText' => 'test in POLISH',
],
];
$this->assertSame($expected, $translations);
/** @var ExtraFieldOptions $extraFieldOption */
$extraFieldOption = $extraFieldOptionsRepo->find($extraFieldOption->getId());
$this->assertSame('test in ENGLISH', $extraFieldOption->getDisplayText());
}
}

@ -11,7 +11,6 @@ use Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch;
use Chamilo\CoreBundle\Repository\ExtraFieldRepository;
use Chamilo\Tests\AbstractApiTest;
use Chamilo\Tests\ChamiloTestTrait;
use Gedmo\Translatable\Entity\Translation;
class ExtraFieldRepositoryTest extends AbstractApiTest
{
@ -57,75 +56,6 @@ class ExtraFieldRepositoryTest extends AbstractApiTest
$this->assertSame($defaultCount + 1, $repo->count([]));
}
public function testCreateWithTranslation(): void
{
$em = $this->getEntityManager();
// $extraFieldRepo = static::getContainer()->get(ExtraFieldRepository::class);
$extraFieldRepo = $em->getRepository(ExtraField::class);
$translator = static::getContainer()->get('translator');
$defaultLocale = $translator->getLocale();
$this->assertSame('en_US', $defaultLocale);
$defaultCount = $extraFieldRepo->count([]);
$extraField = (new ExtraField())
->setDisplayText('test in ENGLISH')
->setVariable('test in en')
->setItemType(ExtraField::USER_FIELD_TYPE)
->setValueType(\ExtraField::FIELD_TYPE_TEXT)
;
$this->assertHasNoEntityViolations($extraField);
$em->persist($extraField);
$em->flush();
$this->assertSame($defaultCount + 1, $extraFieldRepo->count([]));
/** @var ExtraField $extraField */
$extraField = $extraFieldRepo->find($extraField->getId());
$extraField
->setTranslatableLocale('fr_FR')
->setDisplayText('test in FRENCH')
;
$em->persist($extraField);
$em->flush();
/** @var ExtraField $extraField */
$extraField = $extraFieldRepo->find($extraField->getId());
$extraField
->setTranslatableLocale('it')
->setDisplayText('test in ITALIAN')
;
$em->persist($extraField);
$em->flush();
$em->clear();
$this->assertSame($defaultCount + 1, $extraFieldRepo->count([]));
/** @var ExtraField $extraField */
$extraField = $extraFieldRepo->find($extraField->getId());
$repository = $em->getRepository(Translation::class);
$translations = $repository->findTranslations($extraField);
$this->assertCount(2, $translations);
$expected = [
'fr_FR' => [
'displayText' => 'test in FRENCH',
],
'it' => [
'displayText' => 'test in ITALIAN',
],
];
$this->assertSame($expected, $translations);
/** @var ExtraField $extraField */
$extraField = $extraFieldRepo->find($extraField->getId());
$this->assertSame('test in ENGLISH', $extraField->getDisplayText());
}
public function testGetExtraFields(): void
{
$repo = static::getContainer()->get(ExtraFieldRepository::class);

@ -26191,8 +26191,8 @@ msgstr "Use global score display setting in gradebook"
msgid "Inter-gradebook dependencies"
msgstr "Inter-gradebook dependencies"
msgid "Enables a mechanism of gradebook dependencies that lets people know "
msgstr "Enables a mechanism of gradebook dependencies that lets people know "
msgid "Enables a mechanism of gradebook dependencies that lets people know which other items they need to go through first in order to complete the gradbeook."
msgstr "Enables a mechanism of gradebook dependencies that lets people know which other items they need to go through first in order to complete the gradbeook."
msgid "Mandatory courses for gradebook dependencies"
msgstr "Mandatory courses for gradebook dependencies"
@ -26203,8 +26203,8 @@ msgstr "When using inter-gradebook dependencies, you can choose a list of mandat
msgid "Gradebook badges sidebar"
msgstr "Gradebook badges sidebar"
msgid "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires badges and gradebooks pour être "
msgstr "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires badges and gradebooks pour être "
msgid "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires gradebooks to be listed here, by (numerical) ID."
msgstr "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires gradebooks to be listed here, by (numerical) ID."
msgid "Allow multiple evaluation attempts in gradebook"
msgstr "Allow multiple evaluation attempts in gradebook"

@ -26184,7 +26184,7 @@ msgstr ""
msgid "Inter-gradebook dependencies"
msgstr ""
msgid "Enables a mechanism of gradebook dependencies that lets people know "
msgid "Enables a mechanism of gradebook dependencies that lets people know which other items they need to go through first in order to complete the gradbeook."
msgstr ""
msgid "Mandatory courses for gradebook dependencies"
@ -26196,7 +26196,7 @@ msgstr ""
msgid "Gradebook badges sidebar"
msgstr ""
msgid "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires badges and gradebooks pour être "
msgid "Generate a sidebar into the side menu where a few badges can be shown as pending approval. Requires gradebooks to be listed here, by (numerical) ID."
msgstr ""
msgid "Allow multiple evaluation attempts in gradebook"

Loading…
Cancel
Save