Skip to content

Commit cda5003

Browse files
author
Juan Carlos Raña
committed
Merge
2 parents 40452bc + 87ec0cc commit cda5003

File tree

10 files changed

+126
-109
lines changed

10 files changed

+126
-109
lines changed

main/css/chamilo/default.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,15 +2106,12 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;}
21062106
border:1px solid #E1E1E0;
21072107
}
21082108
.small {
2109-
font-family: Verdana, Arial, Helvetica, sans-serif;
21102109
font-size: 11px
21112110
}
21122111
.xsmall {
2113-
font-family: Verdana, Arial, Helvetica, sans-serif;
2114-
font-size: 11px
2112+
font-size: 10px
21152113
}
21162114
.xxsmall {
2117-
font-family: Verdana, Arial, Helvetica, sans-serif;
21182115
font-size: 9px
21192116
}
21202117
#glossary_menu li {

main/exercice/admin.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,12 @@
257257
);
258258
}
259259

260-
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
261-
$interbreadcrumb[]=array("url" => "admin.php?exerciseId=".$objExercise->id,"name" => $objExercise->exercise);
260+
$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
261+
if (isset($_GET['newQuestion']) || isset($_GET['editQuestion']) ) {
262+
$interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB));
263+
} else {
264+
$interbreadcrumb[] = array("url" => "#", "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB));
265+
}
262266

263267
// shows a link to go back to the question pool
264268
if(!$exerciseId && $nameTools != get_lang('ExerciseManagement')){

main/exercice/exercice.php

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,20 @@
293293
$nameTools = get_lang('Exercices');
294294
} else {
295295
if ($is_allowedToEdit || $is_tutor) {
296-
$nameTools = get_lang('StudentScore');
297-
$interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
296+
$nameTools = get_lang('StudentScore');
297+
$interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
298+
$objExerciseTmp = new Exercise();
299+
if ($objExerciseTmp->read($exerciseId)) {
300+
$interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exerciseId, "name" => cut($objExerciseTmp->exercise, EXERCISE_MAX_NAME_BREADCRUMB));
301+
}
298302
} else {
299303
$nameTools = get_lang('YourScore');
300304
$interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
301305
}
302306
}
303307

304308
// need functions of statsutils lib to display previous exercices scores
305-
require_once (api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php');
309+
require_once api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php';
306310

307311
if ($is_allowedToEdit && !empty ($choice) && $choice == 'exportqti2') {
308312
require_once 'export/qti2/qti2_export.php';
@@ -347,7 +351,7 @@
347351
if (!$is_allowedToEdit and !$is_tutor) {
348352
$user_id = api_get_user_id();
349353
}
350-
require_once ('exercise_result.class.php');
354+
require_once 'exercise_result.class.php';
351355
switch ($_POST['export_format']) {
352356
case 'xls' :
353357
$export = new ExerciseResult();
@@ -388,7 +392,7 @@
388392
// only for administrator
389393

390394
if ($is_allowedToEdit) {
391-
if (!empty ($choice)) {
395+
if (!empty($choice)) {
392396
// construction of Exercise
393397

394398
$objExerciseTmp = new Exercise();
@@ -443,8 +447,8 @@
443447
Security::clear_token();
444448
}
445449

446-
if (!empty ($hpchoice)) {
447-
switch ($hpchoice) {
450+
if (!empty($hpchoice)) {
451+
switch($hpchoice) {
448452
case 'delete' : // deletes an exercise
449453
$imgparams = array ();
450454
$imgcount = 0;
@@ -712,15 +716,20 @@
712716
$i=1;
713717

714718
if ($is_allowedToEdit) {
715-
$headers = array(get_lang('ExerciseName'), get_lang('QuantityQuestions'), get_lang('Actions'));
719+
$headers = array(array('name' => get_lang('ExerciseName')),
720+
array('name' => get_lang('QuantityQuestions'), 'params' => array('width'=>'80px')),
721+
array('name' => get_lang('Actions'), 'params' => array('width'=>'180px')));
716722
} else {
717-
$headers = array(get_lang('ExerciseName'), get_lang('Status'), get_lang('Results'));
723+
$headers = array(array('name' => get_lang('ExerciseName')),
724+
array('name' => get_lang('Status')),
725+
array('name' => get_lang('Results')));
718726
}
727+
719728
$header_list = '';
720-
foreach($headers as $header) {
721-
$header_list .= Display::tag('th',$header);
729+
foreach($headers as $header) {
730+
$header_list .= Display::tag('th', $header['name'], $header['params']);
722731
}
723-
echo Display::tag('tr',$header_list);
732+
echo Display::tag('tr', $header_list);
724733

725734
$count = 0;
726735
if (!empty($exercise_list))
@@ -784,7 +793,7 @@
784793
}
785794

786795
//Showing exercise title
787-
$row['title']= text_filter($row['title']);
796+
$row['title'] = text_filter($row['title']);
788797
//echo Display::tag('h1',$row['title']);
789798

790799
if ($session_id == $row['session_id']) {
@@ -883,7 +892,13 @@
883892
//This query might be improved later on by ordering by the new "tms" field rather than by exe_id
884893
//Don't remove this marker: note-query-exe-results
885894
$qry = "SELECT * FROM $TBL_TRACK_EXERCICES
886-
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() . "'
895+
WHERE exe_exo_id = ".$row['id']." AND
896+
exe_user_id = ".api_get_user_id()." AND
897+
exe_cours_id = '".api_get_course_id()."' AND
898+
status <> 'incomplete' AND
899+
orig_lp_id = 0 AND
900+
orig_lp_item_id = 0 AND
901+
session_id = '" . api_get_session_id() . "'
887902
ORDER BY exe_id DESC";
888903
$qryres = Database::query($qry);
889904
$num = Database :: num_rows($qryres);
@@ -894,29 +909,23 @@
894909
//Time limits are on
895910
if ($time_limits) {
896911
// Examn is ready to be taken
897-
if ($is_actived_time) {
898-
if ($my_result_disabled == 0) {
912+
if ($is_actived_time) {
913+
//Show results
914+
if ($my_result_disabled == 0 || $my_result_disabled == 2) {
915+
//More than one attempt
899916
if ($num > 0) {
900917
$row_track = Database :: fetch_array($qryres);
901918
$attempt_text = get_lang('LatestAttempt') . ' : ';
902919
$attempt_text .= show_score($row_track['exe_result'], $row_track['exe_weighting']);
903920
} else {
904-
if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
905-
$attempt_text = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
906-
} else {
907-
if ($row['start_time'] != '0000-00-00 00:00:00') {
908-
$attempt_text = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($row['start_time']));
909-
}
910-
if ($row['end_time'] != '0000-00-00 00:00:00') {
911-
$attempt_text = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($row['end_time']));
912-
}
913-
}
921+
//No attempts
922+
$attempt_text = get_lang('NotAttempted');
914923
}
915924
} else {
916925
$attempt_text = get_lang('CantShowResults');
917926
}
918927
} else {
919-
//Quiz not ready
928+
//Quiz not ready due to time limits
920929
if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
921930
$attempt_text = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
922931
} else {
@@ -926,14 +935,13 @@
926935
}
927936
if ($row['end_time'] != '0000-00-00 00:00:00') {
928937
$attempt_text = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($row['end_time']));
929-
}
930-
938+
}
931939
}
932940
}
933941
} else {
934942
//Normal behaviour
935943
//Show results
936-
if ($my_result_disabled == 0) {
944+
if ($my_result_disabled == 0 || $my_result_disabled == 2) {
937945
if ($num > 0) {
938946
$row_track = Database :: fetch_array($qryres);
939947
$attempt_text = get_lang('LatestAttempt') . ' : ';
@@ -957,7 +965,7 @@
957965
}*/
958966

959967
if (empty($num)) {
960-
$num = '';
968+
$num = '';
961969
}
962970

963971
$item .= Display::tag('td', $attempt_text);

main/exercice/exercice_submit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@
444444
}
445445

446446
$interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
447-
$interbreadcrumb[] = array ("url" => "#","name" => $objExercise->selectTitle());
447+
$interbreadcrumb[] = array ("url" => "#","name" => cut($objExercise->selectTitle(), EXERCISE_MAX_NAME_BREADCRUMB));
448448

449449
if ($origin != 'learnpath') { //so we are not in learnpath tool
450450
//$htmlHeadXtra[] = $objExercise->show_lp_javascript();

main/exercice/exercise.class.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1);
1717
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2);
1818

19+
define('EXERCISE_MAX_NAME_BREADCRUMB', 60);
20+
1921
$debug = 0; //All exercise scripts should depend in this debug variable
2022

2123
require_once dirname(__FILE__).'/../inc/lib/exercise_show_functions.lib.php';
@@ -855,7 +857,7 @@ function createForm ($form, $type='full') {
855857
}
856858
$form->addElement('header', '', $form_title);
857859
// title
858-
$form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles" id="exercise_title"');
860+
$form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), ' size="60" id="exercise_title"');
859861
//$form->applyFilter('exerciseTitle','html_filter');
860862

861863
$form->addElement('html','<div class="row">
@@ -1821,7 +1823,7 @@ function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $e
18211823
$user_answer = '';
18221824

18231825
// Get answer list for matching
1824-
$sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" ';
1826+
$sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id = "'.$questionId.'" ';
18251827
$res_answer = Database::query($sql_answer);
18261828
$answer_matching =array();
18271829
while ($real_answer = Database::fetch_array($res_answer)) {
@@ -2057,9 +2059,7 @@ function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $e
20572059
$answer = '';
20582060
$j = 0;
20592061
//initialise answer tags
2060-
$user_tags = array ();
2061-
$correct_tags = array ();
2062-
$real_text = array ();
2062+
$user_tags = $correct_tags = $real_text = array ();
20632063
// the loop will stop at the end of the text
20642064
while (1) {
20652065
// quits the loop if there are no more blanks (detect '[')
@@ -2087,30 +2087,29 @@ function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $e
20872087
break;
20882088
}
20892089
if ($from_database) {
2090-
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($exeId)."' AND question_id= '".Database::escape_string($questionId)."'";
2090+
$queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".$exeId."' AND question_id= '".Database::escape_string($questionId)."'";
20912091
$resfill = Database::query($queryfill);
20922092
$str = Database::result($resfill,0,'answer');
20932093

20942094
preg_match_all('#\[([^[]*)\]#', $str, $arr);
20952095
$str = str_replace('\r\n', '', $str);
20962096
$choice = $arr[1];
20972097

2098-
$tmp=strrpos($choice[$j],' / ');
2099-
$choice[$j]=api_substr($choice[$j],0,$tmp);
2100-
$choice[$j]=trim($choice[$j]);
2098+
$tmp = api_strrpos($choice[$j],' / ');
2099+
$choice[$j] = api_substr($choice[$j],0,$tmp);
2100+
$choice[$j] = trim($choice[$j]);
21012101

21022102
//Needed to let characters ' and " to work as part of an answer
21032103
$choice[$j] = stripslashes($choice[$j]);
21042104
} else {
21052105
$choice[$j] = trim($choice[$j]);
21062106
}
21072107

2108-
$user_tags[] = api_strtolower($choice[$j]);
2108+
$user_tags[] = api_strtolower($choice[$j]);
21092109
//put the contents of the [] answer tag into correct_tags[]
2110-
$correct_tags[] = api_strtolower(api_substr($temp, 0, $pos));
2110+
$correct_tags[] = api_strtolower(api_substr($temp, 0, $pos));
21112111
$j++;
21122112
$temp = api_substr($temp, $pos +1);
2113-
//$answer .= ']';
21142113
}
21152114
$answer = '';
21162115
$real_correct_tags = $correct_tags;

main/exercice/exercise_admin.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ function setFocus(){
178178
if (!empty($gradebook) && $gradebook=='view') {
179179
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook'));
180180
}
181-
$nameTools=get_lang('ExerciseManagement');
182-
$interbreadcrumb[] = array ("url"=>'exercice.php', 'name'=> get_lang('Exercices'));
181+
$nameTools = get_lang('ExerciseManagement');
182+
$interbreadcrumb[] = array("url"=>'exercice.php', 'name'=> get_lang('Exercices'));
183+
$interbreadcrumb[] = array("url"=>"admin.php?exerciseId=".$objExercise->id, "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB));
184+
183185
Display::display_header($nameTools,get_lang('Exercise'));
184186

185187
echo '<div class="actions">';

main/exercice/question_pool.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@
7575
}
7676

7777
$nameTools = get_lang('QuestionPool');
78-
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
79-
$interbreadcrumb[]=array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->exercise);
80-
81-
78+
$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
79+
$interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => cut($objExercise->exercise, EXERCISE_MAX_NAME_BREADCRUMB));
80+
8281
if ($is_allowedToEdit) {
8382

8483
//Duplicating a Question

main/inc/lib/document.lib.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616
/* CONSTANTS */
1717

1818
define('DISK_QUOTA_FIELD', 'disk_quota'); //name of the database field
19-
/** default quota for the course documents folder */
20-
define('DEFAULT_DOCUMENT_QUOTA', api_get_setting('default_document_quotum'));
19+
20+
//Default quota for the course documents folder
21+
$default_quota = api_get_setting('default_document_quotum');
22+
//Just in case the setting is not correctly set
23+
if (empty($default_quota)) {
24+
$default_quota = 100000000;
25+
}
26+
define('DEFAULT_DOCUMENT_QUOTA', $default_quota);
2127

2228
class DocumentManager {
2329

@@ -30,22 +36,24 @@ private function __construct() {
3036
* @todo eliminate globals
3137
*/
3238
public static function get_course_quota() {
33-
global $_course;
34-
if (empty($_course['sysCode'])) { return DEFAULT_DOCUMENT_QUOTA; }
35-
$course_code = Database::escape_string($_course['sysCode']);
39+
$course_info = api_get_course_info();
40+
if (empty($course_info)) {
41+
return DEFAULT_DOCUMENT_QUOTA;
42+
}
43+
$course_code = Database::escape_string($course_info['code']);
3644
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
3745

3846
$sql_query = "SELECT ".DISK_QUOTA_FIELD." FROM $course_table WHERE code = '$course_code'";
3947
$sql_result = Database::query($sql_query);
40-
$course_quota = null;
48+
$course_quota = null;
4149
if (Database::num_rows($sql_result)) {
4250
$result = Database::fetch_array($sql_result);
4351
$course_quota = $result[DISK_QUOTA_FIELD];
4452
}
4553

46-
if (is_null($course_quota)) {
54+
if (is_null($course_quota) || empty($course_quota)) {
4755
// Course table entry for quota was null, then use default value
48-
$course_quota = DEFAULT_DOCUMENT_QUOTA;
56+
$course_quota = DEFAULT_DOCUMENT_QUOTA;
4957
}
5058
return $course_quota;
5159
}

0 commit comments

Comments
 (0)