1.10.x
Yannick Warnier 10 years ago
commit 1df2df3d09
  1. 36
      main/cron/add_gradebook_certificates.php
  2. 2
      main/install/configuration.dist.php
  3. 85
      main/webservices/registration.soap.php

@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Adds gradebook certificates to gradebook_certificate table from users
* who have achieved the requirements but have not reviewed them yet
* @package chamilo.cron
* @author Imanol Losada <imanol.losada@beeznest.com>
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'database.lib.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
/**
* Get all categories and users ids from gradebook
* @return array Categories and users ids
*/
function getAllCategoriesAndUsers() {
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$jointable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$joinStatement = ' JOIN '.$jointable.' ON '.$table.'.evaluation_id = '.$jointable.'.id';
return Database::select(
'DISTINCT '.$jointable.'.category_id,'.$table.'.user_id',
$table.$joinStatement
);
}
if ($categoriesAndUsers = getAllCategoriesAndUsers()) {
foreach ($categoriesAndUsers as $categoryAndUser) {
Category::register_user_certificate(
$categoryAndUser['category_id'],
$categoryAndUser['user_id']
);
}
}

@ -286,6 +286,8 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['exercise_max_ckeditors_in_page'] = 0;
// Default upload option
//$_configuration['document_if_file_exists_option'] = 'rename'; // overwrite
// Enable add_gradebook_certificates.php cron task
//$_configuration['add_gradebook_certificates_cron_task_enabled'] = true;
// Which OpenBadges backpack send the badges
//$_configuration['openbadges_backpack'] = 'https://backpack.openbadges.org/';
// Custom name_order_conventions

@ -5549,6 +5549,7 @@ function WSUserSubscribedInCourse ($params)
return (CourseManager::is_user_subscribed_in_course($userId,$courseCode));
}
/* Search session Web Service start */
// Input params for WSSearchSession
@ -5744,6 +5745,87 @@ function WSFetchSession($params)
/* Fetch session Web Service end */
/* Register WSCertificatesList function */
// Register the data structures used by the service
$server->wsdl->addComplexType(
'certificateDetails',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name' => 'id', 'type' => 'xsd:int'),
'username' => array('name' => 'username', 'type' => 'xsd:string'),
'course_code' => array('name' => 'course_code', 'type' => 'xsd:string'),
'session_id' => array('name' => 'session_id', 'type' => 'xsd:int'),
'cat_id' => array('name' => 'cat_id', 'type' => 'xsd:int'),
'created_at' => array('name' => 'created_at', 'type' => 'xsd:string'),
'path_certificate' => array('name' => 'path_certificate', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'certificatesList',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP:ENC:arrayType',
'wsdl:arrayType'=>'tns:certificateDetails[]')
),
'tns:certificateDetails'
);
// Register the method to expose
$server->register(
'WSCertificatesList', // method name
array(
'startingDate' => 'xsd:string', // input parameters
'endingDate' => 'xsd:string'
),
array('return' => 'tns:certificatesList'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSCertificatesList', // soapaction
'rpc', // style
'encoded', // use
'This service returns a list of certificates' // documentation
);
function WSCertificatesList($startingDate = '', $endingDate = '')
{
global $_configuration;
if ($_configuration['add_gradebook_certificates_cron_task_enabled']) {
require_once api_get_path(SYS_CODE_PATH).'cron/add_gradebook_certificates.php';
}
$result = array();
$certificateTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$categoryTable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$query = "SELECT certificate.id, user.username, category.course_code, category.session_id,
certificate.user_id, certificate.cat_id, certificate.created_at, certificate.path_certificate
FROM $certificateTable AS certificate
JOIN $userTable AS user ON certificate.user_id = user.user_id
JOIN $categoryTable AS category ON certificate.cat_id = category.id";
if (!empty($startingDate) && !empty($endingDate)) {
$query .= " WHERE certificate.created_at BETWEEN '$startingDate' AND '$endingDate'";
} else if (!empty($startingDate)) {
$query .= " WHERE certificate.created_at >= '$startingDate'";
} else if (!empty($endingDate)) {
$query .= " WHERE certificate.created_at <= '$endingDate'";
}
$queryResult = Database::query($query);
$basePath = api_get_path(WEB_CODE_PATH).'upload/users/';
while ($row = Database::fetch_array($queryResult)) {
$certificatePath = $basePath;
if (api_get_setting('split_users_upload_directory') === 'true') {
$certificatePath .= substr((string) $row['user_id'], 0, 1).'/';
}
$row['path_certificate'] = $certificatePath.$row['user_id'].'/certificate'.$row['path_certificate'];
$result[] = $row;
}
return $result;
}
/* Create group Web Service start */
// Register the data structures used by the service
@ -5758,7 +5840,6 @@ $server->wsdl->addComplexType(
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'name' => array('name' => 'name', 'type' => 'xsd:string')
)
);
@ -6074,7 +6155,7 @@ function WSDeleteUserFromGroup($params)
/* Delete user from group Web Service end */
// Add more webservices by Hooks
// Add more webservices through hooks from plugins
if (!empty($hook)) {
$hook->setEventData(array('server' => $server));
$res = $hook->notifyWSRegistration(HOOK_EVENT_TYPE_POST);

Loading…
Cancel
Save