本文整理汇总了PHP中Database::fetch_object方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::fetch_object方法的具体用法?PHP Database::fetch_object怎么用?PHP Database::fetch_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::fetch_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_class_data
/**
* Get the classes to display on the current page.
*/
function get_class_data($from, $number_of_items, $column, $direction)
{
$class_table = Database::get_main_table(TABLE_MAIN_CLASS);
$course_class_table = Database::get_main_table(TABLE_MAIN_COURSE_CLASS);
$class_user_table = Database::get_main_table(TABLE_MAIN_CLASS_USER);
$sql = "SELECT * FROM {$course_class_table} WHERE course_code = '" . $_SESSION['_course']['id'] . "'";
$res = Database::query($sql);
$subscribed_classes = array();
while ($obj = Database::fetch_object($res)) {
$subscribed_classes[] = $obj->class_id;
}
$sql = "SELECT\n\t\t\t\t\t\t\tc.id AS col0,\n\t\t\t\t\t\t\tc.name AS col1,\n\t\t\t\t\t\t\tCOUNT(cu.user_id) AS col2,\n\t\t\t\t\t\t\tc.id AS col3\n\t\t\t\t\t\tFROM {$class_table} c\n\t\t\t\t\t\t";
$sql .= " LEFT JOIN {$class_user_table} cu ON cu.class_id = c.id";
$sql .= " WHERE 1 = 1";
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (c.name LIKE '%" . $keyword . "%')";
}
if (count($subscribed_classes) > 0) {
$sql .= " AND c.id NOT IN ('" . implode("','", $subscribed_classes) . "')";
}
$sql .= " GROUP BY c.id, c.name ";
$sql .= " ORDER BY col{$column} {$direction} ";
$sql .= " LIMIT {$from},{$number_of_items}";
$res = Database::query($sql);
$classes = array();
while ($class = Database::fetch_row($res)) {
$classes[] = $class;
}
return $classes;
}
示例2: get_number_of_courses
/**
* Get the number of courses which will be displayed
*/
function get_number_of_courses()
{
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT COUNT(code) AS total_number_of_items FROM {$course_table}";
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql .= " INNER JOIN {$access_url_rel_course_table} url_rel_course ON (code=url_rel_course.course_code)";
}
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string("%" . $_GET['keyword'] . "%");
$sql .= " WHERE (\n title LIKE '" . $keyword . "' OR\n code LIKE '" . $keyword . "' OR\n visual_code LIKE '" . $keyword . "'\n )\n ";
} elseif (isset($_GET['keyword_code'])) {
$keyword_code = Database::escape_string("%" . $_GET['keyword_code'] . "%");
$keyword_title = Database::escape_string("%" . $_GET['keyword_title'] . "%");
$keyword_category = Database::escape_string("%" . $_GET['keyword_category'] . "%");
$keyword_language = Database::escape_string("%" . $_GET['keyword_language'] . "%");
$keyword_visibility = Database::escape_string("%" . $_GET['keyword_visibility'] . "%");
$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
$keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
$sql .= " WHERE\n (code LIKE '" . $keyword_code . "' OR visual_code LIKE '" . $keyword_code . "') AND\n title LIKE '" . $keyword_title . "' AND\n category_code LIKE '" . $keyword_category . "' AND\n course_language LIKE '" . $keyword_language . "' AND\n visibility LIKE '" . $keyword_visibility . "' AND\n subscribe LIKE '" . $keyword_subscribe . "' AND\n unsubscribe LIKE '" . $keyword_unsubscribe . "'\n ";
}
// adding the filter to see the user's only of the current access_url
if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
$sql .= " AND url_rel_course.access_url_id=" . api_get_current_access_url_id();
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
示例3: get_course_usage
/**
*
*/
function get_course_usage($course_code, $session_id = 0)
{
$table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_code = Database::escape_string($course_code);
$sql = "SELECT * FROM {$table} WHERE code='" . $course_code . "'";
$res = Database::query($sql);
$course = Database::fetch_object($res);
// Learnpaths
$table = Database::get_course_table(TABLE_LP_MAIN);
$usage[] = array(get_lang(ucfirst(TOOL_LEARNPATH)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
// Forums
$table = Database::get_course_table(TABLE_FORUM);
$usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $course->id));
// Quizzes
$table = Database::get_course_table(TABLE_QUIZ_TEST);
$usage[] = array(get_lang(ucfirst(TOOL_QUIZ)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
// Documents
$table = Database::get_course_table(TABLE_DOCUMENT);
$usage[] = array(get_lang(ucfirst(TOOL_DOCUMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
// Groups
$table = Database::get_course_table(TABLE_GROUP);
$usage[] = array(get_lang(ucfirst(TOOL_GROUP)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
// Calendar
$table = Database::get_course_table(TABLE_AGENDA);
$usage[] = array(get_lang(ucfirst(TOOL_CALENDAR_EVENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
// Link
$table = Database::get_course_table(TABLE_LINK);
$usage[] = array(get_lang(ucfirst(TOOL_LINK)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
// Announcements
$table = Database::get_course_table(TABLE_ANNOUNCEMENT);
$usage[] = array(get_lang(ucfirst(TOOL_ANNOUNCEMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
return $usage;
}
示例4: get_number_of_groups
/**
* Get the total number of users on the platform
* @see SortableTable#get_total_number_of_items()
*/
function get_number_of_groups()
{
$group_table = Database::get_main_table(TABLE_MAIN_GROUP);
$sql = "SELECT COUNT(g.id) AS total_number_of_items FROM {$group_table} g";
// adding the filter to see the user's only of the current access_url
/*
global $_configuration;
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id()!=-1) {
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
}
*/
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " WHERE (g.name LIKE '%" . $keyword . "%' OR g.description LIKE '%" . $keyword . "%' OR g.url LIKE '%" . $keyword . "%' )";
}
// adding the filter to see the user's only of the current access_url
/*
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id()!=-1) {
$sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
} */
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
示例5: initializeReport
/**
* @param $course_code
* @return array|bool
*/
function initializeReport($course_code)
{
$course_info = api_get_course_info($course_code);
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$table_students_report = Database::get_main_table('rp_students_report');
$table_semanas_curso = Database::get_main_table('rp_semanas_curso');
$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_post = Database::get_course_table(TABLE_FORUM_POST, $course_info['dbName']);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']);
$course_code = Database::escape_string($course_code);
$res = Database::query("SELECT COUNT(*) as cant FROM $table_reporte_semanas WHERE course_code = '" . $course_code . "'");
$sqlWeeks = "SELECT semanas FROM $table_semanas_curso WHERE course_code = '$course_code'";
$resWeeks = Database::query($sqlWeeks);
$weeks = Database::fetch_object($resWeeks);
$obj = Database::fetch_object($res);
$weeksCount = (!isset($_POST['weeksNumber'])) ? (($weeks->semanas == 0) ? 7 : $weeks->semanas) : $_POST['weeksNumber'];
$weeksCount = Database::escape_string($weeksCount);
Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$weeksCount')");
if (intval($obj->cant) != $weeksCount) {
if (intval($obj->cant) > $weeksCount) {
$sql = "DELETE FROM $table_reporte_semanas WHERE week_id > $weeksCount AND course_code = '$course_code'";
Database::query("DELETE FROM $table_reporte_semanas WHERE week_id > $weeksCount AND course_code = '$course_code'");
} else {
for ($i = $obj->cant + 1; $i <= $weeksCount; $i++) {
if (!Database::query("INSERT INTO $table_reporte_semanas (week_id, course_code, forum_id, work_id, quiz_id, pc_id)
VALUES ($i, '$course_code', '0', '0', '0', '0' )")) {
return false;
}
}
}
}
$sql = "REPLACE INTO $table_students_report (user_id, week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)
SELECT cu.user_id, rs.id, 0, 0, 0, 0
FROM $table_course_rel_user cu
LEFT JOIN $table_reporte_semanas rs ON cu.course_code = rs.course_code
WHERE cu.status = 5 AND rs.course_code = '$course_code'
ORDER BY cu.user_id, rs.id";
if (!Database::query($sql)) {
return false;
} else {
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
Database::query("UPDATE $table_students_report sr SET sr.work_ok = 1
WHERE CONCAT (sr.user_id,',',sr.week_report_id)
IN (SELECT DISTINCT CONCAT(w.user_id,',',rs.id)
FROM $table_work w JOIN $table_reporte_semanas rs ON w.parent_id = rs.work_id)");
Database::query("UPDATE $table_students_report sr SET sr.thread_ok = 1
WHERE CONCAT (sr.user_id,',',sr.week_report_id)
IN (SELECT DISTINCT CONCAT(f.poster_id,',',rs.id)
FROM $table_post f JOIN $table_reporte_semanas rs ON f.thread_id = rs.forum_id)");
return showResults($course_info, $weeksCount, $page);
}
}
示例6: get_number_of_classes
/**
* Gets the total number of classes.
*/
function get_number_of_classes()
{
$tbl_class = Database::get_main_table(TABLE_MAIN_CLASS);
$sql = "SELECT COUNT(*) AS number_of_classes FROM {$tbl_class}";
if (isset($_GET['keyword'])) {
$sql .= " WHERE (name LIKE '%" . Database::escape_string(trim($_GET['keyword'])) . "%')";
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->number_of_classes;
}
示例7: get_number_of_attendances
/**
* Get the total number of attendance inside current course and current session
* @see SortableTable#get_total_number_of_items()
*/
static function get_number_of_attendances()
{
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$course_id = api_get_course_int_id();
$sql = "SELECT COUNT(att.id) AS total_number_of_items FROM {$tbl_attendance} att\n\t\t WHERE c_id = {$course_id} AND att.active = 1 {$condition_session} ";
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
示例8: save_data
/**
* Saves imported data.
*/
function save_data($users_courses)
{
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$csv_data = array();
$inserted_in_course = array();
foreach ($users_courses as $user_course) {
$csv_data[$user_course['Email']][$user_course['CourseCode']] = $user_course['Status'];
}
foreach ($csv_data as $email => $csv_subscriptions) {
$sql = "SELECT * FROM {$user_table} u\n WHERE u.email = '" . Database::escape_string($email) . "' LIMIT 1";
$res = Database::query($sql);
$obj = Database::fetch_object($res);
$user_id = $obj->user_id;
$sql = "SELECT * FROM {$course_user_table} cu\n WHERE cu.user_id = {$user_id} AND cu.relation_type <> " . COURSE_RELATION_TYPE_RRHH . " ";
$res = Database::query($sql);
$db_subscriptions = array();
while ($obj = Database::fetch_object($res)) {
$db_subscriptions[$obj->c_id] = $obj->status;
}
$to_subscribe = array_diff(array_keys($csv_subscriptions), array_keys($db_subscriptions));
$to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csv_subscriptions));
if ($_POST['subscribe']) {
foreach ($to_subscribe as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$course_code = $courseInfo['code'];
if (CourseManager::course_exists($course_code)) {
$course_info = CourseManager::get_course_information($course_code);
$inserted_in_course[$course_code] = $course_info['title'];
CourseManager::subscribe_user($user_id, $course_code, $csv_subscriptions[$course_code]);
$inserted_in_course[$course_info['code']] = $course_info['title'];
}
}
}
if ($_POST['unsubscribe']) {
foreach ($to_unsubscribe as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
$course_code = $courseInfo['code'];
if (CourseManager::course_exists($course_code)) {
CourseManager::unsubscribe_user($user_id, $course_code);
$course_info = CourseManager::get_course_information($course_code);
CourseManager::unsubscribe_user($user_id, $course_code);
$inserted_in_course[$course_info['code']] = $course_info['title'];
}
}
}
}
return $inserted_in_course;
}
示例9: save_data
/**
* Saves imported data.
*/
function save_data($users_courses)
{
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$csv_data = array();
foreach ($users_courses as $user_course) {
$csv_data[$user_course['UserName']][$user_course['CourseCode']] = $user_course['Status'];
}
foreach ($csv_data as $username => $csv_subscriptions) {
$sql = "SELECT * FROM {$user_table} u WHERE u.username = '" . Database::escape_string($username) . "'";
$res = Database::query($sql);
$obj = Database::fetch_object($res);
$user_id = $obj->user_id;
$sql = "SELECT * FROM {$course_user_table} cu\n\t\t WHERE cu.user_id = {$user_id} AND cu.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " ";
$res = Database::query($sql);
$db_subscriptions = array();
while ($obj = Database::fetch_object($res)) {
$db_subscriptions[$obj->c_id] = $obj->status;
}
$csvCourseList = array();
foreach ($csv_subscriptions as $courseCode => $status) {
$courseInfo = api_get_course_info($courseCode);
if ($courseInfo) {
$csvCourseList[$courseInfo['real_id']] = $status;
}
}
$to_subscribe = array_diff(array_keys($csvCourseList), array_keys($db_subscriptions));
$to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csvCourseList));
global $inserted_in_course;
if (!isset($inserted_in_course)) {
$inserted_in_course = array();
}
if (isset($_POST['subscribe']) && $_POST['subscribe']) {
foreach ($to_subscribe as $courseId) {
CourseManager::add_user_to_course($user_id, $courseId, $csvCourseList[$courseId]);
$course_info = api_get_course_info_by_id($courseId);
$inserted_in_course[$courseId] = $course_info['title'];
}
}
if (isset($_POST['unsubscribe']) && $_POST['unsubscribe']) {
foreach ($to_unsubscribe as $courseId) {
CourseManager::unsubscribe_user($user_id, $courseId);
$course_info = api_get_course_info_by_id($courseId);
$inserted_in_course[$courseId] = $course_info['title'];
}
}
}
}
示例10: user
public static function user()
{
$id = isset($_COOKIE['id']) ? $_COOKIE['id'] : '';
$hash = isset($_COOKIE['hash']) ? $_COOKIE['hash'] : '';
$query = Database::query("SELECT * FROM " . self::$tUsers . " WHERE id = ? AND session = ?", [$id, $hash]);
if (Database::num_rows($query)) {
$fetch = Database::fetch_object($query);
$user = new StdClass();
$user->id = $fetch->id;
$user->email = $fetch->email;
$user->username = $fetch->username;
if (!empty($fetch->profile)) {
$profile = json_decode($fetch->profile);
foreach ($profile as $field => $value) {
$user->{$field} = htmlspecialchars($value);
}
}
return $user;
}
}
示例11: initializeReport
/**
* @param $course_code
* @return array|bool
*/
function initializeReport($course_code)
{
$course_info = api_get_course_info($course_code);
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$table_students_report = Database::get_main_table('rp_students_report');
$table_semanas_curso = Database::get_main_table('rp_semanas_curso');
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_post = Database::get_course_table(TABLE_FORUM_POST);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$course_code = Database::escape_string($course_code);
$res = Database::query("SELECT COUNT(*) as cant FROM {$table_reporte_semanas} WHERE course_code = '" . $course_code . "'");
$sqlWeeks = "SELECT semanas FROM {$table_semanas_curso} WHERE course_code = '{$course_code}'";
$resWeeks = Database::query($sqlWeeks);
$weeks = Database::fetch_object($resWeeks);
$obj = Database::fetch_object($res);
$weeksCount = !isset($_POST['weeksNumber']) ? $weeks->semanas == 0 ? 7 : $weeks->semanas : $_POST['weeksNumber'];
$weeksCount = Database::escape_string($weeksCount);
Database::query("REPLACE INTO {$table_semanas_curso} (course_code , semanas) VALUES ('{$course_code}','{$weeksCount}')");
if (intval($obj->cant) != $weeksCount) {
if (intval($obj->cant) > $weeksCount) {
$sql = "DELETE FROM {$table_reporte_semanas} WHERE week_id > {$weeksCount} AND course_code = '{$course_code}'";
Database::query("DELETE FROM {$table_reporte_semanas} WHERE week_id > {$weeksCount} AND course_code = '{$course_code}'");
} else {
for ($i = $obj->cant + 1; $i <= $weeksCount; $i++) {
if (!Database::query("INSERT INTO {$table_reporte_semanas} (week_id, course_code, forum_id, work_id, quiz_id, pc_id)\n\t\t\t\t\t\tVALUES ({$i}, '{$course_code}', '0', '0', '0', '0' )")) {
return false;
}
}
}
}
$sql = "REPLACE INTO {$table_students_report} (user_id, week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)\n\t\t\tSELECT cu.user_id, rs.id, 0, 0, 0, 0\n\t\t\tFROM {$table_course_rel_user} cu\n\t\t\tINNER JOIN {$courseTable} c\n\t\t\tON (c.id = cu.c_id)\n\t\t\tLEFT JOIN {$table_reporte_semanas} rs ON c.code = rs.course_code\n\t\t\tWHERE cu.status = 5 AND rs.course_code = '{$course_code}'\n\t\t\tORDER BY cu.user_id, rs.id";
if (!Database::query($sql)) {
return false;
} else {
$page = !isset($_GET['page']) ? 1 : $_GET['page'];
Database::query("UPDATE {$table_students_report} sr SET sr.work_ok = 1\n\t\tWHERE CONCAT (sr.user_id,',',sr.week_report_id)\n\t\tIN (SELECT DISTINCT CONCAT(w.user_id,',',rs.id)\n\t\tFROM {$table_work} w JOIN {$table_reporte_semanas} rs ON w.parent_id = rs.work_id)");
Database::query("UPDATE {$table_students_report} sr SET sr.thread_ok = 1\n\t\tWHERE CONCAT (sr.user_id,',',sr.week_report_id)\n\t\tIN (SELECT DISTINCT CONCAT(f.poster_id,',',rs.id)\n\t\tFROM {$table_post} f JOIN {$table_reporte_semanas} rs ON f.thread_id = rs.forum_id)");
return showResults($course_info, $weeksCount, $page);
}
}
示例12: inicializarReporte
function inicializarReporte($course_code)
{
$course_info = api_get_course_info($course_code);
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$table_students_report = Database::get_main_table('rp_students_report');
$table_semanas_curso = Database::get_main_table('rp_semanas_curso');
$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_post = Database::get_course_table(TABLE_FORUM_POST, $course_info['dbName']);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']);
$res = Database::query("SELECT COUNT(*) as cant FROM {$table_reporte_semanas} WHERE course_code = '" . $course_code . "'");
$sql_semanas = "SELECT semanas FROM {$table_semanas_curso} WHERE course_code = '{$course_code}'";
$res_semanas = Database::query($sql_semanas);
$semanas = Database::fetch_object($res_semanas);
$obj = Database::fetch_object($res);
$numero_semanas = !isset($_POST['numerosemanas']) ? $semanas->semanas == 0 ? 7 : $semanas->semanas : $_POST['numerosemanas'];
Database::query("REPLACE INTO {$table_semanas_curso} (course_code , semanas) VALUES ('{$course_code}','{$numero_semanas}')");
if (intval($obj->cant) != $numero_semanas) {
if (intval($obj->cant) > $numero_semanas) {
$sql = "DELETE FROM {$table_reporte_semanas} WHERE week_id > {$numero_semanas} AND course_code = '{$course_code}'";
Database::query("DELETE FROM {$table_reporte_semanas} WHERE week_id > {$numero_semanas} AND course_code = '{$course_code}'");
} else {
for ($i = $obj->cant + 1; $i <= $numero_semanas; $i++) {
if (!Database::query("INSERT INTO {$table_reporte_semanas} (week_id,course_code,forum_id,work_id,quiz_id,pc_id)\n\t\t\t\t\t\tVALUES ('{$i}','{$course_code}','0','0','0','0' )")) {
return false;
}
}
}
}
$sql = "REPLACE INTO {$table_students_report} (user_id,week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)\n\t\t\tSELECT cu.user_id, rs.id, 0, 0, 0, 0\n\t\t\tFROM {$table_course_rel_user} cu\n\t\t\tLEFT JOIN {$table_reporte_semanas} rs ON cu.course_code = rs.course_code\n\t\t\tWHERE cu.status = '5' AND rs.course_code = '{$course_code}'\n\t\t\tORDER BY cu.user_id, rs.id";
if (!Database::query($sql)) {
return false;
} else {
$pagina = !isset($_GET['page']) ? 1 : $_GET['page'];
Database::query("UPDATE {$table_students_report} sr SET sr.work_ok = 1\n\t\tWHERE CONCAT (sr.user_id,',',sr.week_report_id)\n\t\tIN (SELECT DISTINCT CONCAT(w.user_id,',',rs.id)\n\t\tFROM {$table_work} w JOIN {$table_reporte_semanas} rs ON w.parent_id = rs.work_id)");
Database::query("UPDATE {$table_students_report} sr SET sr.thread_ok = 1\n\t\tWHERE CONCAT (sr.user_id,',',sr.week_report_id)\n\t\tIN (SELECT DISTINCT CONCAT(f.poster_id,',',rs.id)\n\t\tFROM {$table_post} f JOIN {$table_reporte_semanas} rs ON f.thread_id = rs.forum_id)");
return mostrarResultados($course_info, $numero_semanas, $pagina);
}
}
示例13: save_data
/**
* Saves imported data.
*/
function save_data($users_classes, $deleteUsersNotInList = false)
{
global $purification_option_for_usernames;
// Table definitions.
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$usergroup = new UserGroup();
// Data parsing: purification + conversion (UserName, ClassName) --> (user_is, class_id)
$csv_data = array();
if (!empty($users_classes)) {
foreach ($users_classes as $user_class) {
$sql1 = "SELECT user_id FROM {$user_table}\n WHERE username = '" . Database::escape_string(UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames)) . "'";
$res1 = Database::query($sql1);
$obj1 = Database::fetch_object($res1);
$usergroup = new UserGroup();
$id = $usergroup->get_id_by_name($user_class['ClassName']);
if ($obj1 && $id) {
$csv_data[$id]['user_list'][] = $obj1->user_id;
$csv_data[$id]['user_list_name'][] = $user_class['UserName'];
$csv_data[$id]['class_name'] = $user_class['ClassName'];
}
}
}
// Logic for processing the request (data + UI options).
$message = null;
if (!empty($csv_data)) {
foreach ($csv_data as $class_id => $user_data) {
$user_list = $user_data['user_list'];
$class_name = $user_data['class_name'];
$user_list_name = $user_data['user_list_name'];
$usergroup->subscribe_users_to_usergroup($class_id, $user_list, $deleteUsersNotInList);
$message .= Display::return_message(get_lang('Class') . ': ' . $class_name . '<br />', 'normal', false);
$message .= Display::return_message(get_lang('Users') . ': ' . implode(', ', $user_list_name));
}
}
return $message;
}
示例14: array
cu.user_id = ' . $user['user_id'] . ' AND
cu.c_id = c.id AND
cu.relation_type <> ' . COURSE_RELATION_TYPE_RRHH . ' ';
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$header = array(array(get_lang('Code'), true), array(get_lang('Title'), true), array(get_lang('Status'), true), array(get_lang('TimeSpentInTheCourse'), true), array(get_lang('TotalPostsInAllForums'), true), array('', false));
$headerList = array();
foreach ($header as $item) {
$headerList[] = $item[0];
}
$csvContent[] = array();
$csvContent[] = array(get_lang('Courses'));
$csvContent[] = $headerList;
$data = array();
$courseToolInformationTotal = null;
while ($course = Database::fetch_object($res)) {
$courseInfo = api_get_course_info_by_id($course->c_id);
$courseCode = $courseInfo['code'];
$courseToolInformation = null;
$tools = '<a href="course_information.php?code=' . $courseCode . '">' . Display::return_icon('synthese_view.gif', get_lang('Overview')) . '</a>' . '<a href="' . $courseInfo['course_public_url'] . '">' . Display::return_icon('course_home.gif', get_lang('CourseHomepage')) . '</a>' . '<a href="course_edit.php?course_code=' . $courseCode . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
if ($course->status == STUDENT) {
$tools .= '<a href="user_information.php?action=unsubscribe&course_code=' . $courseCode . '&user_id=' . $user['user_id'] . '">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>';
}
$timeSpent = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseInfo['real_id'], 0));
$totalForumMessages = CourseManager::getCountPostInForumPerUser($user['user_id'], $course->id, 0);
$row = array(Display::url($courseCode, $courseInfo['course_public_url']), $course->title, $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher'), $timeSpent, $totalForumMessages, $tools);
$csvContent[] = array_map('strip_tags', $row);
$data[] = $row;
$result = TrackingUserLogCSV::getToolInformation($user['user_id'], $courseInfo, 0);
$courseToolInformationTotal .= $result['html'];
$csvContent = array_merge($csvContent, $result['array']);
示例15: restore_quizzes
/**
* Restore Quiz
*/
function restore_quizzes($session_id = 0, $respect_base_content = false)
{
if ($this->course->has_resources(RESOURCE_QUIZ)) {
$table_qui = Database::get_course_table(TABLE_QUIZ_TEST);
$table_rel = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
$resources = $this->course->resources;
foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) {
if (isset($quiz->obj)) {
//For new imports
$quiz = $quiz->obj;
} else {
//For backward compatibility
$quiz->obj = $quiz;
}
$doc = '';
if (!empty($quiz->sound)) {
if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) {
$sql = "SELECT path FROM " . $table_doc . " WHERE c_id = " . $this->destination_course_id . " AND id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id;
$doc = Database::query($sql);
$doc = Database::fetch_object($doc);
$doc = str_replace('/audio/', '', $doc->path);
}
}
if ($id != -1) {
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($quiz->description, $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
global $_custom;
if (isset($_custom['exercises_clean_dates_when_restoring']) && $_custom['exercises_clean_dates_when_restoring']) {
$quiz->start_time = null;
$quiz->end_time = null;
}
$params = array('c_id' => $this->destination_course_id, 'title' => self::DBUTF8($quiz->title), 'description' => self::DBUTF8($quiz->description), 'type' => isset($quiz->quiz_type) ? $quiz->quiz_type : $quiz->type, 'random' => $quiz->random, 'active' => $quiz->active, 'sound' => self::DBUTF8($doc), 'max_attempt' => (int) $quiz->max_attempt, 'results_disabled' => (int) $quiz->results_disabled, 'access_condition' => $quiz->access_condition, 'start_time' => $quiz->start_time, 'pass_percentage' => $quiz->pass_percentage, 'end_time' => $quiz->end_time, 'feedback_type' => (int) $quiz->feedback_type, 'random_answers' => (int) $quiz->random_answers, 'random_by_category' => $quiz->random_by_category, 'review_answers' => $quiz->review_answers, 'propagate_neg' => $quiz->propagate_neg, 'text_when_finished' => $quiz->text_when_finished, 'expired_time' => (int) $quiz->expired_time, 'end_button' => (int) $quiz->end_button);
if ($respect_base_content) {
$my_session_id = $quiz->session_id;
if (!empty($quiz->session_id)) {
$my_session_id = $session_id;
}
$params['session_id'] = $my_session_id;
} else {
if (!empty($session_id)) {
$session_id = intval($session_id);
$params['session_id'] = $session_id;
}
}
$new_id = Database::insert($table_qui, $params);
} else {
// $id = -1 identifies the fictionary test for collecting orphan questions. We do not store it in the database.
$new_id = -1;
}
if ($new_id && $new_id != -1) {
// Updates the question position
$exercise = new Exercise($this->destination_course_id);
$exercise->read($new_id);
$exercise->addExerciseToOrderTable();
$this->course->resources[RESOURCE_QUIZ][$id]->obj->destination_id = $new_id;
$order = 0;
if (!empty($quiz->question_ids)) {
foreach ($quiz->question_ids as $index => $question_id) {
$qid = $this->restore_quiz_question($question_id);
$question_order = $quiz->question_orders[$index] ? $quiz->question_orders[$index] : ++$order;
$sql = "INSERT IGNORE INTO " . $table_rel . " SET c_id = " . $this->destination_course_id . ", question_id = " . $qid . ", exercice_id = " . $new_id . ", question_order = " . $question_order;
Database::query($sql);
}
}
if (isset($quiz->categorie) && $quiz->categories) {
$exercise_obj = new Exercise($this->destination_course_id);
$exercise_obj->read($new_id);
$cats = array();
foreach ($quiz->categories as $cat) {
$cat_from_db = new Testcategory($cat['category_id']);
/*$cat_from_db = new Testcategory($cat['category_id']);
if ($cat_from_db && $cat_from_db->title == $cat['title']) {
echo '1';
//use the same id
$cats[$cat_from_db->id] = $cat['count_questions'];
} else {*/
$cat_from_db = $cat_from_db->get_category_by_title($cat['title'], $this->destination_course_id);
if (empty($cat_from_db)) {
//Create a new category in this portal
if ($cat['category_id'] == 0) {
$category_c_id = 0;
} else {
$category_c_id = $this->destination_course_id;
}
$new_cat = new Testcategory(null, $cat['title'], $cat['description'], null, 'simple', $category_c_id);
$new_cat_id = $new_cat->addCategoryInBDD();
$cats[$new_cat_id] = $cat['count_questions'];
} else {
$cats[$cat_from_db['iid']] = $cat['count_questions'];
}
//}
}
$exercise_obj->save_categories_in_exercise($cats);
}
}
}
//.........这里部分代码省略.........