Skip to content

Commit 3d62bc8

Browse files
committed
Format code
1 parent 0df4479 commit 3d62bc8

File tree

6 files changed

+62
-56
lines changed

6 files changed

+62
-56
lines changed

main/exercice/addlimits.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959

6060
if (!empty($gradebook) && $gradebook=='view') {
6161
$interbreadcrumb[]= array (
62-
'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
63-
'name' => get_lang('ToolGradebook')
64-
);
62+
'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
63+
'name' => get_lang('ToolGradebook')
64+
);
6565
}
6666
$nameTools=get_lang('Exercises');
6767
$interbreadcrumb[] = array(

main/exercice/adminhp.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,28 @@
44
* HotPotatoes administration.
55
* @package chamilo.exercise
66
* @author Istvan Mandak
7-
* @version $Id: adminhp.php 20089 2009-04-24 21:12:54Z cvargas1 $
87
*/
8+
99
require_once '../inc/global.inc.php';
1010

11-
$this_section=SECTION_COURSES;
11+
$this_section = SECTION_COURSES;
12+
13+
$_course = api_get_course_info();
1214

1315
if (isset($_REQUEST["cancel"])) {
14-
if ($_REQUEST["cancel"]==get_lang('Cancel')) {
16+
if ($_REQUEST["cancel"] == get_lang('Cancel')) {
1517
header("Location: exercise.php");
18+
exit;
1619
}
1720
}
1821

19-
//$is_courseAdmin = $_SESSION['is_courseAdmin'];
20-
$newName = (!empty($_REQUEST['newName'])?$_REQUEST['newName']:'');
21-
$hotpotatoesName = (!empty($_REQUEST['hotpotatoesName'])?$_REQUEST['hotpotatoesName']:'');
22+
$newName = !empty($_REQUEST['newName']) ? $_REQUEST['newName'] : '';
23+
$hotpotatoesName = !empty($_REQUEST['hotpotatoesName']) ? $_REQUEST['hotpotatoesName'] : '';
2224

2325
$is_allowedToEdit=api_is_allowed_to_edit(null,true);
2426

2527
// document path
26-
$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
28+
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
2729

2830
// picture path
2931
$picturePath=$documentPath.'/images';
@@ -40,33 +42,31 @@
4042
$gradebook= $_SESSION['gradebook'];
4143
}
4244

43-
if (!empty($gradebook) && $gradebook=='view') {
44-
$interbreadcrumb[]= array (
45+
if (!empty($gradebook) && $gradebook == 'view') {
46+
$interbreadcrumb[] = array(
4547
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
46-
'name' => get_lang('ToolGradebook')
48+
'name' => get_lang('ToolGradebook'),
4749
);
4850
}
4951

50-
$interbreadcrumb[]=array("url" => "exercise.php","name" => get_lang('Exercises'));
51-
52+
$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises'));
5253
$nameTools = get_lang('adminHP');
5354

5455
Display::display_header($nameTools,"Exercise");
5556

5657
/** @todo probably wrong !!!! */
57-
require_once(api_get_path(SYS_CODE_PATH).'/exercice/hotpotatoes.lib.php');
58+
require_once api_get_path(SYS_CODE_PATH).'/exercice/hotpotatoes.lib.php';
5859

5960
?>
60-
6161
<h4>
62-
<?php echo $nameTools; ?>
62+
<?php echo $nameTools; ?>
6363
</h4>
6464

6565
<?php
6666
if (isset($newName)) {
6767
if ($newName!="") {
6868
//alter database record for that test
69-
SetComment($hotpotatoesName,$newName);
69+
SetComment($hotpotatoesName, $newName);
7070
echo "<script language='Javascript' type='text/javascript'> window.location='exercise.php'; </script>";
7171
}
7272
}
@@ -75,14 +75,13 @@
7575
echo "<input type=\"hidden\" name=\"hotpotatoesName\" value=\"$hotpotatoesName\">";
7676
echo "<input type=\"text\" name=\"newName\" value=\"";
7777

78-
79-
$lstrComment = "";
78+
$lstrComment = '';
8079
$lstrComment = GetComment($hotpotatoesName);
81-
if ($lstrComment=="") {
82-
$lstrComment = GetQuizName($hotpotatoesName,$documentPath);
80+
if ($lstrComment == '') {
81+
$lstrComment = GetQuizName($hotpotatoesName, $documentPath);
8382
}
84-
if ($lstrComment=="") {
85-
$lstrComment = basename($hotpotatoesName,$documentPath);
83+
if ($lstrComment == '') {
84+
$lstrComment = basename($hotpotatoesName, $documentPath);
8685
}
8786

8887
echo $lstrComment;

main/exercice/aiken.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<?php
22
/* For licensing terms, see /license.txt */
3+
34
/**
45
* Code for Aiken import integration.
56
* @package chamilo.exercise
67
* @author Ronny Velasquez <[email protected]>
78
* @author César Perales <[email protected]> Updated function names and import files for Aiken format support
89
*/
9-
/**
10-
* Code
11-
*/
12-
// including the global Chamilo file
10+
1311
require_once '../inc/global.inc.php';
1412
$lib_path = api_get_path(LIBRARY_PATH);
1513
$main_path = api_get_path(SYS_CODE_PATH);

main/exercice/hotspot.class.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
**/
1313
class HotSpot extends Question
1414
{
15-
static $typePicture = 'hotspot.png';
16-
static $explanationLangVar = 'HotSpot';
15+
public static $typePicture = 'hotspot.png';
16+
public static $explanationLangVar = 'HotSpot';
1717

18+
/**
19+
* HotSpot constructor.
20+
*/
1821
public function __construct()
1922
{
2023
parent::__construct();
@@ -34,7 +37,14 @@ public function createForm (&$form, $fck_config=0)
3437
parent::createForm($form, $fck_config);
3538

3639
if (!isset($_GET['editQuestion'])) {
37-
$form->addElement('file','imageUpload',array('<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />', get_lang('UploadJpgPicture')) );
40+
$form->addElement(
41+
'file',
42+
'imageUpload',
43+
array(
44+
'<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />',
45+
get_lang('UploadJpgPicture'),
46+
)
47+
);
3848

3949
// setting the save button here and not in the question class.php
4050
// Saving a question
@@ -75,12 +85,12 @@ public function processCreation($form, $objExercise = null)
7585
}
7686
}
7787

78-
function createAnswersForm ($form)
88+
function createAnswersForm($form)
7989
{
8090
// nothing
8191
}
8292

83-
function processAnswersCreation ($form)
93+
function processAnswersCreation($form)
8494
{
8595
// nothing
8696
}

main/exercice/hotspot_admin.inc.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,9 @@
366366
if ($answerType == HOT_SPOT_DELINEATION) {
367367
// the magic happens here ...
368368
// we do this to not count the if no error section
369-
if ($nbrAnswers >= 2)
369+
if ($nbrAnswers >= 2) {
370370
$nbrAnswers--;
371+
}
371372
}
372373

373374
$reponse = array();
@@ -605,19 +606,16 @@
605606
<tr>
606607
<th width="5">&nbsp;</th>
607608
<th> <?php echo get_lang('HotspotDescription'); ?> *</th>
608-
<?php
609-
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
610-
?>
609+
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
611610
<th><?php echo get_lang('Comment'); ?></th>
612611
<?php
613612
if ($answerType == HOT_SPOT_DELINEATION) {
614613
echo '<th >' . get_lang('Scenario') . '</th>';
615614
}
616-
?>
617-
<?php
618-
} else {
619-
?>
620-
<th colspan="2"><?php echo get_lang('Comment'); ?></th>
615+
} else { ?>
616+
<th colspan="2">
617+
<?php echo get_lang('Comment'); ?>
618+
</th>
621619
<?php } ?>
622620
<th><?php echo get_lang('QuestionWeighting'); ?> *</th>
623621
</tr>
@@ -676,10 +674,8 @@
676674
}
677675

678676
//-------- IF it is a delineation
679-
680677
if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'delineation') {
681678
$option1 = $option2 = $option3 = '';
682-
683679
for ($k = 1; $k <= 100; $k++) {
684680
$selected1 = $selected2 = $selected3 = '';
685681
if ($k == $threadhold1[$i])

main/upload/upload.document.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
/* For licensing terms, see /license.txt */
3+
34
/**
45
* Process part of the document sub-process for upload. This script MUST BE included by upload/index.php
56
* as it prepares most of the variables needed here.
@@ -31,12 +32,9 @@
3132
/**
3233
* Header
3334
*/
34-
3535
$nameTools = get_lang('UplUploadDocument');
3636
$interbreadcrumb[] = array(
37-
"url" => "./document.php?curdirpath=" . urlencode(
38-
$path
39-
) . $req_gid,
37+
"url" => "./document.php?curdirpath=" . urlencode($path) . '&'.api_get_cidreq(),
4038
"name" => $langDocuments
4139
);
4240
Display::display_header($nameTools, "Doc");
@@ -69,13 +67,17 @@
6967
if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
7068
$table_document = Database::get_course_table(TABLE_DOCUMENT);
7169
$ct = '';
72-
if ($new_comment) $ct .= ", comment='$new_comment'";
73-
if ($new_title) $ct .= ", title='$new_title'";
70+
if ($new_comment) {
71+
$ct .= ", comment='$new_comment'";
72+
}
73+
if ($new_title) {
74+
$ct .= ", title='$new_title'";
75+
}
7476
Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'");
7577
}
7678
//check for missing images in html files
7779
$missing_files = check_for_missing_files($base_work_dir.$_POST['curdirpath'].$new_path);
78-
if ($missing_files) {
80+
if ($missing_files) {
7981
//show a form to upload the missing files
8082
Display::display_normal_message(
8183
build_missing_files_form(
@@ -94,7 +96,7 @@
9496
if ($number_of_uploaded_images > 0) {
9597
//we could also create a function for this, I'm not sure...
9698
//create a directory for the missing files
97-
$img_directory = str_replace('.','_',$_POST['related_file']."_files");
99+
$img_directory = str_replace('.', '_', $_POST['related_file']."_files");
98100
$folderData = create_unexisting_directory(
99101
$_course,
100102
$_user['user_id'],
@@ -116,19 +118,20 @@
116118
$to_user_id,
117119
$max_filled_space
118120
);
121+
119122
//open the html file and replace the paths
120123
replace_img_path_in_html_file(
121124
$_POST['img_file_path'],
122125
$paths_to_replace_in_file,
123126
$base_work_dir . $_POST['related_file']
124127
);
125128
//update parent folders
126-
item_property_update_on_folder($_course,$_POST['curdirpath'],$_user['user_id']);
129+
item_property_update_on_folder($_course, $_POST['curdirpath'], $_user['user_id']);
127130
}
128131
}
129132
//they want to create a directory
130133
if (isset($_POST['create_dir']) && $_POST['dirname']!='') {
131-
$added_slash = ($path=='/')?'':'/';
134+
$added_slash = ($path == '/') ? '' : '/';
132135
$dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']);
133136
$created_dir = create_unexisting_directory(
134137
$_course,
@@ -144,7 +147,7 @@
144147
Display::display_normal_message(get_lang('DirCr'));
145148
$path = $created_dir;
146149
} else {
147-
display_error(get_lang('CannotCreateDir'));
150+
Display::addFlash(Display::return_message(get_lang('CannotCreateDir')));
148151
}
149152
}
150153

0 commit comments

Comments
 (0)