Ejemplo n.º 1
0
    $todb->usermodified = $USER->id;
    $todb->roomid = 0;

    $transaction = $DB->start_delegated_transaction();

    $update = false;
    if (!$c and $session != null) {
        $update = true;
        $todb->id = $session->id;
        $sessionid = $session->id;
        if (!facetoface_update_session($todb, $sessiondates)) {
            add_to_log($course->id, 'facetoface', 'update session (FAILED)', "sessions.php?s=$session->id", $facetoface->id, $cm->id);
            print_error('error:couldnotupdatesession', 'facetoface', $returnurl);
        }
    } else {
        if (!$sessionid = facetoface_add_session($todb, $sessiondates,$fromform)) {
            add_to_log($course->id, 'facetoface', 'add session (FAILED)', 'sessions.php?f='.$facetoface->id, $facetoface->id, $cm->id);
            print_error('error:couldnotaddsession', 'facetoface', $returnurl);
        }
    }

    // Save session room info.
    if (!facetoface_save_session_room($sessionid, $fromform)) {
        add_to_log($course->id, 'facetoface', 'save room (FAILED)', 'room/manage.php', $facetoface->id, $cm->id);
        print_error('error:couldnotsaveroom', 'facetoface');
    }

    foreach ($customfields as $field) {
        // Need to be able to clear fields.
        $fieldname = "custom_$field->shortname";
        if (!isset($fromform->$fieldname)) {
Ejemplo n.º 2
0
         $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 {
     if (!($sessionid = facetoface_add_session($todb, $sessiondates))) {
         $transaction->force_transaction_rollback();
         // Logging and events trigger.
         $params = array('context' => $modulecontext, 'objectid' => $facetoface->id);
         $event = \mod_facetoface\event\add_session_failed::create($params);
         $event->add_record_snapshot('facetoface', $facetoface);
         $event->trigger();
         print_error('error:couldnotaddsession', 'facetoface', $returnurl);
     }
 }
 foreach ($customfields as $field) {
     $fieldname = "custom_{$field->shortname}";
     if (!isset($fromform->{$fieldname})) {
         $fromform->{$fieldname} = '';
         // Need to be able to clear fields.
     }
Ejemplo n.º 3
0
    function test_facetoface_add_session() {
        // Test. method - returns false or session id number
        $this->markTestSkipped('TODO - this test hasn\'t been working since 1.1');

        //variable for test
        $session1 = $this->sessions['sess0'];
        $sess0 = $this->array_to_object($session1);

        // Test.
        $this->assertEquals(facetoface_add_session($session1, $sessiondates1), 4);
        $this->resetAfterTest(true);
    }