123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
- include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
- include_once(api_get_path(LIBRARY_PATH).'image.lib.php');
- if(!defined('ALLOWED_TO_INCLUDE'))
- {
- exit();
- }
- if(isset($_GET['editQuestion']))
- {
- $objQuestion = Question::read ($_GET['editQuestion']);
- $action = api_get_self()."?modifyQuestion=".$modifyQuestion."&editQuestion=".$objQuestion->id;
-
-
- if (isset($exerciseId) && !empty($exerciseId)) {
- $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
- $sql="SELECT max_score FROM $TBL_LP_ITEM
- WHERE item_type = '".TOOL_QUIZ."' AND path ='".Database::escape_string($exerciseId)."'";
- $result = api_sql_query($sql);
- if (Database::num_rows($result) > 0) {
- Display::display_warning_message(get_lang('EditingScoreCauseProblemsToExercisesInLP'));
- }
- }
-
- } else {
- $objQuestion = Question :: getInstance($_REQUEST['answerType']);
- $action = api_get_self()."?modifyQuestion=".$modifyQuestion."&newQuestion=".$newQuestion;
- }
- if(is_object($objQuestion))
- {
-
-
- $styles = '
- <style>
- div.row div.label{
- width: 10%;
- }
- div.row div.formw{
- width: 85%;
- }
- </style>
- ';
- echo $styles;
-
- $form = new FormValidator('question_admin_form','post',$action);
-
- if(isset($_GET['editQuestion'])) {
- $class="save";
- $text=get_lang('ModifyQuestion');
- } else {
- $class="add";
- $text=get_lang('AddQuestionToExercise');
- }
- $types_information = $objQuestion->get_types_information();
- $form_title_extra = get_lang($types_information[$_REQUEST['answerType']][1]);
-
-
- $form->addElement('header', '', $text.': '.$form_title_extra);
-
-
- $objQuestion -> createForm ($form,array('Height'=>150));
-
- $objQuestion -> createAnswersForm ($form);
-
-
-
-
-
-
- if(isset($_POST['submitQuestion']) && $form->validate())
- {
-
-
- $objQuestion -> processCreation($form,$objExercise);
-
- $objQuestion -> processAnswersCreation($form,$nb_answers);
-
-
- if($objQuestion -> type != HOT_SPOT)
- echo '<script type="text/javascript">window.location.href="admin.php"</script>';
- else
- echo '<script type="text/javascript">window.location.href="admin.php?hotspotadmin='.$objQuestion->id.'"</script>';
- }
- else
- {
-
- echo '<h3>'.$questionName.'</h3>';
- if(!empty($pictureName)){
- echo '<img src="../document/download.php?doc_url=%2Fimages%2F'.$pictureName.'" border="0">';
- }
- if(!empty($msgErr))
- {
- Display::display_normal_message($msgErr);
- }
-
- $form->display();
- }
- }
- ?>
|