Ejemplo n.º 1
0
$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':
        $form = importCategoryForm();
        if ($form->validate()) {
            $categories = Import::csv_reader($_FILES['file']['tmp_name']);
            if (!empty($categories)) {