From 8bc3854a02891dfa80c8a8a9fecb0ff72dcfaf45 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 25 Jan 2012 11:22:33 +0100 Subject: [PATCH] Cleaning style codes + fixing page style in question pool --- main/exercice/admin.php | 7 +- main/exercice/exercise_report.php | 3 - main/exercice/question_list_admin.inc.php | 147 +++++++++++----------- main/exercice/question_pool.php | 61 ++++----- 4 files changed, 99 insertions(+), 119 deletions(-) diff --git a/main/exercice/admin.php b/main/exercice/admin.php index 7a0bf48911..74c93a8306 100644 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -52,7 +52,7 @@ require_once 'question.class.php'; require_once 'answer.class.php'; // Name of the language file that needs to be included -$language_file='exercice'; +$language_file = 'exercice'; require_once '../inc/global.inc.php'; require_once 'exercise.lib.php'; @@ -489,8 +489,7 @@ else { // If we are in question_poolbut not in an test, go back to question create in pool echo '
'; echo ''.Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').''; - echo '
'; - + echo ''; } if (isset($_GET['message'])) { @@ -522,4 +521,4 @@ if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspot api_session_register('objExercise'); api_session_register('objQuestion'); api_session_register('objAnswer'); -Display::display_footer(); +Display::display_footer(); \ No newline at end of file diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index 023d1af5b7..304621a1aa 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -336,9 +336,6 @@ $tpl->assign('content', $content); $tpl->display_one_col_template(); */ - - - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results&exerciseId='.$exercise_id; //$activeurl = '?sidx=session_active'; diff --git a/main/exercice/question_list_admin.inc.php b/main/exercice/question_list_admin.inc.php index 8fd5068c32..bc31e7f6e2 100644 --- a/main/exercice/question_list_admin.inc.php +++ b/main/exercice/question_list_admin.inc.php @@ -146,36 +146,35 @@ unset($_SESSION['less_answer']); $inATest = isset($exerciseId) && $exerciseId > 0; if (!$inATest) { echo "

".get_lang("ChoiceQuestionType")."

"; -} -else { - echo '
'; +} else { + echo '
'; if ($nbrQuestions) { - $my_exercise = new Exercise(); - //forces the query to the database - $my_exercise->read($_GET['exerciseId']); - $questionList=$my_exercise->selectQuestionList(); - // ----------------------- - // Style for columns - // ----------------------- - $styleQuestion = "width:50%; float:left;"; - $styleType = "width:4%; float:left; padding-top:4px; text-align:center;"; - $styleCat = "width:22%; float:left; padding-top:8px; text-align:center;"; - $styleLevel = "width:6%; float:left; padding-top:8px; text-align:center;"; - $styleScore = "width:4%; float:left; padding-top:8px; text-align:center;"; - $styleAction = "width:10%; float:left; padding-top:8px;"; - // ------------- - // Title line - // ------------- - echo "
"; - echo "
 ".get_lang('Questions')."
"; - echo "
".get_lang('Type')."
"; - echo "
".get_lang('Category')."
"; - echo "
".get_lang('Difficulty')."
"; - echo "
".get_lang('Score')."
"; - echo "
"; - echo "
 
"; - // ------------- - if (is_array($questionList)) { + $my_exercise = new Exercise(); + //forces the query to the database + $my_exercise->read($_GET['exerciseId']); + $questionList=$my_exercise->selectQuestionList(); + + // Style for columns + + $styleQuestion = "width:50%; float:left;"; + $styleType = "width:4%; float:left; padding-top:4px; text-align:center;"; + $styleCat = "width:22%; float:left; padding-top:8px; text-align:center;"; + $styleLevel = "width:6%; float:left; padding-top:8px; text-align:center;"; + $styleScore = "width:4%; float:left; padding-top:8px; text-align:center;"; + $styleAction = "width:10%; float:left; padding-top:8px;"; + + // Title line + + echo "
"; + echo "
 ".get_lang('Questions')."
"; + echo "
".get_lang('Type')."
"; + echo "
".get_lang('Category')."
"; + echo "
".get_lang('Difficulty')."
"; + echo "
".get_lang('Score')."
"; + echo "
"; + echo "
 
"; + + if (is_array($questionList)) { foreach($questionList as $id) { //To avoid warning messages if (!is_numeric($id)) { @@ -195,67 +194,65 @@ else { $delete_link = Display::tag('div',$delete_link, array('style'=>'float:left; padding:0px; margin:0px')); $actions = Display::tag('div',$edit_link.$clone_link.$delete_link, array('class'=>'edition','style'=>'width:100px; right:10px; margin-top: 0px; position: absolute; top: 10%;')); - $title = Security::remove_XSS($objQuestionTmp->selectTitle()); - $move = Display::return_icon('move.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;')); - // --------------------- - // Question name - // --------------------- + $title = Security::remove_XSS($objQuestionTmp->selectTitle()); + $move = Display::return_icon('move.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;')); + + // Question name + $questionName = Display::tag('div', ''.$move.' '.cut($title, 60).'', array('style'=>$styleQuestion)); - // --------------------- + // Question type - // --------------------- + $tabQuestionList = Question::get_types_information(); list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html(); $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), 32), array('style'=>$styleType)); - // --------------------- + // Question category - // --------------------- + $txtQuestionCat = Security::remove_XSS(Testcategory::getCategoryNameForQuestion($objQuestionTmp->id)); if (empty($txtQuestionCat)) { $txtQuestionCat = "-"; } $questionCategory = Display::tag('div', ''.cut($txtQuestionCat, 55).'', array('style'=>$styleCat)); - // --------------------- + // Question level - // --------------------- + $txtQuestionLevel = $objQuestionTmp->level; - if (empty($objQuestionTmp->level)) { - $txtQuestionLevel = '-'; - } - $questionLevel = Display::tag('div', $txtQuestionLevel, array('style'=>$styleLevel)); - // --------------------- - // Question score - // --------------------- - $questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style'=>$styleScore)); - // --------------------- - echo '
'; - echo '
'; - echo $questionName; - echo $questionType; - echo $questionCategory; - echo $questionLevel; - echo $questionScore; - echo $actions; - echo '
'; - echo '
'; - echo '

'; - //echo get_lang($question_class.$label); - echo get_lang($question_class); - echo '
'; - //echo get_lang('Level').': '.$objQuestionTmp->selectLevel(); - echo '
'; - showQuestion($id, false, '', '',false, true); - echo '

'; - echo '
'; - echo '
'; - unset($objQuestionTmp); - } - echo '
'; + if (empty($objQuestionTmp->level)) { + $txtQuestionLevel = '-'; + } + $questionLevel = Display::tag('div', $txtQuestionLevel, array('style'=>$styleLevel)); + + // Question score + + $questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style'=>$styleScore)); + + echo '
'; + echo '
'; + echo $questionName; + echo $questionType; + echo $questionCategory; + echo $questionLevel; + echo $questionScore; + echo $actions; + echo '
'; + echo '
'; + echo '

'; + //echo get_lang($question_class.$label); + echo get_lang($question_class); + echo '
'; + //echo get_lang('Level').': '.$objQuestionTmp->selectLevel(); + echo '
'; + showQuestion($id, false, '', '',false, true); + echo '

'; + echo '
'; + echo '
'; + unset($objQuestionTmp); + } } } if(!$nbrQuestions) { echo Display::display_warning_message(get_lang('NoQuestion')); - } - - echo '
'; + } + echo ''; //question list div } \ No newline at end of file diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index 552672e2dc..408c9891fa 100644 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -1,6 +1,4 @@ updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy')); - //Duplicating the source question, in the current course + //Duplicating the source question, in the current course $new_id = $old_question_obj->duplicate($current_course); - //Reading new question + //Reading new question $new_question_obj = Question::read($new_id); $new_question_obj->addToList($fromExercise); - //Reading Answers obj of the current course + //Reading Answers obj of the current course $new_answer_obj = new Answer($old_question_id, $origin_course_id); $new_answer_obj->read(); - //Duplicating the Answers in the current course + //Duplicating the Answers in the current course $new_answer_obj->duplicate($new_id, $current_course); // destruction of the Question object unset($new_question_obj); unset($old_question_obj); - if (!$objExcercise instanceOf Exercise) { - $objExercise = new Exercise(); - $objExercise->read($fromExercise); - } + if (!$objExcercise instanceOf Exercise) { + $objExercise = new Exercise(); + $objExercise->read($fromExercise); + } api_session_register('objExercise'); } $displayMessage = get_lang('ItemAdded'); @@ -124,15 +122,13 @@ if ($is_allowedToEdit) { if ($delete) { // construction of the Question object // if the question exists - if($objQuestionTmp = Question::read($delete)) - { + if($objQuestionTmp = Question::read($delete)) { // deletes the question from all exercises $objQuestionTmp->delete(); } // destruction of the Question object unset($objQuestionTmp); - } - elseif($recup && $fromExercise) { + } elseif($recup && $fromExercise) { // gets an existing question and copies it into a new exercise $objQuestionTmp = Question :: read($recup); // if the question exists @@ -287,9 +283,7 @@ if (isset($type)) { } echo ''; -// ---------------------------------------------------- // Session list, if sessions are used. -// ---------------------------------------------------- $session_list = SessionManager::get_sessions_by_coach(api_get_user_id()); $tabAttrParam = array('class'=>'chzn-select', 'onchange'=>'submit_form(this)'); // when sessions are used $labelFormRow = get_lang('Session'); @@ -304,9 +298,7 @@ foreach($session_list as $item) { $select_session_html = Display::select('session_id', $session_select_list, $session_id, $tabAttrParam); echo Display::form_row($labelFormRow, $select_session_html); // hub 13-10-2011 -// ----------------------------------------------------------------------------- // Course list, get course list of session, or for course where user is admin -// ----------------------------------------------------------------------------- if (!empty($session_id) && $session_id != '-1') { $course_list = SessionManager::get_course_list_by_session_id($session_id); } else { @@ -323,7 +315,7 @@ foreach ($course_list as $item) { $select_course_html = Display::select('selected_course', $course_select_list, $selected_course, array('class'=>'chzn-select','onchange'=>'mark_course_id_changed(); submit_form(this);')); echo Display::form_row(get_lang('Course'), $select_course_html); -$db_name = ""; + if (empty($selected_course) || $selected_course == '-1') { $course_info = api_get_course_info(); reset_menu_exo_lvl_type(); // no course selected, reset menu test / difficult� / type de reponse // hub 13-10-2011 @@ -374,15 +366,14 @@ if ($exercice_id_changed == 1) { $select_exercise_html = Display::select('exerciseId', $my_exercise_list, $exerciseId, array('class'=>'chzn-select','onchange'=>'mark_exercice_id_changed(); submit_form(this);'), false); echo Display::form_row(get_lang('Exercise'), $select_exercise_html); -// // Difficulty list (only from 0 to 5) -// + $select_difficulty_html = Display::select('exerciseLevel', array(-1 => get_lang('All'), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5), $exerciseLevel, array('class'=>'chzn-select', 'onchange'=>'submit_form(this);'), false); echo Display::form_row(get_lang('Difficulty'), $select_difficulty_html); -// + // Answer type -// + $question_list = Question::get_types_information(); $new_question_list = array(); $new_question_list['-1'] = get_lang('All'); @@ -416,9 +407,9 @@ echo "'; -// + // if we have selected an exercise in the list-box 'Filter' -// + if ($exerciseId > 0) { $where = ''; $from = ''; @@ -565,7 +556,7 @@ else { } $nbrQuestions = count($main_question_list); -// + // build the line of the array to display questions // Actions are different if you launch the question_pool page // They are different too if you have displayed questions from your course @@ -654,9 +645,7 @@ Display::display_footer(); -// ========================================================================= // Some functions here, just for question_pool to ease the code -// ========================================================================= /* Put the menu entry for level and type to default "Choice" @@ -771,7 +760,6 @@ function get_action_icon_for_question($in_action, $from_exercice, $in_questionid return $res; } -// // return the icon for the question type // hubert.borderiou 13-10-2011 function get_question_type_for_question($in_selectedcourse, $in_questionid) { @@ -782,7 +770,6 @@ function get_question_type_for_question($in_selectedcourse, $in_questionid) { return $questionType; } -// // return the name of the category for the question in a course // hubert.borderiou 13-10-2011 function get_question_categorie_for_question($in_courseid, $in_questionid) {