Internal: Rename track_e_attempt_recording to track_e_attempt_qualify to improve understandability of purpose (#5072)

Author: Christian <christian1827@gmail.com>
pull/5076/head
Yannick Warnier 2 years ago committed by GitHub
parent 612f106906
commit ca8f3337c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      public/main/cron/import_csv.php
  2. 4
      public/main/exercise/exercise_history.php
  3. 5
      public/main/exercise/exercise_report.php
  4. 4
      public/main/exercise/exercise_result.class.php
  5. 2
      public/main/inc/lib/database.constants.inc.php
  6. 63
      public/main/inc/lib/events.lib.php
  7. 12
      public/main/inc/lib/exercise.lib.php
  8. 14
      public/main/inc/lib/tracking.lib.php
  9. 39
      src/CoreBundle/Entity/TrackEAttemptQualify.php
  10. 2
      src/CoreBundle/Entity/TrackEExercise.php
  11. 47
      src/CoreBundle/Migrations/Schema/V200/Version20230321154019.php
  12. 50
      src/CoreBundle/Migrations/Schema/V200/Version20230321164019.php
  13. 29
      src/CoreBundle/Migrations/Schema/V200/Version20230321165019.php

@ -3113,7 +3113,7 @@ class ImportCsv
Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS),
Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES),
Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT),
Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING),
Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY),
Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT),
Database::get_main_table(TABLE_STATISTIC_TRACK_E_UPLOADS),
Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT),

@ -42,7 +42,7 @@ $interbreadcrumb[] = [
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_EXERCISES_QUESTION = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$tblTrackAttemptQualify = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY);
Display::display_header(get_lang('Test'));
if (isset($_GET['message'])) {
@ -68,7 +68,7 @@ echo Display::toolbarAction('toolbar', [$actions]);
<?php
$sql = "SELECT *, quiz_question.question, firstname, lastname
FROM $TBL_TRACK_ATTEMPT_RECORDING t, $TBL_USER,
FROM $tblTrackAttemptQualify t, $TBL_USER,
$TBL_EXERCISES_QUESTION quiz_question
WHERE
quiz_question.id = question_id AND

@ -3,8 +3,8 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
use Chamilo\CoreBundle\Entity\TrackEAttemptRecording;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLp;
@ -56,7 +56,6 @@ $is_tutor = api_is_allowed_to_edit(true);
$TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$allowCoachFeedbackExercises = 'true' === api_get_setting('allow_coach_feedback_exercises');
$course_id = api_get_course_int_id();
@ -242,7 +241,7 @@ if (isset($_REQUEST['comments']) &&
['question_id = ? AND exe_id = ?' => [$questionId, $id]]
);
$recording = new TrackEAttemptRecording();
$recording = new TrackEAttemptQualify();
$recording
->setTrackExercise($trackExercise)
->setQuestionId($questionId)

@ -49,7 +49,7 @@ class ExerciseResult
$TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$tblTrackAttemptQualify = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY);
$cid = api_get_course_id();
$course_id = api_get_course_int_id();
@ -195,7 +195,7 @@ class ExerciseResult
} else {
//revised or not
$sql_exe = "SELECT exe_id
FROM $TBL_TRACK_ATTEMPT_RECORDING
FROM $tblTrackAttemptQualify
WHERE
author != '' AND
exe_id = ".(int) ($result['exid']).'

@ -114,7 +114,7 @@ define('TABLE_STATISTIC_TRACK_E_HOTPOTATOES', 'track_e_hotpotatoes');
define('TABLE_STATISTIC_TRACK_E_COURSE_ACCESS', 'track_e_course_access');
define('TABLE_STATISTIC_TRACK_E_EXERCISES', 'track_e_exercises');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT', 'track_e_attempt');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING', 'track_e_attempt_recording');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY', 'track_e_attempt_qualify');
define('TABLE_STATISTIC_TRACK_E_DEFAULT', 'track_e_default');
define('TABLE_STATISTIC_TRACK_E_UPLOADS', 'track_e_uploads');
define('TABLE_STATISTIC_TRACK_E_HOTSPOT', 'track_e_hotspot');

@ -5,7 +5,7 @@
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\Course as CourseEntity;
use Chamilo\CoreBundle\Entity\Session as SessionEntity;
use Chamilo\CoreBundle\Entity\TrackEAttemptRecording;
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Entity\TrackEDefault;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Entity\User;
@ -516,7 +516,7 @@ class Event
$position = (int) $position;
$course_id = (int) $course_id;
$now = api_get_utc_datetime();
$recording = ('true' === api_get_setting('exercise.quiz_answer_extra_recording'));
$recordingLog = ('true' === api_get_setting('exercise.quiz_answer_extra_recording'));
// check user_id or get from context
if (empty($user_id)) {
@ -611,20 +611,19 @@ class Event
error_log($sql);
}
$recording_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$em = Database::getManager();
if (false == $updateResults) {
$attempt_id = Database::insert($TBL_TRACK_ATTEMPT, $attempt);
$trackExercise = $em->find(TrackEExercise::class, $exe_id);
if ($attempt_id) {
$recording = new TrackEAttemptRecording();
if ($recordingLog) {
$recording = new TrackEAttemptQualify();
$recording
->setTrackExercise($trackExercise)
->setQuestionId($question_id)
->setAnswer($answer)
->setMarks((int) $score)
//->setAuthor('')
->setAuthor(api_get_user_id())
->setSessionId($session_id)
;
$em->persist($recording);
@ -646,28 +645,26 @@ class Event
]
);
if ($recording) {
$attempt_recording = [
'exe_id' => $exe_id,
'question_id' => $question_id,
'answer' => $answer,
'marks' => $score,
'insert_date' => $now,
'author' => '',
'session_id' => $session_id,
];
Database::update(
$recording_table,
$attempt_recording,
if ($recordingLog) {
$repoTrackQualify = $em->getRepository(TrackEAttemptQualify::class);
$trackQualify = $repoTrackQualify->findBy(
[
'exe_id = ? AND question_id = ? AND session_id = ? ' => [
$exe_id,
$question_id,
$session_id,
],
'exeId' => $exe_id,
'questionId' => $question_id,
'sessionId' => $session_id,
]
);
/** @var TrackEAttemptQualify $trackQualify */
$trackQualify
->setTrackExercise($exe_id)
->setQuestionId($question_id)
->setAnswer($answer)
->setMarks((int) $score)
->setAuthor(api_get_user_id())
->setSessionId($session_id)
;
$em->persist($trackQualify);
$em->flush();
}
$attempt_id = $exe_id;
}
@ -1104,7 +1101,7 @@ class Event
$track_e_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$track_attempts = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$recording_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$tblTrackAttemptQualify = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY);
$sessionCondition = api_get_session_condition($session_id);
// Make sure we have the exact lp_view_id
$sql = "SELECT iid FROM $lp_view_table
@ -1174,7 +1171,7 @@ class Event
WHERE exe_id IN ($exeListString)";
Database::query($sql);
$sql = "DELETE FROM $recording_table
$sql = "DELETE FROM $tblTrackAttemptQualify
WHERE exe_id IN ($exeListString)";
Database::query($sql);
}
@ -1411,7 +1408,7 @@ class Event
{
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$table_track_attempt_recording = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$tblTrackAttemptQualify = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY);
$exe_id = (int) $exe_id;
$status = Database::escape_string($status);
@ -1425,7 +1422,7 @@ class Event
$row = Database::fetch_array($res, 'ASSOC');
//Checking if this attempt was revised by a teacher
$sql_revised = "SELECT exe_id FROM $table_track_attempt_recording
$sql_revised = "SELECT exe_id FROM $tblTrackAttemptQualify
WHERE author != '' AND exe_id = $exe_id
LIMIT 1";
$res_revised = Database::query($sql_revised);
@ -1470,7 +1467,7 @@ class Event
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$table_track_attempt_recording = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$tblTrackAttemptQualify = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY);
$courseId = (int) $courseId;
$exercise_id = (int) $exercise_id;
$session_id = (int) $session_id;
@ -1499,7 +1496,7 @@ class Event
while ($row = Database::fetch_array($res, 'ASSOC')) {
// Checking if this attempt was revised by a teacher
$exeId = $row['exe_id'];
$sql = "SELECT exe_id FROM $table_track_attempt_recording
$sql = "SELECT exe_id FROM $tblTrackAttemptQualify
WHERE author != '' AND exe_id = $exeId
LIMIT 1";
$res_revised = Database::query($sql);
@ -1710,7 +1707,7 @@ class Event
$session_id = 0
) {
$table_track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$tblTrackAttemptQualify = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY);
$courseId = (int) $courseId;
$session_id = (int) $session_id;
$exercise_id = (int) $exercise_id;
@ -1719,7 +1716,7 @@ class Event
$sql = "SELECT count(e.exe_id) as count
FROM $table_track_exercises e
LEFT JOIN $table_track_attempt a
LEFT JOIN $tblTrackAttemptQualify a
ON e.exe_id = a.exe_id
WHERE
exe_exo_id = $exercise_id AND

@ -1917,11 +1917,11 @@ HOTSPOT;
api_is_student_boss() ||
api_is_session_admin();
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER);
$TBL_GROUP = Database::get_course_table(TABLE_GROUP);
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$tblTrackAttemptQualify = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_QUALIFY);
$session_id_and = '';
$sessionCondition = '';
@ -1939,8 +1939,8 @@ HOTSPOT;
$sql_inner_join_tbl_track_exercices = "
(
SELECT DISTINCT ttte.*, if(tr.exe_id,1, 0) as revised
FROM $TBL_TRACK_EXERCICES ttte
LEFT JOIN $TBL_TRACK_ATTEMPT_RECORDING tr
FROM $TBL_TRACK_EXERCISES ttte
LEFT JOIN $tblTrackAttemptQualify tr
ON (ttte.exe_id = tr.exe_id) AND tr.author > 0
WHERE
c_id = $courseId AND
@ -2081,7 +2081,7 @@ HOTSPOT;
}
$sql = " $sql_select
FROM $TBL_EXERCICES AS ce
FROM $TBL_EXERCISES AS ce
INNER JOIN $sql_inner_join_tbl_track_exercices AS te
ON (te.exe_exo_id = ce.iid)
INNER JOIN $sql_inner_join_tbl_user AS user

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
use Chamilo\CoreBundle\Entity\Session as SessionEntity;
@ -7023,7 +7024,6 @@ class Tracking
$TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$attemptRecording = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_TRACK_E_COURSE_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$TBL_TRACK_E_LAST_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
@ -7058,8 +7058,16 @@ class Tracking
//$sql = "UPDATE $TBL_TRACK_ATTEMPT SET session_id = '$new_session_id' WHERE exe_id = $exe_id";
//Database::query($sql);
$sql = "UPDATE $attemptRecording SET session_id = '$new_session_id' WHERE exe_id = $exe_id";
Database::query($sql);
$repoTrackQualify = $em->getRepository(TrackEAttemptQualify::class);
/** @var TrackEAttemptQualify $trackQualify */
$trackQualify = $repoTrackQualify->findBy([
'exeId' => $exe_id
]);
if ($trackQualify) {
$trackQualify->setSessionId($new_session_id);
$em->persist($trackQualify);
$em->flush();
}
if (!isset($result_message[$TABLETRACK_EXERCICES])) {
$result_message[$TABLETRACK_EXERCICES] = 0;

@ -18,12 +18,12 @@ use Gedmo\Mapping\Annotation as Gedmo;
],
security: 'is_granted("ROLE_USER")'
)]
#[ORM\Table(name: 'track_e_attempt_recording')]
#[ORM\Table(name: 'track_e_attempt_qualify')]
#[ORM\Index(columns: ['exe_id'], name: 'exe_id')]
#[ORM\Index(columns: ['question_id'], name: 'question_id')]
#[ORM\Index(columns: ['session_id'], name: 'session_id')]
#[ORM\Entity]
class TrackEAttemptRecording
class TrackEAttemptQualify
{
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
@ -68,7 +68,11 @@ class TrackEAttemptRecording
{
return $this->trackExercise;
}
/**
* Set exeId.
* @param ?TrackEExercise $trackExercise
* @return TrackEAttemptQualify
*/
public function setTrackExercise(?TrackEExercise $trackExercise): static
{
$this->trackExercise = $trackExercise;
@ -81,6 +85,11 @@ class TrackEAttemptRecording
return $this->questionId;
}
/**
* Set questionId.
* @param int $questionId
* @return TrackEAttemptQualify
*/
public function setQuestionId(int $questionId): static
{
$this->questionId = $questionId;
@ -93,6 +102,11 @@ class TrackEAttemptRecording
return $this->marks;
}
/**
* Set marks (score).
* @param float $marks
* @return TrackEAttemptQualify
*/
public function setMarks(float $marks): self
{
$this->marks = $marks;
@ -105,6 +119,11 @@ class TrackEAttemptRecording
return $this->insertDate;
}
/**
* Set insert date.
* @param DateTime $insertDate
* @return TrackEAttemptQualify
*/
public function setInsertDate(DateTime $insertDate): self
{
$this->insertDate = $insertDate;
@ -117,6 +136,11 @@ class TrackEAttemptRecording
return $this->author;
}
/**
* Set author.
* @param int $author
* @return TrackEAttemptQualify
*/
public function setAuthor(int $author): static
{
$this->author = $author;
@ -129,6 +153,10 @@ class TrackEAttemptRecording
return $this->teacherComment;
}
/**
* @param string $teacherComment
* @return TrackEAttemptQualify
*/
public function setTeacherComment(string $teacherComment): self
{
$this->teacherComment = $teacherComment;
@ -141,6 +169,11 @@ class TrackEAttemptRecording
return $this->sessionId;
}
/**
* Set sessionId.
* @param int $sessionId
* @return TrackEAttemptQualify
*/
public function setSessionId(int $sessionId): static
{
$this->sessionId = $sessionId;

@ -180,7 +180,7 @@ class TrackEExercise
protected Collection $attempts;
#[Groups(['track_e_exercise:read'])]
#[ORM\OneToMany(mappedBy: 'trackExercise', targetEntity: TrackEAttemptRecording::class, orphanRemoval: true)]
#[ORM\OneToMany(mappedBy: 'trackExercise', targetEntity: TrackEAttemptQualify::class, orphanRemoval: true)]
private Collection $revisedAttempts;
public function __construct()

@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20230321154019 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Create table track_e_attempt_qualify';
}
public function up(Schema $schema): void
{
if (!$schema->hasTable('track_e_attempt_qualify')) {
$this->addSql(
"CREATE TABLE track_e_attempt_qualify (
id INT AUTO_INCREMENT NOT NULL,
exe_id INT NOT NULL,
question_id INT NOT NULL,
marks INT NOT NULL,
insert_date DATETIME NOT NULL COMMENT '(DC2Type:datetime)',
author INT NOT NULL,
teacher_comment LONGTEXT NOT NULL,
session_id INT NOT NULL,
answer LONGTEXT DEFAULT NULL,
INDEX exe_id (exe_id), INDEX question_id (question_id),
INDEX session_id (session_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;"
);
}
}
public function down(Schema $schema): void
{
if ($schema->hasTable('track_e_attempt_qualify')) {
$this->addSql('DROP TABLE track_e_attempt_qualify;');
}
}
}

@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20230321164019 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Migrate track_e_attempt_recording';
}
public function up(Schema $schema): void
{
$container = $this->getContainer();
$doctrine = $container->get('doctrine');
$em = $doctrine->getManager();
$sql = 'SELECT * FROM track_e_attempt_recording';
$connection = $this->getEntityManager()->getConnection();
$result = $connection->executeQuery($sql);
$items = $result->fetchAllAssociative();
foreach ($items as $item) {
$trackQualify = new TrackEAttemptQualify();
$trackQualify
->setExeId($item['exe_id'])
->setQuestionId($item['question_id'])
->setAnswer($item['answer'])
->setMarks((int) $item['marks'])
->setAuthor($item['author'])
->setTeacherComment($item['teacher_comment'])
->setSessionId($item['session_id'])
;
$em->persist($trackQualify);
$em->flush();
}
}
public function down(Schema $schema): void
{
}
}

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20230321165019 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Delete track_e_attempt_recording';
}
public function up(Schema $schema): void
{
if ($schema->hasTable('track_e_attempt_recording')) {
$schema->dropTable('track_e_attempt_recording');
}
}
public function down(Schema $schema): void
{
}
}
Loading…
Cancel
Save