Skip to content
Snippets Groups Projects
Verified Commit 77b87f65 authored by Marco Schlicht's avatar Marco Schlicht :speech_balloon:
Browse files

minor changes

parent a0b37ee9
No related branches found
No related tags found
No related merge requests found
Showing
with 45 additions and 38 deletions
......@@ -40,10 +40,9 @@ namespace RwthMoodleApiLib;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @link https://git.rwth-aachen.de/moodle/rwth_moodle_api
**/
namespace RwthMoodleApiLib;
class Config
{
public static $debug_msgs = false;
public static $moodle_url = "https://d-mo01.devlef.campus.rwth-aachen.de/moodlems/";
}
?>
......@@ -79,7 +79,7 @@ class CourseRoom extends ApiController implements CourseRoomInterface
$dataSet = array();
foreach ($courses as $course) {
//TODO
$closed = !(((int)$course->enddate)===0 || ((int)$course->enddate)>time());
/* $closed = !(((int)$course->enddate)===0 || ((int)$course->enddate)>time()); */
$uniqueid = $course->id; // "12ws-00000",
$semester = "TODO"; // "ws12",
......
......@@ -93,7 +93,7 @@ class WhatsNew extends CourseRoom implements WhatsNewInterface
$sharedDocuments = array();
$wikis = array();
foreach ($updates->instances as $update) {
print_r($update);
/* print_r($update); */
/* $params_mod = array("cmid"=>$update->id); */
/* print_r($params_mod); */
/* $module_raw = $this->getApi()->restCall('core_course_get_course_module', $params_mod); */
......
......@@ -50,12 +50,12 @@ class BadResponseException extends RequestException implements BadResponseExcept
/**
* Constructor
*
* @param \GuzzleHttp\Exception\BadResponseException $gz Exception to wrap
* @param \GuzzleHttp\Exception\BadResponseException $gzhttp Exception to wrap
**/
public function __construct(\GuzzleHttp\Exception\BadResponseException $gz)
public function __construct(\GuzzleHttp\Exception\BadResponseException $gzhttp)
{
parent::__construct($gz);
$this->badResponseException = $gz;
parent::__construct($gzhttp);
$this->badResponseException = $gzhttp;
}
}
......
......@@ -50,12 +50,12 @@ class ClientException extends BadResponseException implements ClientExceptionInt
/**
* Constructor
*
* @param \GuzzleHttp\Exception\ClientException $gz Exception to wrap
* @param \GuzzleHttp\Exception\ClientException $gzhttp Exception to wrap
**/
public function __construct(\GuzzleHttp\Exception\ClientException $gz)
public function __construct(\GuzzleHttp\Exception\ClientException $gzhttp)
{
parent::__construct($gz);
$this->clientException = $gz;
parent::__construct($gzhttp);
$this->clientException = $gzhttp;
}
}
......
......@@ -50,12 +50,12 @@ class HttpException extends RwthMoodleApiLibException implements HttpExceptionIn
/**
* Constructor
*
* @param \GuzzleHttp\Exception\TransferException $gz exception to wrap
* @param \GuzzleHttp\Exception\TransferException $gzhttp exception to wrap
**/
public function __construct(\GuzzleHttp\Exception\TransferException $gz)
public function __construct(\GuzzleHttp\Exception\TransferException $gzhttp)
{
parent::__construct($gz);
$this->httpException = $gz;
parent::__construct($gzhttp);
$this->httpException = $gzhttp;
}
}
......
......@@ -105,6 +105,11 @@ class MoodleException extends MoodleResponseException implements MoodleException
return $this->moodleMessage;
}
/**
* Returns the error message as a string
*
* @return string error message
**/
public function __toString()
: string
{
......
......@@ -53,12 +53,12 @@ class RequestException extends HttpException implements RequestExceptionInterfac
/**
* Constructor
*
* @param \GuzzleHttp\Exception\RequestInterface $gz RequestException to wrap
* @param \GuzzleHttp\Exception\RequestInterface $gzhttp RequestException to wrap
**/
public function __construct(\GuzzleHttp\Exception\RequestException $gz)
public function __construct(\GuzzleHttp\Exception\RequestException $gzhttp)
{
parent::__construct($gz);
$this->requestException = $gz;
parent::__construct($gzhttp);
$this->requestException = $gzhttp;
}
/**
......
......@@ -50,12 +50,12 @@ class ServerException extends BadResponseException implements BadResponseExcepti
/**
* Constructor
*
* @param \GuzzleHttp\Exception\ServerException $gz Exception to wrap
* @param \GuzzleHttp\Exception\ServerException $gzhttp Exception to wrap
**/
public function __construct(\GuzzleHttp\Exception\ServerException $gz)
public function __construct(\GuzzleHttp\Exception\ServerException $gzhttp)
{
parent::__construct($gz);
$this->serverException = $gz;
parent::__construct($gzhttp);
$this->serverException = $gzhttp;
}
}
......
......@@ -55,15 +55,17 @@ class Injector implements InjectorInterface
/**
* Constructor
*
* @param string $url The url to moodle
**/
public function __construct($url=Null)
public function __construct($url=null)
{
//observers
$informationalObserver = new Logging\ConsoleLogger(6);
$infoObserver = new Logging\ConsoleLogger(6);
$warningObserver = new Logging\ConsoleLogger(4);
$criticalObserver = new Logging\ConsoleLogger(2);
$this->observers = array(
"informational" => $informationalObserver,
"informational" => $infoObserver,
"warning" => $warningObserver,
"critical" => $criticalObserver
);
......
......@@ -99,11 +99,10 @@ class RwthMoodleApiLib implements RwthMoodleApiLibInterface
throw new Exceptions\MoodleError($login->error, $login->errorcode, $response);
} else if (empty($login->token) && empty($login->privatetoken)) {
return false;
} else {
}
$this->moodleToken = $login->token??$login->privatetoken;
return true;
}
}
/**
* Login and get the Moodle token with the ext_token_login plugin
......@@ -128,14 +127,16 @@ class RwthMoodleApiLib implements RwthMoodleApiLibInterface
} else if (!empty($login->exception)) {
throw new Exceptions\MoodleException($login->exception, $login->errorcode, $login->message, $response);
} else if (!empty($login->error)) {
if (Config::$debug_msgs) {
print_r($login);
}
throw new Exceptions\MoodleError($login->error, $login->errorcode, $response);
} else if (empty($login->token) && empty($login->privatetoken)) {
return false;
} else {
}
$this->moodleToken = $login->token??$login->privatetoken;
return true;
}
}
/**
* Perform a rest call to the (already logged in) moodle webservice
......
......@@ -70,15 +70,15 @@ final class AnnouncementTest extends TestCase
}
/**
* Test case for viewAllCourseInfo
* Test case for viewAllAnnouncements
*
* @covers RwthMoodleApiLib\Controller\Announcement::viewAllCourseInfo()
* @covers RwthMoodleApiLib\Controller\Announcement::viewAllAnnouncements()
*
* @return none
**/
public function testViewAllCourseInfo()
public function testViewAllAnnouncements()
{
$announcement = $this->announcement->viewAllAnnouncements(3);
$announcement = $this->announcement->viewAllAnnouncements(2);
$this->assertTrue(true);
}
......
......@@ -78,7 +78,7 @@ final class WhatsNewTest extends TestCase
**/
public function testWhatsNewSince()
{
$this->whatsNew->whatsNewSince(3, 99999);
$this->whatsNew->whatsNewSince(2, 99999);
$this->assertTrue(true);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment