Adding DB changes, remove course code use c_id #2247

pull/2650/head^2
Julio Montoya 6 years ago
parent 798ab228ee
commit 09b1417635
  1. 48
      app/Migrations/Schema/V200/Version20.php
  2. 2
      main/exercise/stats.php
  3. 5
      main/gradebook/lib/be/result.class.php
  4. 1
      main/inc/lib/api.lib.php
  5. 3
      main/inc/lib/events.lib.php
  6. 37
      main/inc/lib/exercise.lib.php
  7. 3
      main/session/resume_session.php
  8. 66
      src/CoreBundle/Entity/GradebookResultLog.php
  9. 51
      src/CoreBundle/Entity/Templates.php
  10. 32
      src/CoreBundle/Entity/TrackEHotspot.php
  11. 19
      src/CoreBundle/Entity/TrackEUploads.php
  12. 6
      src/CourseBundle/Entity/CQuizQuestionCategory.php

@ -143,7 +143,6 @@ class Version20 extends AbstractMigrationChamilo
}
$this->addSql('ALTER TABLE course_category CHANGE parent_id parent_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE course_category ADD CONSTRAINT FK_AFF87497727ACA70 FOREIGN KEY (parent_id) REFERENCES course_category (id);');
$this->addSql('ALTER TABLE settings_current ADD CONSTRAINT FK_62F79C3B9436187B FOREIGN KEY (access_url) REFERENCES access_url (id);');
$this->addSql('ALTER TABLE settings_current CHANGE variable variable VARCHAR(190) DEFAULT NULL, CHANGE subkey subkey VARCHAR(190) DEFAULT NULL;');
@ -250,7 +249,7 @@ class Version20 extends AbstractMigrationChamilo
$tables = [
'shared_survey',
'specific_field_values',
'templates'
'templates',
];
foreach ($tables as $table) {
@ -400,7 +399,7 @@ class Version20 extends AbstractMigrationChamilo
'show_glossary_in_documents' => 'document',
'show_glossary_in_extra_tools' => 'glossary',
//'show_toolshortcuts' => '',
'survey_email_sender_noreply'=> 'survey',
'survey_email_sender_noreply' => 'survey',
'allow_coach_feedback_exercises' => 'exercise',
'sessionadmin_autosubscribe' => 'registration',
'sessionadmin_page_after_login' => 'registration',
@ -410,7 +409,7 @@ class Version20 extends AbstractMigrationChamilo
'icons_mode_svg' => 'display',
'server_type' => 'platform',
'show_official_code_whoisonline' => 'platform',
'show_terms_if_profile_completed' => 'ticket'
'show_terms_if_profile_completed' => 'ticket',
];
foreach ($settings as $variable => $category) {
@ -639,7 +638,6 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE c_document ADD CONSTRAINT FK_C9FA0CBD1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id);');
$this->addSql('CREATE UNIQUE INDEX UNIQ_C9FA0CBD1BAD783F ON c_document (resource_node_id)');
$this->addSql('ALTER TABLE c_document CHANGE session_id session_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE c_document ADD CONSTRAINT FK_C9FA0CBD613FECDF FOREIGN KEY (session_id) REFERENCES session (id)');
$this->addSql('CREATE INDEX IDX_C9FA0CBD613FECDF ON c_document (session_id)');
@ -659,6 +657,45 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE access_url_rel_usergroup ADD CONSTRAINT FK_AD488DD573444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id)');
$this->addSql('CREATE INDEX IDX_AD488DD573444FD5 ON access_url_rel_usergroup (access_url_id)');
$this->addSql('ALTER TABLE track_e_exercises CHANGE session_id session_id INT NOT NULL');
// Update template
$this->addSql('DELETE FROM templates WHERE course_code NOT IN (SELECT code FROM course)');
$this->addSql('ALTER TABLE templates ADD c_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE templates ADD CONSTRAINT FK_6F287D8E91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)');
$this->addSql('UPDATE templates SET c_id = (SELECT id FROM course WHERE code = course_code)');
$this->addSql('ALTER TABLE gradebook_result_log CHANGE id_result result_id INT NOT NULL');
$this->addSql('ALTER TABLE c_quiz_question_category ADD session_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_quiz_question_category ADD CONSTRAINT FK_1414369D613FECDF FOREIGN KEY (session_id) REFERENCES session (id)');
// Drop unused columns
$dropColumnsAndIndex = [
'track_e_uploads' => ['columns' => ['upload_cours_id'], 'index' => ['upload_cours_id']],
'track_e_hotspot' => ['columns' => ['hotspot_course_code'], 'index' => ['hotspot_course_code']],
'templates' => ['columns' => ['course_code'], 'index' => []],
];
foreach ($dropColumnsAndIndex as $tableName => $data) {
if ($schema->hasTable($tableName)) {
$indexList = $data['index'];
foreach ($indexList as $index) {
if ($table->hasIndex($index)) {
$table->dropIndex($index);
}
}
$columns = $data['columns'];
$table = $schema->getTable($tableName);
foreach ($columns as $column) {
if ($table->hasColumn($column)) {
$table->dropColumn($column);
}
}
}
}
// Drop unused tables
$dropTables = ['event_email_template', 'event_sent', 'user_rel_event_type', 'openid_association'];
foreach ($dropTables as $table) {
@ -666,6 +703,7 @@ class Version20 extends AbstractMigrationChamilo
$schema->dropTable($table);
}
}
}
/**

@ -235,7 +235,7 @@ if (!empty($question_list)) {
$answer_id,
$question_id,
$exerciseId,
$courseCode,
api_get_course_int_id(),
$sessionId
);
$percentage = 0;

@ -230,14 +230,13 @@ class Result
public function addResultLog($userid, $evaluationid)
{
if (isset($userid) && isset($evaluationid)) {
$tbl_grade_results_log = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_LOG);
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_LOG);
$result = new Result();
$arr_result = $result->load(null, $userid, $evaluationid);
$arr = get_object_vars($arr_result[0]);
$sql = 'INSERT INTO '.$tbl_grade_results_log
.' (id_result,user_id, evaluation_id,created_at';
$sql = 'INSERT INTO '.$table.' (result_id,user_id, evaluation_id,created_at';
if (isset($arr['score'])) {
$sql .= ',score';
}

@ -8849,7 +8849,6 @@ function api_create_protected_dir($name, $parentDirectory)
* @param array Additional parameters
*
* @return bool true if mail was sent
*
*/
function api_mail_html(
$recipientName,

@ -305,7 +305,6 @@ class Event
$sql = "INSERT INTO $table
( upload_user_id,
c_id,
upload_cours_id,
upload_work_id,
upload_date,
upload_session_id
@ -313,7 +312,6 @@ class Event
VALUES (
$userId,
$courseId,
'',
$documentId,
'$reallyNow',
$sessionId
@ -742,7 +740,6 @@ class Event
return Database::insert(
$table,
[
'hotspot_course_code' => api_get_course_id(),
'hotspot_user_id' => api_get_user_id(),
'c_id' => api_get_course_int_id(),
'hotspot_exe_id' => $exeId,

@ -3958,11 +3958,11 @@ EOT;
/**
* Get number of answers to hotspot questions.
*
* @param int $answer_id
* @param int $question_id
* @param int $exercise_id
* @param string $course_code
* @param int $session_id
* @param int $answer_id
* @param int $question_id
* @param int $exercise_id
* @param int $courseId
* @param int $session_id
*
* @return int
*/
@ -3970,27 +3970,20 @@ EOT;
$answer_id,
$question_id,
$exercise_id,
$course_code,
$courseId,
$session_id
) {
$track_exercises = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_EXERCISES
);
$track_hotspot = Database::get_main_table(
TABLE_STATISTIC_TRACK_E_HOTSPOT
);
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$track_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$courseUserSession = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$courseUserSession = Database::get_main_table(
TABLE_MAIN_SESSION_COURSE_USER
);
$question_id = intval($question_id);
$answer_id = intval($answer_id);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$question_id = (int) $question_id;
$answer_id = (int) $answer_id;
$exercise_id = (int) $exercise_id;
$courseId = (int) $courseId;
$session_id = (int) $session_id;
if (empty($session_id)) {
$courseCondition = "
@ -4013,7 +4006,7 @@ EOT;
$courseCondition
WHERE
exe_exo_id = $exercise_id AND
a.hotspot_course_code = '$course_code' AND
a.c_id = $courseId AND
e.session_id = $session_id AND
hotspot_answer_id = $answer_id AND
hotspot_question_id = $question_id AND

@ -1,10 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\SessionRelCourse;
use Chamilo\CoreBundle\Entity\SequenceResource;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourse;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\CoreBundle\Repository\SequenceRepository;
use Chamilo\CoreBundle\Repository\SessionRepository;

@ -16,9 +16,18 @@ class GradebookResultLog
/**
* @var int
*
* @ORM\Column(name="id_result", type="integer", nullable=false)
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $idResult;
protected $id;
/**
* @var int
*
* @ORM\Column(name="result_id", type="integer", nullable=false)
*/
protected $resultId;
/**
* @var int
@ -48,39 +57,6 @@ class GradebookResultLog
*/
protected $score;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* Set idResult.
*
* @param int $idResult
*
* @return GradebookResultLog
*/
public function setIdResult($idResult)
{
$this->idResult = $idResult;
return $this;
}
/**
* Get idResult.
*
* @return int
*/
public function getIdResult()
{
return $this->idResult;
}
/**
* Set userId.
*
@ -186,4 +162,24 @@ class GradebookResultLog
{
return $this->id;
}
/**
* @return int
*/
public function getResultId(): int
{
return $this->resultId;
}
/**
* @param int $resultId
*
* @return GradebookResultLog
*/
public function setResultId(int $resultId): GradebookResultLog
{
$this->resultId = $resultId;
return $this;
}
}

@ -37,11 +37,12 @@ class Templates
protected $description;
/**
* @var string
* @var Course
*
* @ORM\Column(name="course_code", type="string", length=40, nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", cascade={"persist"})
* @ORM\JoinColumn(name="c_id", referencedColumnName="id")
*/
protected $courseCode;
protected $course;
/**
* @var int
@ -112,30 +113,6 @@ class Templates
return $this->description;
}
/**
* Set courseCode.
*
* @param string $courseCode
*
* @return Templates
*/
public function setCourseCode($courseCode)
{
$this->courseCode = $courseCode;
return $this;
}
/**
* Get courseCode.
*
* @return string
*/
public function getCourseCode()
{
return $this->courseCode;
}
/**
* Set userId.
*
@ -217,4 +194,24 @@ class Templates
{
return $this->id;
}
/**
* @return Course
*/
public function getCourse(): Course
{
return $this->course;
}
/**
* @param Course $course
*
* @return Templates
*/
public function setCourse(Course $course): Templates
{
$this->course = $course;
return $this;
}
}

@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping as ORM;
* TrackEHotspot.
*
* @ORM\Table(name="track_e_hotspot", indexes={
* @ORM\Index(name="hotspot_course_code", columns={"hotspot_course_code"}),
* @ORM\Index(name="hotspot_user_id", columns={"hotspot_user_id"}),
* @ORM\Index(name="hotspot_exe_id", columns={"hotspot_exe_id"}),
* @ORM\Index(name="hotspot_question_id", columns={"hotspot_question_id"})
@ -34,13 +33,6 @@ class TrackEHotspot
*/
protected $hotspotUserId;
/**
* @var string
*
* @ORM\Column(name="hotspot_course_code", type="string", length=50, nullable=false)
*/
protected $hotspotCourseCode;
/**
* @var int
*
@ -107,30 +99,6 @@ class TrackEHotspot
return $this->hotspotUserId;
}
/**
* Set hotspotCourseCode.
*
* @param string $hotspotCourseCode
*
* @return TrackEHotspot
*/
public function setHotspotCourseCode($hotspotCourseCode)
{
$this->hotspotCourseCode = $hotspotCourseCode;
return $this;
}
/**
* Get hotspotCourseCode.
*
* @return string
*/
public function getHotspotCourseCode()
{
return $this->hotspotCourseCode;
}
/**
* Set cId.
*

@ -13,7 +13,6 @@ use Doctrine\ORM\Mapping as ORM;
* indexes={
* @ORM\Index(name="course", columns={"c_id"}),
* @ORM\Index(name="upload_user_id", columns={"upload_user_id"}),
* @ORM\Index(name="upload_cours_id", columns={"upload_cours_id"}),
* @ORM\Index(name="upload_session_id", columns={"upload_session_id"})
* }
* )
@ -21,6 +20,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class TrackEUploads
{
/**
* @var int
*
* @ORM\Column(name="upload_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $uploadId;
/**
* @var int
*
@ -63,15 +71,6 @@ class TrackEUploads
*/
protected $uploadSessionId;
/**
* @var int
*
* @ORM\Column(name="upload_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $uploadId;
/**
* Set uploadUserId.
*

@ -55,6 +55,12 @@ class CQuizQuestionCategory
*/
protected $description;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", cascade={"persist"})
* @ORM\JoinColumn(name="session_id", referencedColumnName="id")
*/
protected $session;
/**
* Set title.
*

Loading…
Cancel
Save