Some fixes for webservices functions about report

skala
Christian Fasanando 15 years ago
parent 259651ae9a
commit 5b408460c3
  1. 26
      main/webservices/soap.php
  2. 6
      main/webservices/soap_course.php
  3. 52
      main/webservices/soap_report.php
  4. 4
      main/webservices/soap_session.php
  5. 8
      main/webservices/soap_user.php
  6. 11
      main/webservices/webservice.php
  7. 39
      main/webservices/webservice_report.php

@ -70,6 +70,29 @@ $s->wsdl->addComplexType(
)
);
$s->wsdl->addComplexType(
'extras',
'complexType',
'struct',
'all',
'',
array(
'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'),
'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
)
);
$s->wsdl->addComplexType(
'extra_field',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),'tns:extras'
);
/*
$s->wsdl->addComplexType(
'extra_field',
'complexType',
@ -81,6 +104,7 @@ $s->wsdl->addComplexType(
'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
)
);
*/
$s->register(
'WS.test',
@ -95,4 +119,4 @@ require_once(dirname(__FILE__).'/soap_report.php');
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$s->service($HTTP_RAW_POST_DATA);
$s->service($HTTP_RAW_POST_DATA);

@ -71,7 +71,7 @@ $s->register(
'language' => 'xsd:string',
'course_id_field_name' => 'xsd:string',
'course_id_value' => 'xsd:string',
'extras' => 'tns:extra_field[]'
'extras' => 'tns:extra_field'
),
array('return' => 'xsd:int')
);
@ -92,7 +92,7 @@ $s->wsdl->addComplexType(
'language' => array('name' => 'language', 'type' => 'xsd:string'),
'course_id_field_name' => array('name' => 'course_id_field_name', 'type' => 'xsd:string'),
'course_id_value' => array('name' => 'course_id_value', 'type' => 'xsd:string'),
'extras' => array('name' => 'extras', 'type' => 'tns:extra_field[]')
'extras' => array('name' => 'extras', 'type' => 'tns:extra_field')
)
);
@ -144,7 +144,7 @@ $s->register(
'subscribe' => 'xsd:int',
'unsubscribe' => 'xsd:int',
'visual_code' => 'xsd:string',
'extras' => 'tns:extra_field[]'
'extras' => 'tns:extra_field'
)
);

@ -44,6 +44,7 @@ $s->wsdl->addComplexType(
)
);
/*
$s->wsdl->addComplexType(
'user_result',
'complexType',
@ -54,6 +55,45 @@ $s->wsdl->addComplexType(
'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
);*/
$s->wsdl->addComplexType(
'user_result',
'complexType',
'struct',
'all',
'',
array(
'id' => array('name' => 'id', 'type' => 'xsd:string'),
'title' => array('name' => 'title', 'type' => 'xsd:string')
)
);
$s->wsdl->addComplexType(
'progress_result',
'complexType',
'struct',
'all',
'',
array(
'progress_bar_mode' => array('name' => 'progress_bar_mode', 'type' => 'xsd:string'),
'progress_db' => array('name' => 'progress_db', 'type' => 'xsd:string')
)
);
$s->wsdl->addComplexType(
'score_result',
'complexType',
'struct',
'all',
'',
array(
'min_score' => array('name' => 'min_score', 'type' => 'xsd:string'),
'max_score' => array('name' => 'max_score', 'type' => 'xsd:string'),
'mastery_score' => array('name' => 'mastery_score', 'type' => 'xsd:string'),
'current_score' => array('name' => 'current_score', 'type' => 'xsd:string'),
)
);
$s->wsdl->addComplexType(
@ -67,6 +107,8 @@ $s->wsdl->addComplexType(
'tns:user_result'
);
$s->register(
'WSReport.GetTimeSpentOnPlatform',
array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string'),
@ -93,20 +135,20 @@ $s->register(
$s->register(
'WSReport.GetLearnpathsByCourse',
array('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'),
array('return' => 'tns:user_result_array')
);
$s->register(
'WSReport.GetLearnpathProgress',
array('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')
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:progress_result')
);
$s->register(
'WSReport.GetLearnpathScoreSingleItem',
array('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')
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:score_result')
);
$s->register(

@ -25,7 +25,7 @@ $s->register(
'user_id_value' => 'xsd:string',
'session_id_field_name' => 'xsd:string',
'session_id_value' => 'xsd:string',
'extras' => 'tns:extra_field[]'
'extras' => 'tns:extra_field'
),
array('return' => 'xsd:int')
);
@ -54,7 +54,7 @@ $s->register(
'user_id_value' => 'xsd:string',
'session_id_field_name' => 'xsd:string',
'session_id_value' => 'xsd:string',
'extras' => 'tns:extra_field[]'
'extras' => 'tns:extra_field'
)
);

@ -98,7 +98,7 @@ $s->register(
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:extra_field[]'
'extras' => 'tns:extra_field'
),
array('return' => 'xsd:int')
);
@ -123,7 +123,7 @@ $s->wsdl->addComplexType(
'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[]')
'extras' => array('name' => 'extras', 'type' => 'tns:extra_field')
)
);
@ -176,7 +176,7 @@ $s->register(
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:extra_field[]'
'extras' => 'tns:extra_field'
)
);
@ -199,7 +199,7 @@ $s->wsdl->addComplexType(
'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[]')
'extras' => array('name' => 'extras', 'type' => 'tns:extra_field')
)
);

@ -162,12 +162,19 @@ class WS {
}
} else {
$course_code = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
if (!empty($course_code)) {
$course_info = CourseManager::get_course_information($course_code);
return $course_info['id'];
} else {
return new WSError(200, "Course not found");
}
/*
if($course_code == 0) {
return new WSError(200, "Course not found");
} else {
$course_info = CourseManager::get_course_information($course_code);
return $course_info['id'];
}
}
*/
}
}

@ -90,7 +90,7 @@ class WSReport extends WS {
* @param string Course id value
* @return array Array of id=>title of learning paths
*/
public function GetLearnpathsByCourse($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $lp_id) {
public function GetLearnpathsByCourse($secret_key, $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;
@ -101,11 +101,13 @@ class WSReport extends WS {
} 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);
$lp = new LearnpathList($user_id,$course_code);
$list = $lp->list;
$return = array();
foreach ($list as $id => $item) {
$return[] = array('id'=>$id, 'title' => $item);
$return[] = array('id'=>$id, 'title' => $item['lp_name']);
}
return $return;
}
@ -119,7 +121,7 @@ class WSReport extends WS {
* @param string Learnpath ID
* @return double Between 0 and 100 (% of progress)
*/
public function GetLearnpathProgress($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) {
public function GetLearnpathProgress($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;
@ -132,8 +134,14 @@ 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);
return $lp['progress'];
$items = $lp->items[$learnpath_id];
$return = array(
'progress_bar_mode' => $lp->progress_bar_mode,
'progress_db' => $lp->progress_db,
);
return $return;
}
/**
* Gets score obtained in the given learning path by the given user,
* assuming there is only one item (SCO) in the learning path
@ -145,7 +153,7 @@ class WSReport extends WS {
* @param string Learnpath ID
* @return double Generally between 0 and 100
*/
public function GetLearnpathScoreSingleItem($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) {
public function GetLearnpathScoreSingleItem($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;
@ -158,8 +166,13 @@ 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);
//return $lp['progress'];
return 100;
$return = array(
'min_score' => $lp->items[$learnpath_id]->min_score,
'max_score' => $lp->items[$learnpath_id]->max_score,
'mastery_score' => $lp->items[$learnpath_id]->mastery_score,
'current_score' => $lp->items[$learnpath_id]->current_score,
);
return $return;
}
/**
* Gets status obtained in the given learning path by the given user,
@ -173,8 +186,7 @@ class WSReport extends WS {
* @param string Learnpath ID
* @return string "not attempted", "passed", "completed", "failed", "incomplete"
*/
public function GetLearnpathStatusSingleItem($secret_key, $user_id_field_name = 'chamilo_user_id', $user_id_value, $course_id_field_name = 'chamilo_course_id', $course_id_value, $learnpath_id) {
return null;
public function GetLearnpathStatusSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
@ -188,13 +200,14 @@ class WSReport extends WS {
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);
error_log('Ready to return status for '.$course_code.'-'.$learnpath_id.'-'.$user_id.': '.$lp->items[0]['status']);
return $lp->items[0]['status'];
return $lp->items[$learnpath_id]->status;
}
}
public function test() {
return 'Hello world!';
}

Loading…
Cancel
Save