Exemple #1
0
function visualiser_item()
{
    global $page;
    global $item;
    global $message;
    $page['gabarit'] = "administration";
    if (isset($_SESSION['role_user']) && droit_acces($item['visualiser_item'], $_SESSION['role_user'])) {
        if (is_proprietaire($_GET['id']) || is_partage_organisme($_SESSION['id_lieu'], $_GET['id'])) {
            $page['vue'] = "items/item.vue.php";
            $page['colonne'] = "items/sidebar_item.vue.php";
            $page['etat'] = liste_etat();
            $page['categorie'] = liste_categorie();
            $page['lieu'] = liste_lieux();
            $page['items'] = liste_item();
            $page['sphere'] = liste_sphere();
            $page['facteur'] = liste_facteur();
            $page['etat'] = liste_etat();
            $page['item'] = get_item($_GET['id']);
            $page['item'] = $page['item'][0];
            $page['item']['id_sphere'] = get_id_sphere($page['item']['id_categorie']);
            $page['item']['tests'] = get_test_from_item($_GET['id']);
        } else {
            $page['vue'] = "erreur_droit.vue.php";
            $page['message'] = $message['non_proprietaire'];
        }
    } else {
        $page['vue'] = "erreur_droit.vue.php";
    }
}
Exemple #2
0
function editer_test()
{
    global $page;
    global $item;
    global $message;
    $page['gabarit'] = "administration";
    if (isset($_SESSION['role_user']) && droit_acces($item['editer_item'], $_SESSION['role_user'])) {
        if (isset($_GET['id'])) {
            $id = $_GET['id'];
        }
        if (isset($_POST['id_test'])) {
            $id = $_POST['id_test'];
        }
        $page['vue'] = "tests/edit_test.vue.php";
        $page['test'] = get_test($id);
        $page['test'] = $page['test'][0];
        $page['test']['id_test'] = $id;
        $page['sphere'] = liste_sphere();
        $page['facteur'] = liste_facteur();
        $page['test']['id_sphere'] = get_id_sphere($page['test']['id_categorie']);
        $page['items'] = liste_item_by_categorie($page['test']['id_categorie'], $page['test']['id_projet']);
        $page['colonne'] = "tests/sidebar_edit_test.vue.php";
        $page['projet'] = liste_projet();
        if (isset($_POST['edit_test'])) {
            if (is_current_version_test($_POST['id_test'], $_POST['revision'])) {
                update_revision_test($_POST['id_test']);
                if (get_etat_test($_POST['id_test']) <= 2 && !has_reponse_test($_POST['id_test'])) {
                    //passer test en exerimentation
                    delete_test_section($_POST['id_test']);
                    if (isset($_POST['items'])) {
                        foreach ($_POST['items'] as $key => $it) {
                            $tabs = explode('|', $it);
                            if (sizeof($tabs) == 1) {
                                if (isset($_POST[$it . 'actif'])) {
                                    $actif = 'on';
                                } else {
                                    $actif = '';
                                }
                                if (isset($_POST[$it . 'score'])) {
                                    $score = 'on';
                                } else {
                                    $score = '';
                                }
                                if ($_POST[$it . 'chrono'] == "" || $_POST[$it . 'chrono'] <= 0) {
                                    $chrono = 0;
                                } else {
                                    $chrono = $_POST[$it . 'chrono'];
                                }
                                add_test_section($_POST['id_test'], $it, $key + 1, 'item', $actif, $score, $chrono);
                                set_item_to_experimentation($it);
                            } else {
                                if ($tabs[1] == 'illimit&eacute;e') {
                                    $tabs[1] = null;
                                }
                                $id_section = creation_section($tabs[0], intval($tabs[1]));
                                add_test_section($_POST['id_test'], $id_section, $key + 1, 'section');
                                foreach ($_POST[$tabs[2]] as $keys => $ite) {
                                    if (isset($_POST[$ite . 'actif'])) {
                                        $actif = 'on';
                                    } else {
                                        $actif = '';
                                    }
                                    if (isset($_POST[$ite . 'score'])) {
                                        $score = 'on';
                                    } else {
                                        $score = '';
                                    }
                                    if ($_POST[$ite . 'chrono'] == "" || $_POST[$ite . 'chrono'] <= 0) {
                                        $chrono = 0;
                                    } else {
                                        $chrono = $_POST[$ite . 'chrono'];
                                    }
                                    add_section_item($id_section, $ite, $keys + 1, $actif, $score, $chrono);
                                    set_item_to_experimentation($ite);
                                }
                            }
                        }
                    }
                    set_test_to_experimentation($_POST['id_test']);
                    //	header("Location: index.php?controleur=test&tache=base");
                    header("Location: index.php?controleur=test&tache=editer_test&id=" . $_POST['id_test'] . "&mesg=ok");
                } else {
                    header("Location: index.php?controleur=test&tache=visualiser_test&id=" . $_POST['id_test']);
                }
            } else {
                $page['message'] = $message['outdated_test'];
            }
        } else {
            $page['test'] = get_test($_GET['id']);
            $page['test'] = $page['test'][0];
            $page['test']['contenu_test'] = get_contenu_test($_GET['id']);
            $page['test']['id_sphere'] = get_id_sphere($page['test']['id_categorie']);
            $page['test']['id_test'] = $id;
            if (get_etat_test($page['test']['id_test']) > 2 || has_reponse_test($page['test']['id_test'])) {
                $page['message'] = $message['test_edition_disabled'];
            }
            foreach ($page['test']['contenu_test'] as $key => $content) {
                if ($content['type'] == 'item') {
                    $items = get_item($content['id_element']);
                    if (isset($items[0])) {
                        foreach ($items[0] as $k => $v) {
                            $page['test']['contenu_test'][$key][$k] = $v;
                        }
                    }
                    $page['test']['contenu_test'][$key]['type'] = 'item';
                } else {
                    $section = get_section($content['id_element']);
                    foreach ($section[0] as $k => $v) {
                        $page['test']['contenu_test'][$key][$k] = $v;
                    }
                    $page['test']['contenu_test'][$key]['type'] = 'section';
                }
                $page['test']['contenu_test'][$key]['item'] = get_item_by_section($content['id_element']);
            }
        }
    } else {
        $page['vue'] = "erreur_droit.vue.php";
    }
}