Feature #2099 - New methods have been added to CourseRequestManager class.

skala
Ivan Tcholakov 15 years ago
parent e6a0734b74
commit 16121be571
  1. 8
      main/admin/course_request_accepted.php
  2. 16
      main/admin/course_request_rejected.php
  3. 20
      main/admin/course_request_review.php
  4. 5
      main/create_course/add_course.php
  5. 45
      main/inc/lib/course_request.lib.php

@ -39,14 +39,10 @@ require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
/**
* Get the number of courses which will be displayed
* Get the number of courses which will be displayed.
*/
function get_number_of_courses() {
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table WHERE status = ".COURSE_REQUEST_ACCEPTED;
$res = Database :: query($sql);
$obj = Database :: fetch_object($res);
return $obj->total_number_of_items;
return CourseRequestManager::count_course_requests(COURSE_REQUEST_ACCEPTED);
}
/**

@ -62,23 +62,14 @@ if (!empty($accept_course_request)) {
* Sending to the teacher a request for additional information about the proposed course.
*/
if (!empty($request_info)) {
// Marking the fact, that additional information has been requested.
$sql_info = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET info = 1 WHERE id = ".$request_info;
$result_info = Database::query($sql_info);
// TODO: Send the e-mail.
CourseRequestManager::ask_for_additional_info($request_info);
}
/**
* Get the number of courses which will be displayed
* Get the number of courses which will be displayed.
*/
function get_number_of_courses() {
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table WHERE status = ".COURSE_REQUEST_REJECTED;
$res = Database :: query($sql);
$obj = Database :: fetch_object($res);
return $obj->total_number_of_items;
return CourseRequestManager::count_course_requests(COURSE_REQUEST_REJECTED);
}
/**
@ -113,7 +104,6 @@ function get_course_data($from, $number_of_items, $column, $direction) {
/**
* Actions in the list: edit.
*/
function modify_filter($id) {
return
'<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;'.' '.

@ -75,25 +75,16 @@ if (isset($_GET['reject_course_request']) && $_GET['reject_course_request'] != '
* Sending to the teacher a request for additional information about the proposed course.
*/
if (!empty($request_info)) {
// Marking the fact, that additional information has been requested.
$sql_info = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET info = 1 WHERE id = ".$request_info;
$result_info = Database::query($sql_info);
// TODO: Send the e-mail.
CourseRequestManager::ask_for_additional_info($request_info);
}
/**
* Funcion feita por nos para saber o numero de cursos na taboa temporal sen validar
* Get the number of courses which will be displayed.
*/
function get_number_of_courses() {
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table WHERE status = ".COURSE_REQUEST_PENDING;
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
return CourseRequestManager::count_course_requests(COURSE_REQUEST_PENDING);
}
/**
@ -138,13 +129,12 @@ function email_filter($teacher) {
/**
* Actions in the list: edit, accept, reject, request additional information.
*/
function modify_filter($id) {
/*
return
'<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;'.' '.'<a href="?reject_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><img src="../img/delete.gif" border="0" style="vertical-align: middle" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>'.' '.'<a href="?request_info='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('cesga_AdminAlertInfo'), ENT_QUOTES))."'".')) return false;"><img src="../img/cesga_question.gif" border="0" style="vertical-align: middle" title="'.get_lang('cesga_AdminPedirInfo').'" alt="'.get_lang('cesga_AdminPedirInfo').'"/></a>&nbsp;'.' '.'<a href="?accept_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('cesga_AdminAlertCrear'), ENT_QUOTES))."'".')) return false;"><img src="../img/right.gif" border="0" style="vertical-align: middle" title="'.get_lang('cesga_AdminValidar').'" alt="'.get_lang('cesga_AdminValidar').'"/></a>&nbsp;';
*/
$sql_request_info = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE (id = ".$id." AND info = 1 )";
$sql_request_info = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE (id = ".$id." AND info = 1)";
$res_request_info = Database::query($sql_request_info);
if (Database::num_rows($res_request_info) > 0) { //Si ya se le ha pedido información, no se muestra esa opción
@ -182,7 +172,7 @@ Display :: display_header($tool_name);
//api_display_tool_title($tool_name);
if (isset ($_GET['delete_course'])) {
CourseManager :: delete_course($_GET['delete_course']);
//CourseManager :: delete_course($_GET['delete_course']);
}
// Create a sortable table with the course data

@ -70,11 +70,6 @@ if (!api_is_allowed_to_create_course()) {
exit;
}
// Get necessary table definitions.
$table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_course_request = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
global $_configuration;
$dbnamelength = strlen($_configuration['db_prefix']);
// Ensure the database prefix + database name do not get over 40 characters.

@ -33,7 +33,7 @@ class CourseRequestManager {
}
$table_course_request = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
$wanted_course_code = Database::escape_string($wanted_course_code);
$sql = sprintf('SELECT COUNT(*) AS number FROM %s WHERE visual_code = "%s"', $table_course_request, $wanted_course_code);
$sql = sprintf('SELECT COUNT(id) AS number FROM %s WHERE visual_code = "%s"', $table_course_request, $wanted_course_code);
$result = Database::fetch_array(Database::query($sql));
return $result['number'] > 0;
}
@ -109,6 +109,33 @@ class CourseRequestManager {
}
/**
* Deletes a given course request.
* @param int/string $id The id (an integer number) of the corresponding database record.
* @return array/bool Returns TRUE on success or FALSE on failure.
*/
public static function delete_course_request($id) {
$id = (int)$id;
$sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id = ".$id;
$result = Database::query($sql);
return $result !== false;
}
public static function count_course_requests($status = null) {
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
if (is_null($status)) {
$sql = "SELECT COUNT(id) AS number FROM ".$course_table;
} else {
$status = (int)$status;
$sql = "SELECT COUNT(id) AS number FROM ".$course_table." WHERE status = ".$status;
}
$result = Database::fetch_array(Database::query($sql));
if (is_array($result)) {
return $result['number'];
}
return false;
}
/**
* Gets all the information about a course request using its database id as access key.
* @param int/string $id The id (an integer number) of the corresponding database record.
@ -203,4 +230,20 @@ class CourseRequestManager {
return $result;
}
/**
* Asks the author (through e-mail) for additional info about the given course request.
* @param int/string $id The database primary id of the given request.
* @return array/bool Returns TRUE on success or FALSE on failure.
*/
public static function ask_for_additional_info($id) {
$id = (int)$id;
$sql = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET info = 1 WHERE id = ".$id;
$result = Database::query($sql) !== false;
// TODO: Send the e-mail.
return $result;
}
}

Loading…
Cancel
Save