Ejemplo n.º 1
0
</script>';
// Breadcrumbs
$interbreadcrumb[] = array("url" => "exercice.php", "name" => get_lang('Exercices'));
Display::display_header(get_lang('Category'));
// Action handling: add, edit and remove
if (isset($_GET['action']) && $_GET['action'] == 'addcategory') {
    add_category_form($_GET['action'], $type);
} else {
    if (isset($_GET['action']) && $_GET['action'] == 'addcategoryglobal') {
        add_category_form($_GET['action'], $type);
    } else {
        if (isset($_GET['action']) && $_GET['action'] == 'editcategory') {
            edit_category_form($_GET['action'], $type);
        } else {
            if (isset($_GET['action']) && $_GET['action'] == 'deletecategory') {
                delete_category_form($_GET['action'], $type);
            } else {
                display_add_category($type);
                display_categories($type);
            }
        }
    }
}
Display::display_footer();
// FUNCTIONS
// form to edit a category
function edit_category_form($in_action, $type = 'simple')
{
    $in_action = Security::remove_XSS($in_action);
    if (isset($_GET['category_id']) && is_numeric($_GET['category_id'])) {
        $category_id = Security::remove_XSS($_GET['category_id']);
Ejemplo n.º 2
0
$category = new TestCategory();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
// breadcrumbs
$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
Display::display_header(get_lang('Category'));
// Action handling: add, edit and remove
if (isset($_GET['action']) && $_GET['action'] == 'addcategory') {
    add_category_form($_GET['action']);
    display_add_category();
} else {
    if (isset($_GET['action']) && $_GET['action'] == 'editcategory') {
        edit_category_form($_GET['action']);
    } else {
        if (isset($_GET['action']) && $_GET['action'] == 'deletecategory') {
            delete_category_form($_GET['action']);
            display_add_category();
        } else {
            display_add_category();
        }
    }
}
echo $category->displayCategories($courseId, $sessionId);
Display::display_footer();
/**
 * Form to edit a category
 * @todo move to TestCategory.class.php
 * @param string $action
 */
function edit_category_form($action)
{
Ejemplo n.º 3
0
$category = new TestCategory();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
// breadcrumbs
$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
$action = isset($_GET['action']) ? $_GET['action'] : '';
$content = '';
switch ($action) {
    case 'addcategory':
        $content = add_category_form('addcategory');
        break;
    case 'editcategory':
        $content = edit_category_form('editcategory');
        break;
    case 'deletecategory':
        delete_category_form('deletecategory');
        break;
    case 'export_category':
        $archiveFile = 'export_exercise_categoroes_' . api_get_course_id() . '_' . api_get_local_time();
        $categories = $category->getCategories($courseId, $sessionId);
        $export = [];
        $export[] = ['title', 'description'];
        if (!empty($categories)) {
            foreach ($categories as $category) {
                $export[] = [$category['title'], $category['description']];
            }
        }
        Export::arrayToCsv($export, $archiveFile);
        exit;
        break;
    case 'import_category':