Minor - Format code, fix PHP warnings

1.10.x
Julio Montoya 10 years ago
parent 31daa2c692
commit 9097cec29a
  1. 39
      main/exercice/hotpotatoes.php
  2. 10
      main/exercice/hotspot_save.inc.php
  3. 8
      main/exercice/unique_answer.class.php
  4. 10
      main/newscorm/learnpath.class.php

@ -42,9 +42,9 @@ $course_id = api_get_course_int_id();
// Setting some variables.
$document_sys_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$uploadPath = '/HotPotatoes_files';
$finish = (!empty($_POST['finish']) ? $_POST['finish'] : 0);
$imgcount = (!empty($_POST['imgcount']) ? $_POST['imgcount'] : null);
$fld = (!empty($_POST['fld']) ? $_POST['fld'] : null);
$finish = (!empty($_POST['finish']) ? $_POST['finish'] : 0);
$imgcount = (!empty($_POST['imgcount']) ? $_POST['imgcount'] : null);
$fld = (!empty($_POST['fld']) ? $_POST['fld'] : null);
$imgparams = [];
$dialogBox = '';
@ -56,9 +56,21 @@ if ($finish == 2 && isset($_POST['imgparams'])) {
if (api_is_allowed_to_edit(null, true)) {
if (hotpotatoes_init($document_sys_path.$uploadPath)) {
// If the directory doesn't exist, create the "HotPotatoes" directory.
$doc_id = add_document($_course, '/HotPotatoes_files', 'folder', 0, get_lang('HotPotatoesFiles'));
$doc_id = add_document(
$_course,
'/HotPotatoes_files',
'folder',
0,
get_lang('HotPotatoesFiles')
);
// Update properties in dbase (in any case).
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', api_get_user_id());
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'FolderCreated',
api_get_user_id()
);
// Make invisible (in any case) - why?
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id());
}
@ -67,7 +79,13 @@ if (api_is_allowed_to_edit(null, true)) {
/** Display */
$nameTools = get_lang('HotPotatoesTests');
$form = new FormValidator('hotpotatoes', 'post', api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));
$form = new FormValidator(
'hotpotatoes',
'post',
api_get_self()."?".api_get_cidreq(),
null,
array('enctype' => 'multipart/form-data')
);
$form->addElement('header', $nameTools);
$form->addElement('hidden', 'uploadPath');
$form->addElement('hidden', 'fld', $fld);
@ -119,7 +137,6 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
$filename = $_FILES['userFile']['name'];
}
/*if (treat_uploaded_file($_FILES['userFile'], $document_sys_path, $uploadPath."/".$fld, $max_filled_space, $unzip))*/
$allow_output_on_success = false;
if (handle_uploaded_document(
$_course,
@ -163,8 +180,9 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
}
$title = @htmlspecialchars(GetQuizName($filename, $document_sys_path.$uploadPath.'/'.$fld.'/'), ENT_COMPAT, api_get_system_encoding());
$query = "UPDATE $dbTable SET comment='".Database::escape_string($title)."'
WHERE c_id = $course_id AND path=\"".$uploadPath."/".$fld."/".$filename."\"";
$query = "UPDATE $dbTable
SET comment='".Database::escape_string($title)."'
WHERE c_id = $course_id AND path=\"".$uploadPath."/".$fld."/".$filename."\"";
Database::query($query);
api_item_property_update($_course, TOOL_QUIZ, $id, 'QuizAdded', api_get_user_id());
@ -196,7 +214,8 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2)))
'</a>';
echo '</div>';
if ($finish == 2) { // If we are in the img upload process.
if ($finish == 2) {
// If we are in the img upload process.
$dialogBox .= get_lang('ImgNote_st').$imgcount.get_lang('ImgNote_en').'<br />';
while (list($key, $string) = each($imgparams)) {
$dialogBox .= $string.'; ';

@ -35,7 +35,13 @@ if ($_GET['type'] == "poly" || $_GET['type'] == "delineation" || $_GET['type'] =
$hotspot_coordinates = api_substr($hotspot_coordinates,0,-2);
}
$course_id = api_get_course_int_id();
$sql = "UPDATE $TBL_ANSWER SET hotspot_coordinates = '".Database::escape_string($hotspot_coordinates)."',hotspot_type = '".Database::escape_string($hotspot_type)."'
WHERE c_id = $course_id AND id = ".intval($answerId)." AND question_id = ".intval($questionId)." LIMIT 1 ;";
$sql = "UPDATE $TBL_ANSWER SET
hotspot_coordinates = '".Database::escape_string($hotspot_coordinates)."',
hotspot_type = '".Database::escape_string($hotspot_type)."'
WHERE
c_id = $course_id AND
id = ".intval($answerId)." AND
question_id = ".intval($questionId)."
LIMIT 1 ";
$result = Database::query($sql);
echo "done=done";

@ -143,10 +143,10 @@ class UniqueAnswer extends Question
$item_list = explode('@@', $answer->destination[$i]);
$try = $item_list[0];
$lp = $item_list[1];
$list_dest = $item_list[2];
$url = $item_list[3];
$try = isset($item_list[0]) ? $item_list[0] : '';
$lp = isset($item_list[1]) ? $item_list[1] : '';
$list_dest = isset($item_list[2]) ? $item_list[2] : '';
$url = isset($item_list[3]) ? $item_list[3] : '';
if ($try == 0) {
$try_result = 0;

@ -5391,9 +5391,10 @@ class learnpath
$prerequisiteMinScore = isset($array[$i]['prerequisite_min_score']) ? $array[$i]['prerequisite_min_score'] : null;
$prerequisiteMaxScore = isset($array[$i]['prerequisite_max_score']) ? $array[$i]['prerequisite_max_score'] : null;
$ref = isset($array[$i]['ref']) ? $array[$i]['ref'] : '';
$this->arrMenu[] = array(
'id' => $array[$i]['id'],
'ref' => $ref,
'item_type' => $array[$i]['item_type'],
'title' => $array[$i]['title'],
'path' => $path,
@ -6535,7 +6536,6 @@ class learnpath
public function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '')
{
$course_id = api_get_course_int_id();
global $charset;
$uploadPath = DIR_HOTPOTATOES; //defined in main_api
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
@ -8319,8 +8319,8 @@ class learnpath
$return .= '<label for="idNone">' . get_lang('None') . '</label>';
$return .= '</tr>';
$sql = "SELECT * FROM $tbl_lp_item
WHERE c_id = $course_id AND lp_id = " . $this->lp_id;
$sql = "SELECT * FROM $tbl_lp_item
WHERE c_id = $course_id AND lp_id = " . $this->lp_id;
$result = Database::query($sql);
$arrLP = array();
@ -8415,7 +8415,7 @@ class learnpath
$return .= '</tr>';
$return .= '</table>';
$return .= '<div style="padding-top:3px;">';
$return .= '<button class="btn btn-default" name="submit_button" type="submit">' . get_lang('ModifyPrerequisites') . '</button>';
$return .= '<button class="btn btn-primary" name="submit_button" type="submit">' . get_lang('ModifyPrerequisites') . '</button>';
$return .= '</form>';
return $return;

Loading…
Cancel
Save