@@ -30,7 +30,7 @@ class evasys_synchronizer {
30
30
31
31
public function __construct ($ courseid ) {
32
32
$ this ->courseid = $ courseid ;
33
- $ this ->init_soap_client ();
33
+ $ this ->soapclient = evasys_soap_client:: get ();
34
34
$ this ->blockcontext = \context_course::instance ($ courseid ); // TODO Course context or block context? Check caps.
35
35
$ this ->courseinformation = $ this ->get_course_information ();
36
36
}
@@ -67,21 +67,6 @@ public function get_allocated_courses() {
67
67
return $ this ->evasyscourses ;
68
68
}
69
69
70
- private function init_soap_client () {
71
- $ this ->soapclient = new \SoapClient (get_config ('block_evasys_sync ' , 'evasys_wsdl_url ' ), [
72
- 'trace ' => 1 ,
73
- 'exceptions ' => 0 ,
74
- 'location ' => get_config ('block_evasys_sync ' , 'evasys_soap_url ' )
75
- ]);
76
-
77
- $ headerbody = new \SoapVar ([
78
- new \SoapVar (get_config ('block_evasys_sync ' , 'evasys_username ' ), XSD_STRING , null , null , 'Login ' , null ),
79
- new \SoapVar (get_config ('block_evasys_sync ' , 'evasys_password ' ), XSD_STRING , null , null , 'Password ' , null ),
80
- ], SOAP_ENC_OBJECT );
81
- $ header = new \SOAPHEADER ('soap ' , 'Header ' , $ headerbody );
82
- $ this ->soapclient ->__setSoapHeaders ($ header );
83
- }
84
-
85
70
private function get_course_information () {
86
71
$ result = [];
87
72
foreach ($ this ->get_allocated_courses () as $ course ) {
@@ -101,7 +86,7 @@ private function get_course_information() {
101
86
* @return array of surveys with additional information
102
87
*/
103
88
public function get_surveys ($ courseid ) {
104
- if ($ this ->courseinformation [$ courseid ] === null ) {
89
+ if (! isset ( $ this -> courseinformation [ $ courseid ]) || $ this ->courseinformation [$ courseid ] === null ) {
105
90
return array ();
106
91
}
107
92
if (!isset ($ this ->courseinformation [$ courseid ]->m_oSurveyHolder ->m_aSurveys ->Surveys )) {
@@ -190,7 +175,8 @@ private function get_form_name($formid) {
190
175
}
191
176
192
177
public function get_amount_participants ($ courseid ) {
193
- if ($ this ->courseinformation [$ courseid ] === null || !property_exists ($ this ->courseinformation [$ courseid ]->m_aoParticipants , "Persons " )) {
178
+ if (!isset ($ this ->courseinformation [$ courseid ]) || $ this ->courseinformation [$ courseid ] === null
179
+ || !property_exists ($ this ->courseinformation [$ courseid ]->m_aoParticipants , "Persons " )) {
194
180
return 0 ;
195
181
}
196
182
if (is_object ($ this ->courseinformation [$ courseid ]->m_aoParticipants ->Persons )) {
0 commit comments