Added new GetLearnpathHighestLessonLocation() webservice - refs BT#6667

1.9.x
Yannick Warnier 12 years ago
parent c9dc7ae249
commit 06cae6093d
  1. 44
      main/webservices/soap.test.php
  2. 10
      main/webservices/soap_report.php
  3. 33
      main/webservices/webservice_report.php

@ -0,0 +1,44 @@
<?php /* For licensing terms, see /license.txt */
/**
* Test script for soap.php
* @author Yannick Warnier <yannick.warnier@beeznest.com>
* @package chamilo.webservices
*/
/**
* Init
*/
exit; //remove to enable
// Include the necessary files, assuming this script is located in main/newscorm/ or something like that
require_once '../inc/global.inc.php';
global $_configuration;
// First build the signature to use with the webservice. We assume
// we are calling the webservice from the same server, so getting
// the IP (part of the signature) can be done through $_SERVER['REMOTE_ADDR']
$ip = trim($_SERVER['REMOTE_ADDR']);
$signature = sha1($ip.$_configuration['security_key']);
// Prepare the arguments to the webservice, based on the user ID (int), the course ID (int), the learnpath_id and the learnpath_item_id:
$uid = 1; // set to your user ID
$cid = 1; // set to your course ID
$lpid = 1; // set to your learnpath ID
$lpiid = 1; // set to your learnpath item ID
// Build the server's SOAP script address
$server = api_get_path(WEB_CODE_PATH).'webservices/soap.php?wsdl';
/**
* Call the webservice
*/
// Init the SOAP connection
$client = new SoapClient($server, array('cache_wsdl' => WSDL_CACHE_NONE));
// Call the function we want with the right params...
$response = $client->{'WSReport.test'}();
//$response = $client->{'WSReport.GetLearnpathStatusSingleItem'}($signature, 'chamilo_user_id', $uid, 'chamilo_course_id', $cid, $lpid, $lpiid);
//$response = $client->{'WSReport.GetLearnpathProgress'}($signature, 'chamilo_user_id', $uid, 'chamilo_course_id', $cid, $lpid);
//$response = $client->{'WSReport.GetLearnpathHighestLessonLocation'}($signature, 'chamilo_user_id', $uid, 'chamilo_course_id', $cid, $lpid);
// Print the output, or do whatever you like with it (it's the status for this item):
echo '<pre>'.$response.'</pre>';
// This should print "complete", "incomplete" or any other active status.

@ -146,14 +146,20 @@ $s->register(
);
$s->register(
'WSReport.GetLearnpathScoreSingleItem',
'WSReport.GetLearnpathHighestLessonLocation',
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' => 'xsd:string')
);
$s->register(
'WSReport.GetLearnpathScoreSingleItem',
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', 'learnpath_item_id' => 'xsd:string'),
array('return' => 'tns:score_result')
);
$s->register(
'WSReport.GetLearnpathStatusSingleItem',
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('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', 'learnpath_item_id' => 'xsd:string'),
array('return' => 'xsd:string')
);

@ -129,13 +129,44 @@ class WSReport extends WS {
}
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
$lp = new learnpath($course_code, $learnpath_id, $user_id);
$items = $lp->items[$learnpath_id];
$return = array(
'progress_bar_mode' => $lp->progress_bar_mode,
'progress_db' => $lp->progress_db,
);
return $return;
}
/**
* Gets the highest element seen (lesson_location) in the given learning
* path by the given user. If the user saw the learning path several times,
* the last time (lp_view) is assumed. If there are several items in the lp,
* the last item seen (lp_view.last_item) is considered as the relevant one
* to get the lesson_location from.
*
* @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 string The last item's lesson_location value
*/
public function GetLearnpathHighestLessonLocation($secret_key, $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);
$item = $lp->last_item_seen;
$return = $lp->items[$item]->get_lesson_location();
return $return;
}
/**
* Gets score obtained in the given learning path by the given user,

Loading…
Cancel
Save