Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->comment(PHP_EOL . 'modifiyng' . PHP_EOL);
     $sessions = ClassroomSession::select('id', 'teacher_id', 'admin_link', 'subject_subject_id', 'interval_id', 'title', 'wiziq_id', 'duration', 'start_at')->whereDate('start_at', '=', date('Y-m-d'))->with('subject', 'interval', 'teacher')->get();
     foreach ($sessions as $session) {
         try {
             $classroom = WiziqClassroom::build($session->interval->title . " - " . $session->subject->name, new \DateTime($session->start_at))->withDuration($session->duration)->withPresenter($session->teacher->id, $session->teacher->name)->withAttendeeLimit(config("classrooms.attendee_limit"))->withReturnUrl('')->withCreateRecording(true)->withPresenterDefaultControls('audio, video')->withTimeZone("Asia/Muscat")->withStatusPingUrl("https://www.google.com")->withLanguageCultureName("ar-SA");
             $WiziqApi = new WiziqApi();
             $WiziqApi->modify($session->wiziq_id, $classroom);
             $attendees = Attendees::build()->add(9999999999.0, 'النظام', 'ar-SA');
             $response = $WiziqApi->addAttendeesToClass($session->wiziq_id, $attendees);
             $session->admin_link = $response[0]['url'];
             $session->save();
         } catch (\mikemix\Wiziq\Common\Api\Exception\CallException $e) {
             Mail::send('emails.classrooms_modify', ['error' => $e->getMessage(), 'time' => $session->start_at], function ($m) {
                 $m->to('*****@*****.**', 'علي اليزيدي')->to('*****@*****.**', 'محسن بخيش')->subject('حدث مشكل اثناء تعديل الفصول');
             });
             $this->comment(PHP_EOL . $e->getMessage() . " - " . $session->id . ' - ' . $session->start_at . PHP_EOL);
         } catch (\mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
             Mail::send('emails.classrooms_modify', ['error' => $e->getMessage(), 'time' => $session->start_at], function ($m) {
                 $m->to('*****@*****.**', 'علي اليزيدي')->to('*****@*****.**', 'محسن بخيش')->subject('حدث مشكل اثناء تعديل الفصول');
             });
             $this->comment(PHP_EOL . $e->getMessage() . " - " . $session->id . ' - ' . $session->start_at . PHP_EOL);
         }
     }
     $this->comment(PHP_EOL . 'finished modifiyng' . PHP_EOL);
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->comment(PHP_EOL . 'adding' . PHP_EOL);
     $sessions = ClassroomSession::select('classroom_sessions.wiziq_id', 'classroom_sessions.id', 'classroom_sessions.classroom_id')->whereDate('classroom_sessions.start_at', '>', date('Y-m-d'))->with(['classroom' => function ($query) {
         return $query->select('classrooms.id');
     }, 'classroom.students' => function ($query) {
         return $query->select('students.id', 'students.name');
     }, 'studentsSessions' => function ($query) {
         return $query->select('student_id', 'classroom_session_id');
     }])->get();
     foreach ($sessions as $session) {
         $classroomId = $session->wiziq_id;
         $error = 0;
         $WiziqApi = new WiziqApi();
         // var_dump($session->classroom->students->count());
         foreach ($session->classroom->students as $student) {
             $exist = $session->studentsSessions->filter(function ($value) use($student) {
                 return $value->student_id == $student->id;
             });
             if ($exist->count()) {
                 continue;
             }
             $this->comment(PHP_EOL . ' not exist ' . PHP_EOL);
             try {
                 $attendees = Attendees::build()->add($student->id, $student->name, 'ar-SA');
                 // add more if needed
                 $response = $WiziqApi->addAttendeesToClass($classroomId, $attendees);
                 $data = ['student_link' => $response[0]['url'], 'attendee_id' => $response[0]['id'], 'classroom_session_id' => $session->id, 'student_id' => $student->id, 'semester_id' => semester()->id];
                 StudentClassroomSession::create($data);
             } catch (\mikemix\Wiziq\Common\Api\Exception\CallException $e) {
                 $this->comment(PHP_EOL . ' call exception ' . PHP_EOL);
                 $error = 1;
             } catch (\mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
                 $this->comment(PHP_EOL . ' invalid response exception ' . PHP_EOL);
                 $error = 1;
             } catch (\ErrorException $e) {
                 $this->comment(PHP_EOL . ' error exception ' . PHP_EOL);
                 $error = 1;
             }
         }
     }
     $this->comment(PHP_EOL . 'added' . PHP_EOL);
 }
 private function createStudentsSessions($students, $session)
 {
     $classroomId = $session->wiziq_id;
     $error = 0;
     $WiziqApi = new WiziqApi();
     //Log::info("adding attendeees");
     foreach ($students as $student) {
         try {
             $attendees = Attendees::build()->add($student->id, $student->name, 'ar-SA');
             // add more if needed
             //Log::info("added attendees");
             $response = $WiziqApi->addAttendeesToClass($classroomId, $attendees);
             //Log::info($response);
             $data = ['student_link' => $response[0]['url'], 'attendee_id' => $response[0]['id'], 'classroom_session_id' => $session->id, 'student_id' => $student->id, 'semester_id' => semester()->id];
             //Log::info($data);
             StudentClassroomSession::create($data);
             //Log::info(var_dump($response));
         } catch (\mikemix\Wiziq\Common\Api\Exception\CallException $e) {
             // Log::warning($e->getMessage());
             $error = 1;
         } catch (\mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
             // Log::warning($e->getMessage());
             $error = 1;
         } catch (\ErrorException $e) {
             $error = 1;
         }
     }
     return $error;
 }
Ejemplo n.º 4
0
 public function attendeeurl(ClassroomSession $session)
 {
     $url = Cache::remember('session_url_for_admin' . $session->wiziq_id, 360, function () use($session) {
         $classroomId = $session->wiziq_id;
         $error = 0;
         $WiziqApi = new WiziqApi();
         $attendees = Attendees::build()->add(9999999999.0, 'النظام', 'ar-SA');
         // add more if needed
         //Log::info("added attendees");
         try {
             $response = $WiziqApi->addAttendeesToClass($classroomId, $attendees);
             return $response[0]['url'];
         } catch (\mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
             return back()->with('error', 'وقع خلل');
         }
     });
     return redirect($url);
 }