Update from 1.9.x

1.10.x
Julio Montoya 9 years ago
parent 2131c11d54
commit 4dec1fe2ff
  1. 4
      main/exercice/exercise.class.php
  2. 63
      main/webservices/client_soap.php
  3. 69
      main/webservices/registration.soap.php

@ -434,12 +434,12 @@ class Exercise
FROM $TBL_EXERCISE_QUESTION e
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id = q.id AND e.c_id = ".$this->course_id." AND q.c_id = ".$this->course_id.")
WHERE e.exercice_id = ".intval($this->id)."";
WHERE e.exercice_id = ".intval($this->id);
$result = Database::query($sql);
$count_question_orders = Database::num_rows($result);
$sql = "SELECT e.question_id, e.question_order
$sql = "SELECT DISTINCT e.question_id, e.question_order
FROM $TBL_EXERCISE_QUESTION e
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.id AND e.c_id = ".$this->course_id." AND q.c_id = ".$this->course_id.")

@ -197,17 +197,21 @@ if (!empty($user_id) && is_numeric($user_id)) {
//4. Adding course Test to the Session Session1
$course_id_list = array (
array('course_code' => 'TEST1'),
array('course_code' => 'TEST2')
);
$params = array('coursessessions' => array(
array('original_course_id_values' => $course_id_list,
'original_course_id_name' => 'course_id_name',
'original_session_id_value' => '1',
'original_session_id_name' => 'session_id_value')
),
'secret_key' => $secret_key);
$course_id_list = array(
array('course_code' => 'TEST1'),
array('course_code' => 'TEST2'),
);
$params = array(
'coursessessions' => array(
array(
'original_course_id_values' => $course_id_list,
'original_course_id_name' => 'course_id_name',
'original_session_id_value' => '1',
'original_session_id_name' => 'session_id_value',
),
),
'secret_key' => $secret_key,
);
//$result = $client->call('WSSuscribeCoursesToSession', array('subscribeCoursesToSession' => $params));
@ -215,28 +219,31 @@ if (!empty($user_id) && is_numeric($user_id)) {
// ------------------------
//Calling the WSSubscribeUserToCourse
/*
$course_array = array( 'original_course_id_name' => 'TEST',
'original_course_id_value' => 'TEST'
);
$user_array = array('original_user_id_value' => $user_id,
'original_user_id_name' => 'name');
$user_courses = array();
$user_courses[] = array ( 'course_id' => $course_array,
'user_id' => $user_array,
'status' => '1'
);
$course_array = array(
'original_course_id_name' => 'TEST',
'original_course_id_value' => 'TEST',
);
$params = array (
'userscourses' => $user_courses,
'secret_key' => $secret_key);
$user_array = array(
'original_user_id_value' => $user_id,
'original_user_id_name' => 'name',
);
$user_courses = array();
$result = $client->call('WSSubscribeUserToCourse', array('subscribeUserToCourse' => $params));
var_dump($result);*/
$user_courses[] = array(
'course_id' => $course_array,
'user_id' => $user_array,
'status' => '1',
);
$params = array(
'userscourses' => $user_courses,
'secret_key' => $secret_key,
);
$result = $client->call('WSSubscribeUserToCourse', array('subscribeUserToCourse' => $params));
var_dump($result);
} else {
echo 'User was not created, activate the debug=true in the registration.soap.php file and see the error logs';
}

@ -970,7 +970,7 @@ function WSCreateUsersPasswordCrypted($params)
return $output;
}
// Subscribe / Unsubscribe Teacher to Session Course
//
//
// Prepare Input params for Subscribe Teacher to SC
$server->wsdl->addComplexType(
'SubscribeTeacherToSessionCourse',
@ -1032,18 +1032,18 @@ $server->register(
function WSSubscribeTeacherToSessionCourse($params)
{
global $debug;
if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
if ($debug) error_log('Params '. print_r($params, 1));
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$userId = $params['userId']; // Chamilo user Id
$sessionId = $params['sessionId']; // Current Session course ID
$courseId = $params['courseId']; // Course Real Id
return (SessionManager::set_coach_to_course_session($userId, $sessionId, $courseId));
}
@ -1056,20 +1056,20 @@ $server->register(
function WSUnsubscribeTeacherFromSessionCourse($params)
{
global $debug;
if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
if ($debug) error_log('Params '. print_r($params, 1));
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$userId = $params['userId']; // Chamilo user Id
$sessionId = $params['sessionId']; // Current Session course ID
$courseId = $params['courseId']; // Course Real Id
return (SessionManager::removeUsersFromCourseSession($userId, $sessionId, $courseId));
}
@ -4296,25 +4296,22 @@ $server->wsdl->addComplexType(
'tns:user_course_status'
);
// Prepare output params, in this case will return an array
$server->wsdl->addComplexType(
'subscribeUserToCourse_return',
'subscribeUserToCourse_return_global',
'complexType',
'struct',
'all',
'array',
'',
array (
'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
'result' => array('name' => 'result', 'type' => 'xsd:int')
)
'SOAP-ENC:Array',
array(),
array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:subscribeUserToCourse_return[]')),
'tns:subscribeUserToCourse_return'
);
// Register the method to expose
$server->register('WSSubscribeUserToCourse', // method name
array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'), // input parameters
array('return' => 'tns:subscribeUserToCourse_return'), // output parameters
array('return' => 'tns:subscribeUserToCourse_return_global'),
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSSubscribeUserToCourse', // soapaction
'rpc', // style
@ -4329,6 +4326,7 @@ function WSSubscribeUserToCourse($params) {
return return_error(WS_ERROR_SECRET_KEY);
}
if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
$results = array();
$userscourses = $params['userscourses'];
foreach ($userscourses as $usercourse) {
@ -4339,10 +4337,7 @@ function WSSubscribeUserToCourse($params) {
$status = $usercourse['status'];
}
$result = array(
'original_user_id_value' => $original_user_id['original_user_id_value'],
'original_course_id_value' => $original_course_id['original_course_id_value'],
'result' => 1);
$resultValue = 1;
// Get user id
$user_id = UserManager::get_user_id_from_original_id(
@ -4353,28 +4348,32 @@ function WSSubscribeUserToCourse($params) {
if ($user_id == 0) {
// If user was not found, there was a problem
$result['result'] = 0;
$resultValue = 0;
} else {
// User was found
$courseInfo = CourseManager::getCourseInfoFromOriginalId(
$courseCode = CourseManager::get_course_id_from_original_id(
$original_course_id['original_course_id_value'],
$original_course_id['original_course_id_name']
);
if (empty($courseInfo)) {
if (empty($courseCode)) {
// Course was not found
$result['result'] = 0;
$resultValue = 0;
} else {
$course_code = $courseInfo['code'];
if ($debug) error_log('WSSubscribeUserToCourse course_code: '.$course_code);
if (!CourseManager::add_user_to_course($user_id, $course_code, $status)) {
$result['result'] = 0;
if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
if (!CourseManager::add_user_to_course($user_id, $courseCode, $status)) {
$resultValue = 0;
}
}
}
$results[] = $result;
$results[] = array(
'original_user_id_value' => $original_user_id['original_user_id_value'],
'original_course_id_value' => $original_course_id['original_course_id_value'],
'result' => $resultValue
);
}
return $results;
}

Loading…
Cancel
Save