@@ -30,7 +30,7 @@ class evasys_synchronizer {
3030
3131 public function __construct ($ courseid ) {
3232 $ this ->courseid = $ courseid ;
33- $ this ->init_soap_client ();
33+ $ this ->soapclient = evasys_soap_client:: get ();
3434 $ this ->blockcontext = \context_course::instance ($ courseid ); // TODO Course context or block context? Check caps.
3535 $ this ->courseinformation = $ this ->get_course_information ();
3636 }
@@ -67,21 +67,6 @@ public function get_allocated_courses() {
6767 return $ this ->evasyscourses ;
6868 }
6969
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-
8570 private function get_course_information () {
8671 $ result = [];
8772 foreach ($ this ->get_allocated_courses () as $ course ) {
@@ -101,7 +86,7 @@ private function get_course_information() {
10186 * @return array of surveys with additional information
10287 */
10388 public function get_surveys ($ courseid ) {
104- if ($ this ->courseinformation [$ courseid ] === null ) {
89+ if (! isset ( $ this -> courseinformation [ $ courseid ]) || $ this ->courseinformation [$ courseid ] === null ) {
10590 return array ();
10691 }
10792 if (!isset ($ this ->courseinformation [$ courseid ]->m_oSurveyHolder ->m_aSurveys ->Surveys )) {
@@ -190,7 +175,8 @@ private function get_form_name($formid) {
190175 }
191176
192177 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 " )) {
194180 return 0 ;
195181 }
196182 if (is_object ($ this ->courseinformation [$ courseid ]->m_aoParticipants ->Persons )) {
0 commit comments