} else if ($form->is_cancelled()) {
    $script = "
        <html>
            <script type=\"text/javascript\">
                window.close();
            </script>
        </html>
    ";

    echo $script;
    die;
}

// Delete action is called via ajax.
if ($action == 'delete') {
    lti_delete_type($typeid);
    die;
}

echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('toolsetup', 'lti'));

if ($action == 'add') {
    $form->display();
} else if ($action == 'edit') {
    $type = lti_get_type_type_config($typeid);
    $form->set_data($type);
    $form->display();
}
Esempio n. 2
0
        redirect($redirect);
    }

} else if (isset($data->cancel)) {
    redirect($redirect);

} else if ($action == 'accept') {
    lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);
    redirect($redirect);

} else if ($action == 'reject') {
    lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);
    redirect($redirect);

} else if ($action == 'delete') {
    lti_delete_type($id);
    redirect($redirect);
}

// print header stuff
$PAGE->set_focuscontrol($focus);
if (empty($SITE->fullname)) {
    $PAGE->set_title($settingspage->visiblename);
    $PAGE->set_heading($settingspage->visiblename);

    $PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');

    echo $OUTPUT->header();

    echo $OUTPUT->box(get_string('configintrosite', 'admin'));
Esempio n. 3
0
 /**
  * Delete a tool type.
  *
  * @param int $id The id of the tool type to be deleted
  * @return array deleted tool type
  * @since Moodle 3.1
  * @throws moodle_exception
  */
 public static function delete_tool_type($id)
 {
     $params = self::validate_parameters(self::delete_tool_type_parameters(), array('id' => $id));
     $id = $params['id'];
     $context = context_system::instance();
     self::validate_context($context);
     require_capability('moodle/site:config', $context);
     $type = lti_get_type($id);
     if (!empty($type)) {
         lti_delete_type($id);
         // If this is the last type for this proxy then remove the proxy
         // as well so that it isn't orphaned.
         $types = lti_get_lti_types_from_proxy_id($type->toolproxyid);
         if (empty($types)) {
             lti_delete_tool_proxy($type->toolproxyid);
         }
     }
     return array('id' => $id);
 }
Esempio n. 4
0
/**
 * Delete a Tool Proxy
 *
 * @param int $id   Tool Proxy id
 */
function lti_delete_tool_proxy($id)
{
    global $DB;
    $DB->delete_records('lti_tool_settings', array('toolproxyid' => $id));
    $tools = $DB->get_records('lti_types', array('toolproxyid' => $id));
    foreach ($tools as $tool) {
        lti_delete_type($tool->id);
    }
    $DB->delete_records('lti_tool_proxies', array('id' => $id));
}
Esempio n. 5
0
function pearsondirect_handle_code_change($courseconfig, $newcode, $newparams)
{
    global $DB, $CFG;
    require_once $CFG->dirroot . '/mod/lti/locallib.php';
    require_once $CFG->dirroot . '/course/lib.php';
    $types = $DB->get_records('lti_types', array('course' => $courseconfig->course));
    if ($types) {
        foreach ($types as $type) {
            if (!strncmp($type->tooldomain, 'pearson:', strlen('pearson:'))) {
                lti_delete_type($type->id);
            }
        }
    }
    $coursemodules = $DB->get_records('course_modules', array('course' => $courseconfig->course, 'module' => pearsondirect_get_lti_module()));
    if ($coursemodules) {
        foreach ($coursemodules as $cm) {
            if (!strncmp($cm->idnumber, 'pearson:', strlen('pearson:'))) {
                course_delete_module($cm->id);
            }
        }
    }
}