Minor - Fix 1.11.x CRUD

pull/3844/head
Julio Montoya 4 years ago
parent 6a8fc4e703
commit ea4a55a9ac
  1. 16
      public/main/exercise/answer.class.php
  2. 12
      public/main/exercise/exercise.class.php
  3. 53
      public/main/exercise/question.class.php
  4. 1
      public/main/inc/lib/thematic.lib.php
  5. 2
      public/main/survey/survey.lib.php
  6. 2
      src/CoreBundle/Entity/ResourceLink.php
  7. 2
      src/CourseBundle/Entity/CAttendance.php

@ -668,7 +668,7 @@ class Answer
$quizAnswer
->setAnswer($answer)
->setComment($comment)
->setCorrect($correct)
->setCorrect((int) $correct)
->setPonderation($weighting)
->setPosition($position)
->setDestination($destination)
@ -700,13 +700,13 @@ class Answer
for ($i = 1; $i <= $this->new_nbrAnswers; $i++) {
$answer = $this->new_answer[$i];
$correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : '';
$comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : '';
$weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : '';
$position = isset($this->new_position[$i]) ? $this->new_position[$i] : '';
$hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : '';
$hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : '';
$destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : '';
$correct = isset($this->new_correct[$i]) ? (int) $this->new_correct[$i] : null;
$comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : null;
$weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : null;
$position = isset($this->new_position[$i]) ? $this->new_position[$i] : null;
$hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : null;
$hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : null;
$destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : null;
//$autoId = $this->selectAutoId($i);
$iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;

@ -1573,8 +1573,8 @@ class Exercise
$description = $this->description;
$sound = $this->sound;
$type = $this->type;
$attempts = isset($this->attempts) ? $this->attempts : 0;
$feedback_type = isset($this->feedback_type) ? $this->feedback_type : 0;
$attempts = isset($this->attempts) ? (int) $this->attempts : 0;
$feedback_type = isset($this->feedback_type) ? (int) $this->feedback_type : 0;
$random = $this->random;
$random_answers = $this->random_answers;
$active = $this->active;
@ -1624,9 +1624,9 @@ class Exercise
->setDescription($description)
->setSound($sound)
->setType($type)
->setRandom($random)
->setRandomAnswers($random_answers)
->setActive($active)
->setRandom((int) $random)
->setRandomAnswers((bool) $random_answers)
->setActive((bool) $active)
->setResultsDisabled($results_disabled)
->setMaxAttempt($attempts)
->setFeedbackType($feedback_type)
@ -1638,7 +1638,7 @@ class Exercise
->setPassPercentage($pass_percentage)
->setSaveCorrectAnswers($saveCorrectAnswers)
->setPropagateNeg($propagate_neg)
->setHideQuestionTitle($this->getHideQuestionTitle())
->setHideQuestionTitle(1 === (int) $this->getHideQuestionTitle())
->setQuestionSelectionType($this->getQuestionSelectionType());
$allow = api_get_configuration_value('allow_exercise_categories');

@ -552,32 +552,33 @@ abstract class Question
if (!empty($id)) {
/** @var CQuizQuestion $question */
$question = $questionRepo->find($id);
$question
->setQuestion($this->question)
->setDescription($this->description)
->setPonderation($this->weighting)
->setPosition($this->position)
->setType($this->type)
->setExtra($this->extra)
->setLevel($this->level)
->setFeedback($this->feedback)
;
if (!empty($categoryId)) {
$category = $questionCategoryRepo->find($categoryId);
$question->updateCategory($category);
}
if ($question) {
$question
->setQuestion($this->question)
->setDescription($this->description)
->setPonderation($this->weighting)
->setPosition($this->position)
->setType($this->type)
->setExtra($this->extra)
->setLevel((int) $this->level)
->setFeedback($this->feedback);
if (!empty($categoryId)) {
$category = $questionCategoryRepo->find($categoryId);
$question->updateCategory($category);
}
$em->persist($question);
$em->flush();
$em->persist($question);
$em->flush();
Event::addEvent(
LOG_QUESTION_UPDATED,
LOG_QUESTION_ID,
$this->iid
);
if ('true' === api_get_setting('search_enabled')) {
$this->search_engine_edit($exerciseId);
Event::addEvent(
LOG_QUESTION_UPDATED,
LOG_QUESTION_ID,
$this->iid
);
if ('true' === api_get_setting('search_enabled')) {
$this->search_engine_edit($exerciseId);
}
}
} else {
// Creates a new question
@ -604,7 +605,7 @@ abstract class Question
->setPosition($position)
->setType($this->type)
->setExtra($this->extra)
->setLevel($this->level)
->setLevel((int)$this->level)
->setFeedback($this->feedback)
//->setParent($exerciseEntity)
->setParent($courseEntity)
@ -1170,7 +1171,7 @@ abstract class Question
public static function getInstance($type)
{
if (null !== $type) {
list($fileName, $className) = self::get_question_type($type);
[$fileName, $className] = self::get_question_type($type);
if (!empty($fileName)) {
if (class_exists($className)) {
return new $className();

@ -593,6 +593,7 @@ class Thematic
$duration
) {
$em = Database::getManager();
$duration = (int) $duration;
if (null === $advance) {
$advance = new CThematicAdvance();

@ -353,7 +353,7 @@ class SurveyManager
->setCode(self::generateSurveyCode($values['survey_code']))
->setTitle($values['survey_title'])
->setSubtitle($values['survey_title'])
->setAuthor($_user['user_id'])
//->setAuthor($_user['user_id'])
->setLang($values['survey_language'])
->setAvailFrom($from)
->setAvailTill($until)

@ -56,7 +56,7 @@ class ResourceLink
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
*/
protected ?User $user;
protected ?User $user = null;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroup")

@ -70,7 +70,7 @@ class CAttendance extends AbstractResource implements ResourceInterface
protected int $locked;
/**
* @var ArrayCollection|CAttendanceCalendar[]
* @var Collection|CAttendanceCalendar[]
*
* @ORM\OneToMany(
* targetEntity="CAttendanceCalendar", mappedBy="attendance", cascade={"persist", "remove"}, orphanRemoval=true

Loading…
Cancel
Save