Remove deprecated function count_rows_course_table.

pull/2487/head
jmontoyaa 9 years ago
parent f9dd791b48
commit 139e3bbd04
  1. 113
      main/admin/course_information.php
  2. 43
      main/inc/lib/course.lib.php

@ -22,54 +22,70 @@ if (empty($courseInfo)) {
$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
/**
* @param array $course
* @param int $session_id
* @return array
*/
function get_course_usage($course, $session_id = 0)
{
$courseId = $course['real_id'];
// Learnpaths
$table = Database::get_course_table(TABLE_LP_MAIN);
$usage[] = array(
get_lang(ucfirst(TOOL_LEARNPATH)),
CourseManager::count_rows_course_table($table, $session_id, $courseId)
);
// Forums
$table = Database::get_course_table(TABLE_FORUM);
$usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $courseId));
// Quizzes
$table = Database::get_course_table(TABLE_QUIZ_TEST);
$usage[] = array(
get_lang(ucfirst(TOOL_QUIZ)),
CourseManager::count_rows_course_table($table, $session_id, $courseId)
);
// Documents
$table = Database::get_course_table(TABLE_DOCUMENT);
$usage[] = array(
get_lang(ucfirst(TOOL_DOCUMENT)),
CourseManager::count_rows_course_table($table, $session_id, $courseId)
);
// Groups
$table = Database::get_course_table(TABLE_GROUP);
$usage[] = array(
get_lang(ucfirst(TOOL_GROUP)),
CourseManager::count_rows_course_table($table, $session_id, $courseId)
);
// Calendar
$table = Database::get_course_table(TABLE_AGENDA);
$usage[] = array(
get_lang(ucfirst(TOOL_CALENDAR_EVENT)),
CourseManager::count_rows_course_table($table, $session_id, $courseId)
);
// Link
$table = Database::get_course_table(TABLE_LINK);
$usage[] = array(
get_lang(ucfirst(TOOL_LINK)),
CourseManager::count_rows_course_table($table, $session_id, $courseId)
);
// Announcements
$table = Database::get_course_table(TABLE_ANNOUNCEMENT);
$usage[] = array(
get_lang(ucfirst(TOOL_ANNOUNCEMENT)),
CourseManager::count_rows_course_table($table, $session_id, $courseId)
);
$tables = [
[
Database::get_course_table(TABLE_LP_MAIN),
get_lang(ucfirst(TOOL_LEARNPATH)),
],
[
Database::get_course_table(TABLE_FORUM),
get_lang('Forums'),
],
[
Database::get_course_table(TABLE_QUIZ_TEST),
get_lang(ucfirst(TOOL_QUIZ)),
],
[
Database::get_course_table(TABLE_DOCUMENT),
get_lang(ucfirst(TOOL_DOCUMENT)),
],
[
Database::get_course_table(TABLE_GROUP),
get_lang(ucfirst(TOOL_GROUP)),
],
[
Database::get_course_table(TABLE_AGENDA),
get_lang('Calendar'),
],
[
Database::get_course_table(TABLE_LINK),
get_lang(ucfirst(TOOL_LINK)),
],
[
Database::get_course_table(TABLE_ANNOUNCEMENT),
get_lang(ucfirst(TOOL_ANNOUNCEMENT)),
]
];
$usage = [];
$conditionSession = '';
if ($session_id !== '') {
$session_id = intval($session_id);
$conditionSession = " AND session_id = '$session_id' ";
}
foreach ($tables as $tableInfo) {
$table = $tableInfo[0];
$title = $tableInfo[1];
$sql = "SELECT COUNT(*) count FROM $table
WHERE c_id = '$courseId' $conditionSession ";
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
$usage[] = array(
$title,
$row['count']
);
}
return $usage;
}
@ -88,7 +104,12 @@ Display::display_header($tool_name);
echo Display::page_header(get_lang('CourseUsage'));
$table = new SortableTableFromArray(get_course_usage($courseInfo, $sessionId), 0, 20, 'usage_table');
$table = new SortableTableFromArray(
get_course_usage($courseInfo, $sessionId),
0,
20,
'usage_table'
);
$table->set_additional_parameters(array('code' => $courseInfo['code']));
$table->set_other_tables(array('user_table', 'class_table'));
$table->set_header(0, get_lang('Tool'), true);

@ -3092,34 +3092,6 @@ class CourseManager
return $category;
}
/**
* Get count rows of a table inside a course database
* @param string $table The table of which the rows should be counted
* @param int $session_id optionally count rows by session id
* @return int $course_id The number of rows in the given table.
*
* @deprecated
*/
public static function count_rows_course_table($table, $session_id = '', $course_id = 0)
{
$condition_session = '';
if ($session_id !== '') {
$session_id = intval($session_id);
$condition_session = " AND session_id = '$session_id' ";
}
if (!empty($course_id)) {
$course_id = intval($course_id);
} else {
$course_id = api_get_course_int_id();
}
$condition_session .= " AND c_id = '$course_id' ";
$sql = "SELECT COUNT(*) AS n FROM $table WHERE 1=1 $condition_session ";
$rs = Database::query($sql);
$row = Database::fetch_row($rs);
return $row[0];
}
/**
* Subscribes courses to human resource manager (Dashboard feature)
* @param int $hr_manager_id Human Resource Manager id
@ -3179,10 +3151,13 @@ class CourseManager
/**
* get courses followed by human resources manager
* @param int $user_id
* @param int $status
* @param int $from
* @param int $limit
* @param string $column
* @param string $direction
* @param bool $getCount
*
* @return array courses
*/
public static function get_courses_followed_by_drh(
@ -4820,9 +4795,9 @@ class CourseManager
'button',
$icon,
array(
'id' => 'register',
'class' => 'btn btn-default btn-sm',
'title' => $title,
'id' => 'register',
'class' => 'btn btn-default btn-sm',
'title' => $title,
'aria-label' => $title
)
);
@ -4834,9 +4809,9 @@ class CourseManager
'button',
$icon,
array(
'id' => 'register',
'class' => 'btn btn-default btn-sm',
'title' => $title,
'id' => 'register',
'class' => 'btn btn-default btn-sm',
'title' => $title,
'aria-label' => $title
)
);

Loading…
Cancel
Save