|
16 | 16 |
|
17 | 17 | namespace block_evasys_sync;
|
18 | 18 |
|
| 19 | +use block_evasys_sync\local\entity\evaluation_state; |
| 20 | + |
19 | 21 | defined('MOODLE_INTERNAL') || die();
|
20 | 22 |
|
21 | 23 | require_once($CFG->libdir . '/adminlib.php');
|
@@ -56,7 +58,6 @@ private function get_course_information() {
|
56 | 58 | foreach ($this->get_allocated_courses() as $course) {
|
57 | 59 | $soapresult = $this->soapclient->GetCourse($course, 'PUBLIC', true, true);
|
58 | 60 | if (is_soap_fault($soapresult)) {
|
59 |
| - var_dump($soapresult); |
60 | 61 | // var_dump("soap verbindung nicht funktioniert");
|
61 | 62 | // This happens e.g. if there is no corresponding course in EvaSys.
|
62 | 63 | return null;
|
@@ -354,26 +355,33 @@ static public function get_assigned_user($course) {
|
354 | 355 | */
|
355 | 356 | public function set_evaluation_period($dates) : bool {
|
356 | 357 | $usestandardtime = ($dates == 'Standard');
|
| 358 | + $course = get_course($this->courseid); |
357 | 359 | if ($usestandardtime) {
|
358 |
| - $course = get_course($this->courseid); |
359 | 360 | $dates = self::get_standard_timemode($course->category);
|
360 | 361 | }
|
361 | 362 | $changed = false;
|
362 |
| - $data = course_evaluation_allocation::get_record_by_course($this->courseid, false); |
| 363 | + $data = evaluation::for_course($this->courseid); |
363 | 364 | if (!$data) {
|
364 |
| - $data = new course_evaluation_allocation(0); |
365 |
| - $data->set('course', $this->courseid); |
366 |
| - $data->set('state', course_evaluation_allocation::STATE_MANUAL); |
| 365 | + $data = new evaluation(); |
| 366 | + $data->courses = [$this->courseid]; |
| 367 | + foreach ($this->courseinformation as $lsfid => $information) { |
| 368 | + $data->evaluations[$lsfid] = (object) [ |
| 369 | + 'title' => $this->get_raw_course_name($lsfid), |
| 370 | + 'lsfid' => $lsfid, |
| 371 | + 'start' => $dates['start'], |
| 372 | + 'end' => $dates['end'], |
| 373 | + 'state' => evaluation_state::MANUAL |
| 374 | + ]; |
| 375 | + } |
367 | 376 | } else {
|
368 |
| - // Don't display date changed warning on first sync. |
369 |
| - if ($data->get('startdate') != $dates['start'] || $data->get('enddate') != $dates['end']) { |
370 |
| - $changed = true; |
| 377 | + foreach ($data->evaluations as &$evaluation) { |
| 378 | + if ($evaluation->start != $dates['start'] || $evaluation['end'] != $dates['end']) { |
| 379 | + $changed = true; |
| 380 | + $evaluation->start = $dates['start']; |
| 381 | + $evaluation->end = $dates['end']; |
| 382 | + } |
371 | 383 | }
|
372 | 384 | }
|
373 |
| - |
374 |
| - $data->set('startdate', $dates['start']); |
375 |
| - $data->set('enddate', $dates['end']); |
376 |
| - $data->set('usestandardtime', $usestandardtime); |
377 | 385 | $data->save();
|
378 | 386 |
|
379 | 387 | return $changed;
|
|
0 commit comments