function activate_start_date() { if(document.getElementById(\'start_date_div\').style.display == \'none\') { document.getElementById(\'start_date_div\').style.display = \'block\'; } else { document.getElementById(\'start_date_div\').style.display = \'none\'; } } function activate_end_date() { if(document.getElementById(\'end_date_div\').style.display == \'none\') { document.getElementById(\'end_date_div\').style.display = \'block\'; } else { document.getElementById(\'end_date_div\').style.display = \'none\'; } } function feedbackselection() { var index = document.exercise_admin.exerciseFeedbackType.selectedIndex; if (index == \'1\') { document.exercise_admin.exerciseType[1].checked=true; document.exercise_admin.exerciseType[0].disabled=true; } else { document.exercise_admin.exerciseType[0].disabled=false; } } function option_time_expired() { if(document.getElementById(\'timercontrol\').style.display == \'none\') { document.getElementById(\'timercontrol\').style.display = \'block\'; } else { document.getElementById(\'timercontrol\').style.display = \'none\'; } } function check_per_page_one() { document.getElementById(\'exerciseType_0\').checked=true; } function check_per_page_all() { if (document.getElementById(\'exerciseType_1\') && document.getElementById(\'exerciseType_1\').checked) { document.getElementById(\'exerciseType_0\').checked = true; } } function check_feedback() { if (document.getElementById(\'result_disabled_1\').checked == true) { document.getElementById(\'result_disabled_0\').checked = true; } } function check_direct_feedback() { document.getElementById(\'option_page_one\').checked = true; document.getElementById(\'result_disabled_0\').checked = true; } function check_results_disabled() { document.getElementById(\'exerciseType_2\').checked = true; } function disabledHideRandom() { $("#hidden_random option:eq(0)").prop("selected", true); $("#hidden_random").hide(); } function checkQuestionSelection() { var selection = $("#questionSelection option:selected").val(); switch (selection) { case "'.EX_Q_SELECTION_ORDERED.'": disabledHideRandom(); $("#hidden_matrix").hide(); break; case "'.EX_Q_SELECTION_RANDOM.'": $("#hidden_random").show(); $("#hidden_matrix").hide(); break; case "'.EX_Q_SELECTION_CATEGORIES_ORDERED_QUESTIONS_ORDERED.'": disabledHideRandom(); $("#hidden_matrix").show(); break; case "per_categories": $("#questionSelection option:eq('.EX_Q_SELECTION_CATEGORIES_ORDERED_QUESTIONS_ORDERED.')").prop("selected", true); disabledHideRandom(); $("#hidden_matrix").show(); break; default: disabledHideRandom(); $("#hidden_matrix").show(); break; } } '; // to correct #4029 Random and number of attempt menu empty added window.onload=advanced_parameters; $htmlHeadXtra[] = ''; $objExercise = new Exercise(); $course_id = api_get_course_int_id(); //INIT FORM if (isset($_GET['exerciseId'])) { $form = new FormValidator( 'exercise_admin', 'post', api_get_self().'?'.api_get_cidreq().'&exerciseId='.intval($_GET['exerciseId']) ); $objExercise->read($_GET['exerciseId'], false); $form->addElement('hidden', 'edit', 'true'); } else { $form = new FormValidator( 'exercise_admin', 'post', api_get_self().'?'.api_get_cidreq() ); $form->addElement('hidden', 'edit', 'false'); } $objExercise->createForm($form); // VALIDATE FORM if ($form->validate()) { $objExercise->processCreation($form); if ($form->getSubmitValue('edit') === 'true') { Display::addFlash( Display::return_message(get_lang('Test name and settings have been saved.'), 'success') ); } else { Display::addFlash( Display::return_message(get_lang('Test added'), 'success') ); } $exercise_id = $objExercise->id; Session::erase('objExercise'); header('Location:admin.php?exerciseId='.$exercise_id.'&'.api_get_cidreq()); exit; } else { if (api_is_in_gradebook()) { $interbreadcrumb[] = [ 'url' => Category::getUrl(), 'name' => get_lang('Assessments'), ]; } $nameTools = get_lang('Tests management'); $interbreadcrumb[] = [ 'url' => 'exercise.php?'.api_get_cidreq(), 'name' => get_lang('Tests'), ]; $interbreadcrumb[] = [ 'url' => 'admin.php?exerciseId='.$objExercise->id.'&'.api_get_cidreq(), 'name' => $objExercise->selectTitle(true), ]; Display::display_header($nameTools, get_lang('Test')); echo '