Yannick Warnier 14 years ago
parent
commit
956b42dd60
3 changed files with 136 additions and 561 deletions
  1. 1 1
      main/newscorm/lp_view.php
  2. 35 179
      main/webservices/soap_report.php
  3. 100 381
      main/webservices/webservice_report.php

+ 1 - 1
main/newscorm/lp_view.php

@@ -236,7 +236,7 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
 
 $display_none = '';
 $margin_left = '282px';
-if (!empty($_GET['embedframe'])) {
+if ($_SESSION['oLP']->mode == 'embedframe') {
     $display_none = ';display:none;';
     $margin_left = '0px';
 }

+ 35 - 179
main/webservices/soap_report.php

@@ -6,11 +6,6 @@
  */
 require_once(dirname(__FILE__).'/webservice_report.php');
 require_once(dirname(__FILE__).'/soap.php');
-
-/**
- * Configures the WSUser SOAP service
- * @package chamilo.webservices
- */
 $s = WSSoapServer::singleton();
 
 $s->wsdl->addComplexType(
@@ -26,211 +21,72 @@ $s->wsdl->addComplexType(
 );
 
 $s->wsdl->addComplexType(
-	'user_result',
-	'complexType',
-	'struct',
-	'all',
-	'',
-	array(
-		'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
-		'result' => array('name' => 'result', 'type' => 'tns:result')
-	)
+    'course_id',
+    'complexType',
+    'struct',
+    'all',
+    '',
+    array(
+        'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
+        'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string')
+    )
 );
 
 $s->wsdl->addComplexType(
-	'user_result_array',
-	'complexType',
-	'array',
-	'',
-	'SOAP-ENC:Array',
-	array(),
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_result[]')),
-	'tns:user_result'
-);
-
-$s->register(
-	'WSUser.DisableUser',
-	array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string')
-);
-
-$s->register(
-	'WSUser.DisableUsers',
-	array('secret_key' => 'xsd:string', 'users' => 'tns:user_id[]'),
-	array('return' => 'tns:user_result_array')
-);
-
-$s->register(
-	'WSUser.EnableUser',
-	array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string')
-);
-
-$s->register(
-	'WSUser.EnableUsers',
-	array('secret_key' => 'xsd:string', 'users' => 'tns:user_id[]'),
-	array('return' => 'tns:user_result_array')
-);
-
-$s->register(
-	'WSUser.DeleteUser',
-	array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string')
-);
-
-$s->register(
-	'WSUser.DeleteUsers',
-	array('secret_key' => 'xsd:string', 'users' => 'tns:user_id[]'),
-	array('return' => 'tns:user_result_array')
-);
-
-$s->register(
-	'WSUser.CreateUser',
-	array(
-		'secret_key' => 'xsd:string',
-		'firstname' => 'xsd:string',
-		'lastname' => 'xsd:string',
-		'status' => 'xsd:int',
-		'loginname' => 'xsd:string',
-		'password' => 'xsd:string',
-		'encrypt_method' => 'xsd:string',
-		'user_id_field_name' => 'xsd:string',
-		'user_id_value' => 'xsd:string',
-		'visibility' => 'xsd:int',
-		'email' => 'xsd:string',
-		'language' => 'xsd:string',
-		'phone' => 'xsd:string',
-		'expiration_date' => 'xsd:string',
-		'extras' => 'tns:extra_field[]'
-	),
-	array('return' => 'xsd:int')
+    'session_id',
+    'complexType',
+    'struct',
+    'all',
+    '',
+    array(
+        'session_id_field_name' => array('name' => 'session_id_field_name', 'type' => 'xsd:string'),
+        'session_id_value' => array('name' => 'session_id_value', 'type' => 'xsd:string')
+    )
 );
 
 $s->wsdl->addComplexType(
-	'user_create',
-	'complexType',
-	'struct',
-	'all',
-	'',
-	array(
-		'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'),
-		'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'),
-		'status' => array('name' => 'status', 'type' => 'xsd:int'),
-		'loginname' => array('name' => 'loginname', 'type' => 'xsd:string'),
-		'password' => array('name' => 'password', 'type' => 'xsd:string'),
-		'encrypt_method' => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
-		'user_id_field_name' => array('name' => 'user_id_field_name', 'type' => 'xsd:string'),
-		'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
-		'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
-		'email' => array('name' => 'email', 'type' => 'xsd:string'),
-		'language' => array('name' => 'language', 'type' => 'xsd:string'),
-		'phone' => array('name' => 'phone', 'type' => 'xsd:string'),
-		'expiration_date' => array('name' => 'expiration_date', 'type' => 'xsd:string'),
-		'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]')
-	)
-);
-
-$s->wsdl->addComplexType(
-	'user_create_result',
+	'user_result',
 	'complexType',
 	'struct',
 	'all',
 	'',
 	array(
 		'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
-		'user_id_generated' => array('name' => 'user_id_generated', 'type' => 'xsd:int'),
 		'result' => array('name' => 'result', 'type' => 'tns:result')
 	)
 );
 
 $s->wsdl->addComplexType(
-	'user_create_result_array',
+	'user_result_array',
 	'complexType',
 	'array',
 	'',
 	'SOAP-ENC:Array',
 	array(),
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_create_result[]')),
-	'tns:user_create_result'
+	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_result[]')),
+	'tns:user_result'
 );
 
 $s->register(
-	'WSUser.CreateUsers',
-	array(
-		'secret_key' => 'xsd:string',
-		'users' => 'tns:user_create[]'
-	),
-	array('return' => 'tns:user_create_result_array')
+	'WSReport.get_time_spent_on_platform',
+	array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string'),
+    array('return' => 'tns:user_result_array')
 );
 
 $s->register(
-	'WSUser.EditUser',
-	array(
-		'secret_key' => 'xsd:string',
-		'user_id_field_name' => 'xsd:string',
-		'user_id_value' => 'xsd:string',
-		'firstname' => 'xsd:string',
-		'lastname' => 'xsd:string',
-		'status' => 'xsd:int',
-		'loginname' => 'xsd:string',
-		'password' => 'xsd:string',
-		'encrypt_method' => 'xsd:string',
-		'email' => 'xsd:string',
-		'language' => 'xsd:string',
-		'phone' => 'xsd:string',
-		'expiration_date' => 'xsd:string',
-		'extras' => 'tns:extra_field[]'
-	)
-);
-
-$s->wsdl->addComplexType(
-	'user_edit',
-	'complexType',
-	'struct',
-	'all',
-	'',
-	array(
-		'user_id_field_name' => array('name' => 'user_id_field_name', 'type' => 'xsd:string'),
-		'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
-		'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'),
-		'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'),
-		'status' => array('name' => 'status', 'type' => 'xsd:int'),
-		'loginname' => array('name' => 'loginname', 'type' => 'xsd:string'),
-		'password' => array('name' => 'password', 'type' => 'xsd:string'),
-		'encrypt_method' => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
-		'email' => array('name' => 'email', 'type' => 'xsd:string'),
-		'language' => array('name' => 'language', 'type' => 'xsd:string'),
-		'phone' => array('name' => 'phone', 'type' => 'xsd:string'),
-		'expiration_date' => array('name' => 'expiration_date', 'type' => 'xsd:string'),
-		'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]')
-	)
-);
-
-$s->wsdl->addComplexType(
-	'user_edit_result',
-	'complexType',
-	'struct',
-	'all',
-	'',
-	array(
-		'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
-		'result' => array('name' => 'result', 'type' => 'tns:result')
-	)
+	'WSReport.get_time_spent_on_course',
+    array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string'),
+	array('return' => 'tns:user_result_array')
 );
 
-$s->wsdl->addComplexType(
-	'user_edit_result_array',
-	'complexType',
-	'array',
-	'',
-	'SOAP-ENC:Array',
-	array(),
-	array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_edit_result[]')),
-	'tns:user_edit_result'
+$s->register(
+	'WSReport.get_time_spent_on_course_in_session',
+    array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string', 'session_id_field_name' => 'xsd:string', 'session_id_value' => 'xsd:string'),
+    array('return' => 'tns:user_result_array')
 );
 
 $s->register(
-	'WSUser.EditUsers',
-	array(
-		'secret_key' => 'xsd:string',
-		'users' => 'tns:user_edit[]'
-	),
-	array('return' => 'tns:user_edit_result_array')
+    'WSReport.get_time_spent_on_learnpath_in_course',
+    array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string', 'course_id_field_name' => 'xsd:string', 'course_id_value' => 'xsd:string', 'learnpath_id' => 'xsd:string'),
+    array('return' => 'tns:user_result_array')
 );

+ 100 - 381
main/webservices/webservice_report.php

@@ -5,8 +5,10 @@
  */
 require_once(dirname(__FILE__).'/../inc/global.inc.php');
 $libpath = api_get_path(LIBRARY_PATH);
+require_once($libpath.'sessionmanager.lib.php');
 require_once $libpath.'usermanager.lib.php';
 require_once $libpath.'tracking.lib.php';
+require_once $libpath.'course.lib.php';
 require_once(dirname(__FILE__).'/webservice.php');
 
 /**
@@ -15,11 +17,11 @@ require_once(dirname(__FILE__).'/webservice.php');
 class WSReport extends WS {
 
 	/**
-	 * Enables or disables a user
+	 * Gets the time spent on the platform by a given user
 	 *
 	 * @param string User id field name
 	 * @param string User id value
-	 * @param int Set to 1 to enable and to 0 to disable
+     * @return array Array of results
 	 */
 	protected function get_time_spent_on_platform($user_id_field_name, $user_id_value) {
 		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
@@ -31,388 +33,105 @@ class WSReport extends WS {
 	}
 
 	/**
-	 * Enables or disables multiple users
+     * Gets the time spent in a course by a given user
 	 *
-	 * @param array Users
-	 * @param int Set to 1 to enable and to 0 to disable
+     * @param string User id field name
+     * @param string User id value
+     * @param string Course id field name
+     * @param string Course id value
 	 * @return array Array of results
 	 */
-	protected function get_time_spent_on_the_course($user_id_field_name, $user_id_value) {
-		$results = array();
-		foreach($users as $user) {
-			$result_tmp = array();
-			$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
-			$result_tmp['user_id_value'] = $user['user_id_value'];
-			if($result_op instanceof WSError) {
-				// Return the error in the results
-				$result_tmp['result'] = $result_op->toArray();
-			} else {
-				$result_tmp['result'] = $this->getSuccessfulResult();
-			}
-			$results[] = $result_tmp;
-		}
-		return $results;
-	}
-
-	/**
-	 * Disables a user
-	 *
-	 * @param string API secret key
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
-	 * @param string User id value
-	 */
-	public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			// Let the implementation handle it
-			$this->handleError($verifKey);
-		} else {
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
-			if($result instanceof WSError) {
-				$this->handleError($result);
-			}
-		}
+	protected function get_time_spent_on_course($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value) {
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
+        if($user_id instanceof WSError) {
+            return $user_id;
+        }
+        $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
+        if($course_id instanceof WSError) {
+            return $course_id;
+        } else {
+            $course_code = CourseManager::get_course_code_from_course_id($course_id);
+        }
+        return Tracking::get_time_spent_on_the_course($user_id, $course_code);
 	}
 
-	/**
-	 * Disables multiple users
-	 *
-	 * @param string API secret key
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
-	 * than 0, an error occured
-	 */
-	public function DisableUsers($secret_key, $users) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			// Let the implementation handle it
-			$this->handleError($verifKey);
-		} else {
-			return $this->changeUsersActiveState($users, 0);
-		}
-	}
-
-	/**
-	 * Enables a user
-	 *
-	 * @param string API secret key
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
-	 * @param string User id value
-	 */
-	public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			$this->handleError($verifKey);
-		} else {
-			$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
-			if($result instanceof WSError) {
-				$this->handleError($result);
-			}
-		}
-	}
-
-	/**
-	 * Enables multiple users
-	 *
-	 * @param string API secret key
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
-	 * than 0, an error occured
-	 */
-	public function EnableUsers($secret_key, $users) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			// Let the implementation handle it
-			$this->handleError($verifKey);
-		} else {
-			return $this->changeUsersActiveState($users, 1);
-		}
-	}
-
-	/**
-	 * Deletes a user (helper method)
-	 *
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
-	 * @param string User id value
-	 * @return mixed True if user was successfully deleted, WSError otherwise
-	 */
-	protected function deleteUserHelper($user_id_field_name, $user_id_value) {
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
-		if($user_id instanceof WSError) {
-			return $user_id;
-		} else {
-			if(!UserManager::delete_user($user_id)) {
-				return new WSError(101, "There was a problem while deleting this user");
-			} else {
-				return true;
-			}
-		}
-	}
-
-	/**
-	 * Deletes a user
-	 *
-	 * @param string API secret key
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
-	 * @param string User id value
-	 */
-	public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			$this->handleError($verifKey);
-		} else {
-			$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
-			if($result instanceof WSError) {
-				$this->handleError($result);
-			}
-		}
-	}
-
-	/**
-	 * Deletes multiple users
-	 *
-	 * @param string API secret key
-	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
-	 * than 0, an error occured
-	 */
-	public function DeleteUsers($secret_key, $users) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			$this->handleError($verifKey);
-		} else {
-			$results = array();
-			foreach($users as $user) {
-				$result_tmp = array();
-				$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
-				$result_tmp['user_id_value'] = $user['user_id_value'];
-				if($result_op instanceof WSError) {
-					// Return the error in the results
-					$result_tmp['result'] = $result_op->toArray();
-				} else {
-					$result_tmp['result'] = $this->getSuccessfulResult();
-				}
-				$results[] = $result_tmp;
-			}
-			return $results;
-		}
-	}
-
-	/**
-	 * Creates a user (helper method)
-	 *
-	 * @param string User first name
-	 * @param string User last name
-	 * @param int User status
-	 * @param string Login name
-	 * @param string Password (encrypted or not)
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
-	 * to include the salt in the extra fields if you are encrypting the password
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
-	 * @param string User id value. Leave blank if you are using the internal user_id
-	 * @param int Visibility.
-	 * @param string User email.
-	 * @param string Language.
-	 * @param string Phone.
-	 * @param string Expiration date
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
-	 * @return mixed New user id generated by the system, WSError otherwise
-	 */
-	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras) {
-		// Add the original user id field name and value to the extra fields if needed
-		$extras_associative = array();
-		if($user_id_field_name != "chamilo_user_id") {
-			$extras_associative[$user_id_field_name] = $user_id_value;
-		}
-		foreach($extras as $extra) {
-			$extras_associative[$extra['field_name']] = $extra['field_value'];
-		}
-		$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
-		if (!$result) {
-			$failure = $api_failureList[0];
-			if($failure == 'login-pass already taken') {
-				return new WSError(102, 'This username is already taken');
-			} else if($failure == 'encrypt_method invalid') {
-				return new WSError(103, 'The encryption of the password is invalid');
-			} else {
-				return new WSError(104, 'There was an error creating the user');
-			}
-		} else {
-			return $result;
-		}
-	}
-
-	/**
-	 * Creates a user
-	 *
-	 * @param string API secret key
-	 * @param string User first name
-	 * @param string User last name
-	 * @param int User status
-	 * @param string Login name
-	 * @param string Password (encrypted or not)
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
-	 * to include the salt in the extra fields if you are encrypting the password
-	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
-	 * @param string User id value. Leave blank if you are using the internal user_id
-	 * @param int Visibility. Set by default to 1
-	 * @param string User email. Set by default to an empty string
-	 * @param string Language. Set by default to english
-	 * @param string Phone. Set by default to an empty string
-	 * @param string Expiration date. Set to null by default
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
-	 * @return int New user id generated by the system
-	 */
-	public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
-		// First, verify the secret key
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			$this->handleError($verifKey);
-		} else {
-			$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
-			if($result instanceof WSError) {
-				$this->handleError($result);
-			} else {
-				return $result;
-			}
-		}
-	}
-
-	/**
-	 * Creates multiple users
-	 *
-	 * @param string API secret key
-	 * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
-	 * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
-	 */
-	public function CreateUsers($secret_key, $users) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			$this->handleError($verifKey);
-		} else {
-			$results = array();
-			foreach($users as $user) {
-				$result_tmp = array();
-				extract($user);
-				$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
-				if($result instanceof WSError) {
-					$result_tmp['result'] = $result->toArray();
-					$result_tmp['user_id_value'] = $user_id_value;
-					$result_tmp['user_id_generated'] = 0;
-				} else {
-					$result_tmp['result'] = $this->getSuccessfulResult();
-					$result_tmp['user_id_value'] = $user_id_value;
-					$result_tmp['user_id_generated'] = $result;
-				}
-				$results[] = $result_tmp;
-			}
-			return $results;
-		}
-	}
-
-	/**
-	 * Edits user info (helper method)
-	 *
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
-	 * @param string User id value
-	 * @param string First name
-	 * @param string Last name
-	 * @param int User status
-	 * @param string Login name
-	 * @param string Password. Leave blank if you don't want to update it
-	 * @param string Encrypt method
-	 * @param string User email
-	 * @param string Language. Set by default to english
-	 * @param string Phone. Set by default to an empty string
-	 * @param string Expiration date. Set to null by default
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
-	 * @return mixed True if user was successfully updated, WSError otherwise
-	 */
-	protected function editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
-		if($user_id instanceof WSError) {
-			return $user_id;
-		} else {
-			if($password == '') {
-				$password = null;
-			}
-			$user_info = UserManager::get_user_info_by_id($user_id);
-			if(count($extras) == 0) {
-				$extras = null;
-			}
-			$result = UserManager::update_user($user_id, $firstname, $lastname, $loginname, $password, PLATFORM_AUTH_SOURCE, $email, $status, '', $phone, $user_info['picture_uri'], $expiration_date, $user_info['active'], null, $user_info['hr_dept_id'], $extras, $encrypt_method);
-			if (!$result) {
-				$failure = $api_failureList[0];
-				if($failure == 'encrypt_method invalid') {
-					return new WSError(103, 'The encryption of the password is invalid');
-				} else {
-					return new WSError(105, 'There was an error updating the user');
-				}
-			} else {
-				return $result;
-			}
-		}
-	}
-
-	/**
-	 * Edits user info
-	 *
-	 * @param string API secret key
-	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
-	 * @param string User id value
-	 * @param string First name
-	 * @param string Last name
-	 * @param int User status
-	 * @param string Login name
-	 * @param string Password. Leave blank if you don't want to update it
-	 * @param string Encrypt method
-	 * @param string User email
-	 * @param string Language. Set by default to english
-	 * @param string Phone. Set by default to an empty string
-	 * @param string Expiration date. Set to null by default
-	 * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
-	 */
-	public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
-		// First, verify the secret key
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			$this->handleError($verifKey);
-		} else {
-			$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $user_id_field_name, $email, $language, $phone, $expiration_date, $extras);
-			if($result instanceof WSError) {
-				$this->handleError($result);
-			}
-		}
-	}
-
-	/**
-	 * Edits multiple users
-	 *
-	 * @param string API secret key
-	 * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
-	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
-	 * than 0, an error occured
-	 */
-	public function EditUsers($secret_key, $users) {
-		$verifKey = $this->verifyKey($secret_key);
-		if($verifKey instanceof WSError) {
-			$this->handleError($verifKey);
-		} else {
-			$results = array();
-			foreach($users as $user) {
-				$result_tmp = array();
-				extract($user);
-				$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
-				$result_tmp['user_id_value'] = $user['user_id_value'];
-				if($result_op instanceof WSError) {
-					// Return the error in the results
-					$result_tmp['result'] = $result_op->toArray();
-				} else {
-					$result_tmp['result'] = $this->getSuccessfulResult();
-				}
-				$results[] = $result_tmp;
-			}
-			return $results;
-		}
-	}
+    /**
+     * Gets the time spent in a course by a given user
+     *
+     * @param string User id field name
+     * @param string User id value
+     * @param string Course id field name
+     * @param string Course id value
+     * @return array Array of results
+     */
+    protected function get_time_spent_on_course_in_session($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
+        if($user_id instanceof WSError) {
+            return $user_id;
+        }
+        $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
+        if($course_id instanceof WSError) {
+            return $course_id;
+        } else {
+            $course_code = CourseManager::get_course_code_from_course_id($course_id);
+        }
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
+        if($session_id instanceof WSError) {
+            return $session_id;
+        }
+        return Tracking::get_time_spent_on_the_course($user_id, $course_code, $session_id);
+    }
+    /**
+     * Gets a list of learning paths by course
+     *
+     * @param string User id field name
+     * @param string User id value
+     * @param string Course id field name
+     * @param string Course id value
+     * @return array Array of id=>title of learning paths
+     */
+    protected function get_learnpaths_by_course($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $lp_id) {
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
+        if($user_id instanceof WSError) {
+            return $user_id;
+        }
+        $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
+        if($course_id instanceof WSError) {
+            return $course_id;
+        } else {
+            $course_code = CourseManager::get_course_code_from_course_id($course_id);
+        }
+        require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
+        $list = new LearnpathList($user_id,$course_code);
+        $return = array();
+        foreach ($list as $id => $item) {
+            $return[] = array('id'=>$id, 'title' => $item);
+        }
+        return $return;
+    }
+    /**
+     * Gets score obtained in a learning path
+     *
+     * @param string User id field name
+     * @param string User id value
+     * @param string Course id field name
+     * @param string Course id value
+     * @param string Learnpath ID
+     * @return array Array of results
+     */
+    protected function get_user_learnpath($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) {
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
+        if($user_id instanceof WSError) {
+            return $user_id;
+        }
+        $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
+        if($course_id instanceof WSError) {
+            return $course_id;
+        } else {
+            $course_code = CourseManager::get_course_code_from_course_id($course_id);
+        }
+        require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
+        $lp = new learnpath($course_code, $learnpath_id, $user_id);
+        return $lp['progress'];
+    }
 }