Avoiding warning messages if course does not exist

skala
Julio Montoya 14 years ago
parent d4db1c4223
commit 4f4f916f17
  1. 9
      main/inc/lib/search/tool_processors/link_processor.class.php
  2. 27
      main/inc/lib/search/tool_processors/quiz_processor.class.php

@ -86,7 +86,10 @@ class link_processor extends search_processor {
* Get document information
*/
private function get_information($course_id, $link_id) {
$item_property_table = Database::get_course_table_from_code($course_id, TABLE_ITEM_PROPERTY);
$course_information = api_get_course_info($course_id);
if (!empty($course_information)) {
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_information['db_name']);
$link_id = Database::escape_string($link_id);
$sql = "SELECT insert_user_id FROM $item_property_table
WHERE ref = $link_id AND tool = '". TOOL_LINK ."'
@ -107,6 +110,8 @@ class link_processor extends search_processor {
}
return array($thumbnail, $image, $name, $author, $url);
} else {
return array();
}
}
}
?>

@ -96,19 +96,17 @@ class quiz_processor extends search_processor {
* Get learning path information
*/
private function get_information($course_id, $exercise_id) {
$exercise_table = Database::get_course_table_from_code($course_id, TABLE_QUIZ_TEST);
$item_property_table = Database::get_course_table_from_code($course_id, TABLE_ITEM_PROPERTY);
$exercise_id = Database::escape_string($exercise_id);
$sql = "SELECT * FROM $exercise_table
WHERE id = $exercise_id
LIMIT 1";
$dk_result = Database::query ($sql);
$course_information = api_get_course_info($course_id);
if (!empty($course_information)) {
$exercise_table = Database::get_course_table(TABLE_QUIZ_TEST, $course_information['db_name']);
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_information['db_name']);
$exercise_id = intval($exercise_id);
$sql = "SELECT * FROM $exercise_table WHERE id = $exercise_id LIMIT 1";
$dk_result = Database::query($sql);
//actually author isn't saved on exercise tool, but prepare for when it's ready
$sql = "SELECT insert_user_id
FROM $item_property_table
WHERE ref = $doc_id
AND tool = '". TOOL_DOCUMENT ."'
$sql = "SELECT insert_user_id FROM $item_property_table
WHERE ref = $doc_id AND tool = '". TOOL_DOCUMENT ."'
LIMIT 1";
$name = '';
@ -119,14 +117,15 @@ class quiz_processor extends search_processor {
$name = $row['title'];
// get author
$author = '';
$item_result = Database::query ($sql);
$item_result = Database::query($sql);
if ($item_result !== FALSE && $row = Database::fetch_array ($item_result)) {
$user_data = api_get_user_info($row['insert_user_id']);
$author = api_get_person_name($user_data['firstName'], $user_data['lastName']);
}
}
return array($thumbnail, $image, $name, $author);
} else {
return array();
}
}
}
?>

Loading…
Cancel
Save