$todb = new stdClass(); $todb->facetoface = $facetoface->id; $todb->datetimeknown = $fromform->datetimeknown; $todb->capacity = $fromform->capacity; $todb->allowoverbook = $fromform->allowoverbook; $todb->duration = $fromform->duration; $todb->normalcost = $fromform->normalcost; $todb->discountcost = $fromform->discountcost; $sessionid = null; $transaction = $DB->start_delegated_transaction(); $update = false; if (!$c and $session != null) { $update = true; $sessionid = $session->id; $todb->id = $session->id; if (!facetoface_update_session($todb, $sessiondates)) { $transaction->force_transaction_rollback(); // Logging and events trigger. $params = array('context' => $modulecontext, 'objectid' => $session->id); $event = \mod_facetoface\event\update_session_failed::create($params); $event->add_record_snapshot('facetoface_sessions', $session); $event->add_record_snapshot('facetoface', $facetoface); $event->trigger(); print_error('error:couldnotupdatesession', 'facetoface', $returnurl); } // Remove old site-wide calendar entry. if (!facetoface_remove_session_from_calendar($session, SITEID)) { $transaction->force_transaction_rollback(); print_error('error:couldnotupdatecalendar', 'facetoface', $returnurl); } } else {
function test_facetoface_update_session() { // test method - returns boolean $this->markTestSkipped('TODO - this test hasn\'t been working since 1.1'); // Test variables. $session1 = $this->sessions['sess0']; $sess0 = $this->array_to_object($session1); $sessiondates = new stdClass(); $sessiondates->sessionid = 1; $sessiondates->timestart = 1300; $sessiondates->timefinish = 1400; $sessiondates->sessionid = 1; // Test. $this->assertTrue((bool)facetoface_update_session($session, $sessiondates), $this->msgtrue); $this->resetAfterTest(true); }