From c9ad4c79d97f4a002c00d658a9db067381d1ab51 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 1 Jun 2011 11:38:00 +0200 Subject: [PATCH 1/8] Minor cleaning file exercise.class.php --- main/exercice/exercise.class.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 612eb97e5d..8c993d4ae5 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1821,7 +1821,7 @@ class Exercise { $user_answer = ''; // Get answer list for matching - $sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" '; + $sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id = "'.$questionId.'" '; $res_answer = Database::query($sql_answer); $answer_matching =array(); while ($real_answer = Database::fetch_array($res_answer)) { @@ -2057,9 +2057,7 @@ class Exercise { $answer = ''; $j = 0; //initialise answer tags - $user_tags = array (); - $correct_tags = array (); - $real_text = array (); + $user_tags = $correct_tags = $real_text = array (); // the loop will stop at the end of the text while (1) { // quits the loop if there are no more blanks (detect '[') @@ -2087,7 +2085,7 @@ class Exercise { break; } if ($from_database) { - $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($exeId)."' AND question_id= '".Database::escape_string($questionId)."'"; + $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".$exeId."' AND question_id= '".Database::escape_string($questionId)."'"; $resfill = Database::query($queryfill); $str = Database::result($resfill,0,'answer'); @@ -2095,9 +2093,9 @@ class Exercise { $str = str_replace('\r\n', '', $str); $choice = $arr[1]; - $tmp=strrpos($choice[$j],' / '); - $choice[$j]=api_substr($choice[$j],0,$tmp); - $choice[$j]=trim($choice[$j]); + $tmp = strrpos($choice[$j],' / '); + $choice[$j] = api_substr($choice[$j],0,$tmp); + $choice[$j] = trim($choice[$j]); //Needed to let characters ' and " to work as part of an answer $choice[$j] = stripslashes($choice[$j]); @@ -2105,12 +2103,11 @@ class Exercise { $choice[$j] = trim($choice[$j]); } - $user_tags[] = api_strtolower($choice[$j]); + $user_tags[] = api_strtolower($choice[$j]); //put the contents of the [] answer tag into correct_tags[] - $correct_tags[] = api_strtolower(api_substr($temp, 0, $pos)); + $correct_tags[] = api_strtolower(api_substr($temp, 0, $pos)); $j++; $temp = api_substr($temp, $pos +1); - //$answer .= ']'; } $answer = ''; $real_correct_tags = $correct_tags; From b351828b5b8bfd1b048349c53f00e91002b9955d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 1 Jun 2011 11:39:03 +0200 Subject: [PATCH 2/8] =?UTF-8?q?Exercise:=20Fixing=20bug=20"pr=C3=A9cis?= =?UTF-8?q?=C3=A9ment"=20when=20using=20Fill=20in=20blank=20questions=20se?= =?UTF-8?q?e=20#3534?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/exercice/exercise.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 8c993d4ae5..7f31619983 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -2093,7 +2093,7 @@ class Exercise { $str = str_replace('\r\n', '', $str); $choice = $arr[1]; - $tmp = strrpos($choice[$j],' / '); + $tmp = api_strrpos($choice[$j],' / '); $choice[$j] = api_substr($choice[$j],0,$tmp); $choice[$j] = trim($choice[$j]); From 3603d541aea52b4e04b165d047e00fd08e45ed6a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 1 Jun 2011 12:25:10 +0200 Subject: [PATCH 3/8] Trying to fix bug when adding an element to a LP (jquery tabs). Removing double document.ready see #3352 #3533 --- main/newscorm/lp_add_item.php | 45 ++++++++++++++++------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/main/newscorm/lp_add_item.php b/main/newscorm/lp_add_item.php index 1b92b538ad..78e58e6cf6 100755 --- a/main/newscorm/lp_add_item.php +++ b/main/newscorm/lp_add_item.php @@ -85,8 +85,7 @@ function check_for_title() { // Compose title if there is none contentTextArray = contentText.split(\' \') ; var x=0; - for(x=0; (x<5 && xget_js_dropdown_array() . //'if( typeof cbo != "undefined" ) {'."\n" . 'cbo.options[k].selected = true;'."\n" . //'}'."\n" . -'}'."\n" . -'$().ready(function() {'."\n" . - 'if ($(\'#previous\')) {'."\n" . - 'if(\'parent is\'+$(\'#idParent\').val()) {'. - 'load_cbo($(\'#idParent\').val());'."\n" . - '}}'."\n" . -'});'."\n" . -''; +'} + +$(function() { + + if ($(\'#previous\')) { + if(\'parent is\'+$(\'#idParent\').val()) { + load_cbo($(\'#idParent\').val()); + } + } + //Loads LP item tabs + + $("#resource_tab").tabs(); + $(\'.lp_resource_element\').click(function() { + window.location.href = $(\'a\', this).attr(\'href\'); + }); +}); +'; $htmlHeadXtra[] = api_get_jquery_ui_js(); //jQuery @@ -221,17 +227,15 @@ Display::display_header(null, 'Path'); //api_display_tool_title($therow['name']); $suredel = trim(get_lang('AreYouSureToDelete')); -//$suredelstep = trim(get_lang('AreYouSureToDeleteSteps')); +//@todo move this somewhere else css/fix.css ?> - - - + Date: Wed, 1 Jun 2011 14:19:58 +0200 Subject: [PATCH 4/8] Exerciese: Fixing bug when using "show only score" test with time limits --- main/exercice/exercice.php | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index da8d8fb827..7cd281eaab 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -883,7 +883,13 @@ if ($show == 'test') { //This query might be improved later on by ordering by the new "tms" field rather than by exe_id //Don't remove this marker: note-query-exe-results $qry = "SELECT * FROM $TBL_TRACK_EXERCICES - WHERE exe_exo_id = ".$row['id']." AND exe_user_id = " . api_get_user_id() . " AND exe_cours_id = '" . api_get_course_id() . "' AND status <>'incomplete' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '" . api_get_session_id() . "' + WHERE exe_exo_id = ".$row['id']." AND + exe_user_id = ".api_get_user_id()." AND + exe_cours_id = '".api_get_course_id()."' AND + status <> 'incomplete' AND + orig_lp_id = 0 AND + orig_lp_item_id = 0 AND + session_id = '" . api_get_session_id() . "' ORDER BY exe_id DESC"; $qryres = Database::query($qry); $num = Database :: num_rows($qryres); @@ -894,29 +900,23 @@ if ($show == 'test') { //Time limits are on if ($time_limits) { // Examn is ready to be taken - if ($is_actived_time) { - if ($my_result_disabled == 0) { + if ($is_actived_time) { + //Show results + if ($my_result_disabled == 0 || $my_result_disabled == 2) { + //More than one attempt if ($num > 0) { $row_track = Database :: fetch_array($qryres); $attempt_text = get_lang('LatestAttempt') . ' : '; $attempt_text .= show_score($row_track['exe_result'], $row_track['exe_weighting']); } else { - if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') { - $attempt_text = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time'])); - } else { - if ($row['start_time'] != '0000-00-00 00:00:00') { - $attempt_text = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($row['start_time'])); - } - if ($row['end_time'] != '0000-00-00 00:00:00') { - $attempt_text = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($row['end_time'])); - } - } + //No attempts + $attempt_text = get_lang('NotAttempted'); } } else { $attempt_text = get_lang('CantShowResults'); } } else { - //Quiz not ready + //Quiz not ready due to time limits if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') { $attempt_text = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time'])); } else { @@ -926,14 +926,13 @@ if ($show == 'test') { } if ($row['end_time'] != '0000-00-00 00:00:00') { $attempt_text = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($row['end_time'])); - } - + } } } } else { //Normal behaviour //Show results - if ($my_result_disabled == 0) { + if ($my_result_disabled == 0 || $my_result_disabled == 2) { if ($num > 0) { $row_track = Database :: fetch_array($qryres); $attempt_text = get_lang('LatestAttempt') . ' : '; @@ -957,7 +956,7 @@ if ($show == 'test') { }*/ if (empty($num)) { - $num = ''; + $num = ''; } $item .= Display::tag('td', $attempt_text); From d59f5f61c8e37ed2b363b1a92f8d29da5a5cf3a7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 1 Jun 2011 15:34:38 +0200 Subject: [PATCH 5/8] Fixing exercise breadcrumbs --- main/exercice/admin.php | 8 ++++++-- main/exercice/exercice.php | 21 ++++++++++++++------- main/exercice/exercice_submit.php | 2 +- main/exercice/exercise.class.php | 4 +++- main/exercice/exercise_admin.php | 6 ++++-- main/exercice/question_pool.php | 7 +++---- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/main/exercice/admin.php b/main/exercice/admin.php index 4077231949..debbddf8d7 100755 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -257,8 +257,12 @@ if (!empty($gradebook) && $gradebook=='view') { ); } -$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); -$interbreadcrumb[]=array("url" => "admin.php?exerciseId=".$objExercise->id,"name" => $objExercise->exercise); +$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices')); +if (isset($_GET['newQuestion']) || isset($_GET['editQuestion']) ) { + $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB)); +} else { + $interbreadcrumb[] = array("url" => "#", "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB)); +} // shows a link to go back to the question pool if(!$exerciseId && $nameTools != get_lang('ExerciseManagement')){ diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 7cd281eaab..2c1bf7b352 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -294,7 +294,14 @@ if ($show != 'result') { } else { if ($is_allowedToEdit || $is_tutor) { $nameTools = get_lang('StudentScore'); - $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); + + $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); + $objExerciseTmp = new Exercise(); + if ($objExerciseTmp->read($exerciseId)) { + $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exerciseId, "name" => cut($objExerciseTmp->exercise, EXERCISE_MAX_NAME_BREADCRUMB)); + } + + } else { $nameTools = get_lang('YourScore'); $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); @@ -302,7 +309,7 @@ if ($show != 'result') { } // need functions of statsutils lib to display previous exercices scores -require_once (api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php'); +require_once api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php'; if ($is_allowedToEdit && !empty ($choice) && $choice == 'exportqti2') { require_once 'export/qti2/qti2_export.php'; @@ -347,7 +354,7 @@ if (!empty ($_POST['export_report']) && $_POST['export_report'] == 'export_repor if (!$is_allowedToEdit and !$is_tutor) { $user_id = api_get_user_id(); } - require_once ('exercise_result.class.php'); + require_once 'exercise_result.class.php'; switch ($_POST['export_format']) { case 'xls' : $export = new ExerciseResult(); @@ -388,7 +395,7 @@ HotPotGCt($documentPath, 1, api_get_user_id() ); // only for administrator if ($is_allowedToEdit) { - if (!empty ($choice)) { + if (!empty($choice)) { // construction of Exercise $objExerciseTmp = new Exercise(); @@ -443,8 +450,8 @@ if ($is_allowedToEdit) { Security::clear_token(); } - if (!empty ($hpchoice)) { - switch ($hpchoice) { + if (!empty($hpchoice)) { + switch($hpchoice) { case 'delete' : // deletes an exercise $imgparams = array (); $imgcount = 0; @@ -784,7 +791,7 @@ if ($show == 'test') { } //Showing exercise title - $row['title']= text_filter($row['title']); + $row['title'] = text_filter($row['title']); //echo Display::tag('h1',$row['title']); if ($session_id == $row['session_id']) { diff --git a/main/exercice/exercice_submit.php b/main/exercice/exercice_submit.php index fc11f2da02..afe897fba3 100755 --- a/main/exercice/exercice_submit.php +++ b/main/exercice/exercice_submit.php @@ -444,7 +444,7 @@ if (!empty ($gradebook) && $gradebook == 'view') { } $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices')); -$interbreadcrumb[] = array ("url" => "#","name" => $objExercise->selectTitle()); +$interbreadcrumb[] = array ("url" => "#","name" => cut($objExercise->selectTitle(), EXERCISE_MAX_NAME_BREADCRUMB)); if ($origin != 'learnpath') { //so we are not in learnpath tool //$htmlHeadXtra[] = $objExercise->show_lp_javascript(); diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 7f31619983..9450a56ef9 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -16,6 +16,8 @@ define('EXERCISE_FEEDBACK_TYPE_END', 0); define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1); define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); +define('EXERCISE_MAX_NAME_BREADCRUMB', 60); + $debug = 0; //All exercise scripts should depend in this debug variable require_once dirname(__FILE__).'/../inc/lib/exercise_show_functions.lib.php'; @@ -855,7 +857,7 @@ class Exercise { } $form->addElement('header', '', $form_title); // title - $form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles" id="exercise_title"'); + $form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), ' size="60" id="exercise_title"'); //$form->applyFilter('exerciseTitle','html_filter'); $form->addElement('html','
diff --git a/main/exercice/exercise_admin.php b/main/exercice/exercise_admin.php index 6035771215..72842b46e8 100755 --- a/main/exercice/exercise_admin.php +++ b/main/exercice/exercise_admin.php @@ -178,8 +178,10 @@ if ($form->validate()) { if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); } - $nameTools=get_lang('ExerciseManagement'); - $interbreadcrumb[] = array ("url"=>'exercice.php', 'name'=> get_lang('Exercices')); + $nameTools = get_lang('ExerciseManagement'); + $interbreadcrumb[] = array("url"=>'exercice.php', 'name'=> get_lang('Exercices')); + $interbreadcrumb[] = array("url"=>"admin.php?exerciseId=".$objExercise->id, "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB)); + Display::display_header($nameTools,get_lang('Exercise')); echo '
'; diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index 6ece66bc7b..201d10fb7d 100755 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -75,10 +75,9 @@ if(!($objExcercise instanceOf Exercise) && !empty($fromExercise)) { } $nameTools = get_lang('QuestionPool'); -$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); -$interbreadcrumb[]=array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->exercise); - - +$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices')); +$interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB)); + if ($is_allowedToEdit) { //Duplicating a Question From 0c9acfc6ef2c3669e8d6cc08f952c9e3b8c32003 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 1 Jun 2011 17:31:30 +0200 Subject: [PATCH 6/8] Fixing LP table --- main/css/chamilo/default.css | 5 +--- main/newscorm/lp_list.php | 45 +++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/main/css/chamilo/default.css b/main/css/chamilo/default.css index fdab477f97..cca4c5abbb 100755 --- a/main/css/chamilo/default.css +++ b/main/css/chamilo/default.css @@ -2106,15 +2106,12 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;} border:1px solid #E1E1E0; } .small { - font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px } .xsmall { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 11px + font-size: 10px } .xxsmall { - font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px } #glossary_menu li { diff --git a/main/newscorm/lp_list.php b/main/newscorm/lp_list.php index cdfa6a9f6b..7890b74f75 100755 --- a/main/newscorm/lp_list.php +++ b/main/newscorm/lp_list.php @@ -125,17 +125,17 @@ if (!empty($curDirPath)) { /* CURRENT DIRECTORY */ -echo ''; -echo ''.get_lang('Title').''; - -if ($is_allowed_to_edit) { - echo ''.get_lang('PublicationDate').''; - echo ''.get_lang('ExpirationDate').''; -} -echo ''.get_lang('Progress').""; - +echo ''; + if ($is_allowed_to_edit) { - echo ''.get_lang('AuthoringOptions').""; + echo ''.get_lang('Title').''; + echo ''.get_lang('PublicationDate').''; + echo ''.get_lang('ExpirationDate').''; + echo ''.get_lang('Progress').""; + echo ''.get_lang('AuthoringOptions').""; +} else { + echo ''.get_lang('Title').''; + echo ''.get_lang('Progress').""; } echo ''; @@ -203,8 +203,7 @@ if (is_array($flat_list)) { if (!empty($details['expired_on'])) { $end_time = api_convert_and_format_date($details['expired_on'], DATE_TIME_FORMAT_LONG); } - } - + } $counter++; if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } @@ -254,8 +253,12 @@ if (is_array($flat_list)) { $lp_theme_css = $mystyle; - if ($display_progress_bar) { - $dsp_progress = '
'.learnpath::get_progress_bar('%',learnpath::get_db_progress($id, api_get_user_id(), '%', '', false, api_get_session_id())).'
'; + if ($display_progress_bar) { + if ($is_allowed_to_edit) { + $dsp_progress = ''.learnpath::get_db_progress($id, api_get_user_id(), '%', '', false, api_get_session_id()).''; + } else { + $dsp_progress = '
'.learnpath::get_progress_bar('%',learnpath::get_db_progress($id, api_get_user_id(), '%', '', false, api_get_session_id())).'
'; + } } else { $dsp_progress = '
'.learnpath::get_db_progress($id, api_get_user_id(), 'both','',false, api_get_session_id()).'
'; } @@ -324,11 +327,11 @@ if (is_array($flat_list)) { // Session test not necessary if we want to show base course learning paths inside the session (see http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions). //if ($current_session == $details['lp_session']) { - if ($details['lp_visibility'] == 0) { - $dsp_visible = "".Display::return_icon('invisible.png', get_lang('Show'),'','22').""; - } else { - $dsp_visible = "" .Display::return_icon('visible.png', get_lang('Hide'),'','22').""; - } + if ($details['lp_visibility'] == 0) { + $dsp_visible = "".Display::return_icon('invisible.png', get_lang('Show'),'','22').""; + } else { + $dsp_visible = "" .Display::return_icon('visible.png', get_lang('Hide'),'','22').""; + } //} else { // $dsp_visible = ''; //} @@ -483,8 +486,8 @@ if (is_array($flat_list)) { } } if ($is_allowed_to_edit) { - $start_time = Display::tag('td', $start_time); - $end_time = Display::tag('td', $end_time); + $start_time = Display::tag('td', Display::div($start_time, array('class'=>'small'))); + $end_time = Display::tag('td', Display::div($end_time, array('class'=>'small'))); } else { $start_time = $end_time= ''; } From 94ddc4e725986bf5347bc6aab5fb648853072dd6 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 1 Jun 2011 18:07:19 +0200 Subject: [PATCH 7/8] Fixing exercise list widths --- main/exercice/exercice.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 2c1bf7b352..b41ee5eb7c 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -293,15 +293,12 @@ if ($show != 'result') { $nameTools = get_lang('Exercices'); } else { if ($is_allowedToEdit || $is_tutor) { - $nameTools = get_lang('StudentScore'); - + $nameTools = get_lang('StudentScore'); $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); $objExerciseTmp = new Exercise(); if ($objExerciseTmp->read($exerciseId)) { $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exerciseId, "name" => cut($objExerciseTmp->exercise, EXERCISE_MAX_NAME_BREADCRUMB)); } - - } else { $nameTools = get_lang('YourScore'); $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); @@ -719,15 +716,20 @@ if ($show == 'test') { $i=1; if ($is_allowedToEdit) { - $headers = array(get_lang('ExerciseName'), get_lang('QuantityQuestions'), get_lang('Actions')); + $headers = array(array('name' => get_lang('ExerciseName')), + array('name' => get_lang('QuantityQuestions'), 'params' => array('width'=>'80px')), + array('name' => get_lang('Actions'), 'params' => array('width'=>'180px'))); } else { - $headers = array(get_lang('ExerciseName'), get_lang('Status'), get_lang('Results')); + $headers = array(array('name' => get_lang('ExerciseName')), + array('name' => get_lang('Status')), + array('name' => get_lang('Results'))); } + $header_list = ''; - foreach($headers as $header) { - $header_list .= Display::tag('th',$header); + foreach($headers as $header) { + $header_list .= Display::tag('th', $header['name'], $header['params']); } - echo Display::tag('tr',$header_list); + echo Display::tag('tr', $header_list); $count = 0; if (!empty($exercise_list)) From 87ec0cc8121cd0888498589b58781661f18fe987 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 1 Jun 2011 18:28:59 +0200 Subject: [PATCH 8/8] Cleaning code when calling the document quota see #3535 --- main/inc/lib/document.lib.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 0eb2a7e0cb..13b9cd706a 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -16,8 +16,14 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; /* CONSTANTS */ define('DISK_QUOTA_FIELD', 'disk_quota'); //name of the database field -/** default quota for the course documents folder */ -define('DEFAULT_DOCUMENT_QUOTA', api_get_setting('default_document_quotum')); + +//Default quota for the course documents folder +$default_quota = api_get_setting('default_document_quotum'); +//Just in case the setting is not correctly set +if (empty($default_quota)) { + $default_quota = 100000000; +} +define('DEFAULT_DOCUMENT_QUOTA', $default_quota); class DocumentManager { @@ -30,22 +36,24 @@ class DocumentManager { * @todo eliminate globals */ public static function get_course_quota() { - global $_course; - if (empty($_course['sysCode'])) { return DEFAULT_DOCUMENT_QUOTA; } - $course_code = Database::escape_string($_course['sysCode']); + $course_info = api_get_course_info(); + if (empty($course_info)) { + return DEFAULT_DOCUMENT_QUOTA; + } + $course_code = Database::escape_string($course_info['code']); $course_table = Database::get_main_table(TABLE_MAIN_COURSE); $sql_query = "SELECT ".DISK_QUOTA_FIELD." FROM $course_table WHERE code = '$course_code'"; $sql_result = Database::query($sql_query); - $course_quota = null; + $course_quota = null; if (Database::num_rows($sql_result)) { $result = Database::fetch_array($sql_result); $course_quota = $result[DISK_QUOTA_FIELD]; } - if (is_null($course_quota)) { + if (is_null($course_quota) || empty($course_quota)) { // Course table entry for quota was null, then use default value - $course_quota = DEFAULT_DOCUMENT_QUOTA; + $course_quota = DEFAULT_DOCUMENT_QUOTA; } return $course_quota; }