protected function in_alternative_role($context) {
        global $USER, $PAGE;
        if (!empty($USER->access['rsw']) && is_array($USER->access['rsw'])) {
            if (!empty($PAGE->context) && !empty($USER->access['rsw'][$PAGE->context->path])) {
                return $USER->access['rsw'][$PAGE->context->path];
            }
            foreach ($USER->access['rsw'] as $key=>$role) {
                if (strpos($context->path, $key)===0) {
                    return $role;
                }
            }
        }
        return false;
    }