Minor: format code

pull/4963/head
Angel Fernando Quiroz Campos 1 year ago
parent 69df455075
commit 56ae3f994d
  1. 2
      src/CoreBundle/Controller/CourseController.php
  2. 2
      src/CoreBundle/Entity/Session.php
  3. 1
      src/CoreBundle/Entity/SessionRelCourse.php
  4. 2
      src/CoreBundle/Entity/SessionRelUser.php
  5. 9
      src/CoreBundle/Entity/TrackEAttemptRecording.php
  6. 3
      src/CoreBundle/Entity/User.php
  7. 4
      src/CoreBundle/Migrations/Schema/V200/Version20231004220000.php
  8. 20
      src/CoreBundle/Migrations/Schema/V200/Version20231022124700.php
  9. 7
      src/CoreBundle/Security/Authorization/Voter/CourseVoter.php
  10. 12
      src/CoreBundle/State/CategorizedExerciseResultStateProvider.php
  11. 2
      src/CoreBundle/Traits/UserExtraFieldFilterTrait.php
  12. 1
      src/CourseBundle/Entity/CQuizAnswer.php

@ -653,7 +653,7 @@ class CourseController extends ToolBaseController
}
$responseData['c_tool'] = [
'iid' => $ctool->getIid(),
'name' => $ctool->getName()
'name' => $ctool->getName(),
];
}

@ -40,7 +40,7 @@ use Symfony\Component\Validator\Constraints as Assert;
new Put(security: "is_granted('ROLE_ADMIN')"),
new GetCollection(security: "is_granted('ROLE_ADMIN')"),
new Post(security: "is_granted('ROLE_ADMIN')"),
new Delete(security: "is_granted('DELETE', object)")
new Delete(security: "is_granted('DELETE', object)"),
],
normalizationContext: ['groups' => ['session:read']],
denormalizationContext: ['groups' => ['session:write']],

@ -68,7 +68,6 @@ class SessionRelCourse
$this->position = 0;
}
public function getId(): ?int
{
return $this->id;

@ -28,7 +28,7 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource(
operations: [
new Get(security: "is_granted('ROLE_ADMIN') or object.user == user"),
new GetCollection(security: "is_granted('ROLE_USER')"),
new GetCollection(security: "is_granted('ROLE_USER')"),
new Post(security: "is_granted('ROLE_ADMIN')"),
],
normalizationContext: [

@ -8,7 +8,6 @@ namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
@ -31,10 +30,6 @@ class TrackEAttemptRecording
#[ORM\GeneratedValue]
protected ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'revisedAttempts')]
#[ORM\JoinColumn(name: 'exe_id', referencedColumnName: 'exe_id', nullable: false)]
private ?TrackEExercise $trackExercise = null;
#[ORM\Column(name: 'question_id', type: 'integer', nullable: false)]
protected int $questionId;
@ -57,6 +52,10 @@ class TrackEAttemptRecording
#[ORM\Column(name: 'answer', type: 'text', nullable: true)]
protected ?string $answer;
#[ORM\ManyToOne(inversedBy: 'revisedAttempts')]
#[ORM\JoinColumn(name: 'exe_id', referencedColumnName: 'exe_id', nullable: false)]
private ?TrackEExercise $trackExercise = null;
public function __construct()
{
$this->teacherComment = '';

@ -2361,7 +2361,8 @@ class User implements UserInterface, EquatableInterface, ResourceInterface, Reso
{
return $this
->getFriendsWithMeByRelationType($relationType)
->exists(fn (int $index, UserRelUser $userRelUser) => $userRelUser->getUser() === $friend);
->exists(fn (int $index, UserRelUser $userRelUser) => $userRelUser->getUser() === $friend)
;
}
/**

@ -6,11 +6,7 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CourseBundle\Entity\CCalendarEvent;
use DateTime;
use DateTimeZone;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\Exception\ORMException;
use Exception;

@ -416,11 +416,9 @@ final class Version20231022124700 extends AbstractMigrationChamilo
}
}
}
}
}
private function replaceURLParametersInContent($htmlContent, $connection)
{
$pattern = '/((https?:\/\/[^\/\s]*|)\/[^?\s]+?)\?cidReq=([a-zA-Z0-9_]+)(&(?:amp;)?id_session=([0-9]+))(&(?:amp;)?gidReq=([0-9]+))([^"\s]*)/i';
@ -432,7 +430,7 @@ final class Version20231022124700 extends AbstractMigrationChamilo
$code = $matches[3]; // The 'code' is extracted from the captured URL.
$courseId = null;
$sql = "SELECT id FROM course WHERE code = :code ORDER BY id DESC LIMIT 1";
$sql = 'SELECT id FROM course WHERE code = :code ORDER BY id DESC LIMIT 1';
$stmt = $connection->executeQuery($sql, ['code' => $code]);
$course = $stmt->fetch();
@ -440,7 +438,7 @@ final class Version20231022124700 extends AbstractMigrationChamilo
$courseId = $course['id'];
}
if ($courseId === null) {
if (null === $courseId) {
return $matches[0]; // Complete original URL.
}
@ -448,24 +446,22 @@ final class Version20231022124700 extends AbstractMigrationChamilo
$remainingParams = '';
if (!empty($matches[8])) {
$remainingParams = $matches[8];
if ($remainingParams[0] !== '&') {
$remainingParams = '&' . $remainingParams;
if ('&' !== $remainingParams[0]) {
$remainingParams = '&'.$remainingParams;
}
}
// Reconstructing the URL with the new courseId and adjusted parameters.
$newUrl = $matches[1] . '?cid=' . $courseId . '&sid=' . $matches[5] . '&gid=' . $matches[7] . $remainingParams;
return $newUrl; // Return the new URL.
return $matches[1].'?cid='.$courseId.'&sid='.$matches[5].'&gid='.$matches[7].$remainingParams;
// Return the new URL.
},
$htmlContent
);
if (preg_last_error() !== PREG_NO_ERROR) {
error_log('Error encountered in preg_replace_callback: ' . preg_last_error());
if (PREG_NO_ERROR !== preg_last_error()) {
error_log('Error encountered in preg_replace_callback: '.preg_last_error());
}
return $newContent;
}
}

@ -6,12 +6,11 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Security\Authorization\Voter;
use Doctrine\ORM\EntityManagerInterface;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;
@ -151,8 +150,8 @@ class CourseVoter extends Voter
return true;
}
}
break;
case self::EDIT:
case self::DELETE:

@ -11,6 +11,7 @@ use ApiPlatform\State\ProviderInterface;
use Chamilo\CoreBundle\ApiResource\CategorizedExerciseResult;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Security\Authorization\Voter\TrackEExerciseVoter;
use function count;
use Doctrine\ORM\EntityManagerInterface;
use Event;
use Exception;
@ -22,9 +23,6 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use TestCategory;
use function count;
use function in_array;
class CategorizedExerciseResultStateProvider implements ProviderInterface
{
public function __construct(
@ -98,7 +96,7 @@ class CategorizedExerciseResultStateProvider implements ProviderInterface
$show_results = false;
$show_only_score = false;
if (in_array(
if (\in_array(
$objExercise->results_disabled,
[
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,
@ -110,7 +108,7 @@ class CategorizedExerciseResultStateProvider implements ProviderInterface
$show_results = true;
}
if (in_array(
if (\in_array(
$objExercise->results_disabled,
[
RESULT_DISABLE_SHOW_SCORE_ONLY,
@ -133,7 +131,7 @@ class CategorizedExerciseResultStateProvider implements ProviderInterface
$showTotalScoreAndUserChoicesInLastAttempt = true;
$showTotalScore = true;
if (in_array(
if (\in_array(
$objExercise->results_disabled,
[
RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT,
@ -158,7 +156,7 @@ class CategorizedExerciseResultStateProvider implements ProviderInterface
);
if ($attempts) {
$numberAttempts = count($attempts);
$numberAttempts = \count($attempts);
}
$showTotalScore = false;

@ -11,7 +11,7 @@ use Chamilo\CoreBundle\Filter\UserExtraFieldFilter;
/**
* Properties to use as filters. To search by a user extra field.
* The API Resource must have a relation with User
* The API Resource must have a relation with User.
*/
trait UserExtraFieldFilterTrait
{

@ -110,7 +110,6 @@ class CQuizAnswer
return $this;
}
public function getPonderation(): float
{
return $this->ponderation;

Loading…
Cancel
Save