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