Script: Fix missing exit + update documentation

pull/4635/head
Yannick Warnier 3 years ago
parent 291d829b7b
commit b9ceee8704
  1. 16
      tests/scripts/delete_deleted_exercises_with_questions.php
  2. 3
      tests/scripts/delete_duplicate_documents.php
  3. 2
      tests/scripts/find_duplicate_documents_by_md5.php

@ -1,13 +1,17 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script cleans up tests and questions that were deleted from the
* platform interface but were left in the database for recovery purposes.
*/
exit;
require_once __DIR__ . '/../../main/inc/global.inc.php';
$sql = 'SELECT iid, c_id, title
FROM c_quiz
WHERE active = -1
$sql = 'SELECT iid, c_id, title
FROM c_quiz
WHERE active = -1
ORDER BY iid';
$result = Database::query($sql);
@ -24,7 +28,7 @@ foreach ($data as $row) {
$courseInfo = api_get_course_info_by_id($row['c_id']);
$sql = "SELECT question_id, c_id
$sql = "SELECT question_id, c_id
FROM c_quiz_rel_question
WHERE exercice_id = $id
ORDER BY iid";
@ -41,7 +45,7 @@ foreach ($data as $row) {
foreach ($questions as $questionData) {
$questionId = $questionData['question_id'];
// Check if question is used in another exercise:
$sql = "SELECT count(iid)
$sql = "SELECT count(iid)
FROM c_quiz_rel_question
WHERE exercice_id != $id AND question_id = $questionId";
$result = Database::query($sql);
@ -64,4 +68,4 @@ foreach ($data as $row) {
$sql = "DELETE FROM c_item_property WHERE ref = $id AND c_id = $courseId and tool = 'quiz' ";
$result = Database::query($sql);
}
}

@ -1,8 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script removes duplicated tests and questions created
* through something gone wrong in the course backup/copy process.
* This script removes duplicated documents.
* It identifies duplicate documents by title, path and size, and
* makes sure no usage is associated with the duplicated document, and
* that the duplicated document is not used in a learning path.

@ -15,7 +15,7 @@
*
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
//exit; //remove this line to execute from the command line
exit; //remove this line to execute from the command line
use ChamiloSession as Session;

Loading…
Cancel
Save