Remove E_NOTICE when resolving the hotspot delineation question - refs #8124

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent f64eef3d51
commit 5e25f1d799
  1. 32
      main/exercice/exercise_submit_modal.php
  2. 11
      main/inc/lib/geometry.lib.php

@ -26,7 +26,9 @@ $threadhold1 = null;
$threadhold2 = null; $threadhold2 = null;
$threadhold3 = null; $threadhold3 = null;
if (empty ($exerciseResult)) { $exerciseResult = [];
if (isset($_SESSION['exerciseResult'])) {
$exerciseResult = $_SESSION['exerciseResult']; $exerciseResult = $_SESSION['exerciseResult'];
} }
@ -40,18 +42,18 @@ if (empty($origin)) {
// if origin is learnpath // if origin is learnpath
$learnpath_id = 0; $learnpath_id = 0;
if (empty($learnpath_id)) { if (isset($_REQUEST['learnpath_id'])) {
$learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']); $learnpath_id = intval($_REQUEST['learnpath_id']);
} }
$learnpath_item_id = 0; $learnpath_item_id = 0;
if (empty($learnpath_item_id)) { if (isset($_REQUEST['learnpath_item_id'])) {
$learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']); $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
} }
$_SESSION['hotspot_coord']=array(); $_SESSION['hotspot_coord']=array();
$newquestionList= $_SESSION['newquestionList']; $newquestionList= isset($_SESSION['newquestionList']) ? $_SESSION['newquestionList'] : [];
$questionList = $_SESSION['questionList']; $questionList = $_SESSION['questionList'];
$exerciseId = intval($_GET['exerciseId']); $exerciseId = intval($_GET['exerciseId']);
@ -65,15 +67,19 @@ Session::erase('exerciseResultExtra'.$exerciseId);
Session::erase('questionListExtra'.$exerciseId); Session::erase('questionListExtra'.$exerciseId);
//round-up the coordinates //round-up the coordinates
$coords = explode('/', $_GET['hotspot']);
$user_array = ''; $user_array = '';
if (is_array($coords) && count($coords) > 0) {
foreach ($coords as $coord) { if (isset($_GET['hotspot'])) {
if (!empty($coord)) { $coords = explode('/', $_GET['hotspot']);
list($x, $y) = explode(';', $coord);
$user_array .= round($x).';'.round($y).'/'; if (is_array($coords) && count($coords) > 0) {
foreach ($coords as $coord) {
if (!empty($coord)) {
list($x, $y) = explode(';', $coord);
$user_array .= round($x).';'.round($y).'/';
}
} }
} }
} }
$choice_value = ''; $choice_value = '';

@ -151,8 +151,8 @@ function poly_compile($poly, $max, $test = false) {
// doubling the first point if needed (see above) // doubling the first point if needed (see above)
if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) { if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) {
if (is_array($bords[$poly[$i]['y']])) if (is_array($bords[$poly[$i - 1]['y']]))
array_push($bords[$poly[$i]['y']], round($poly[$i]['x'])); array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x']));
//if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') ';
} }
// doubling the last point if neededd // doubling the last point if neededd
@ -188,7 +188,11 @@ function poly_compile($poly, $max, $test = false) {
sort($bords[$i]); sort($bords[$i]);
} }
for ($j = 0; $j<sizeof($bords[$i]);$j+=2) // bords for ($j = 0; $j<sizeof($bords[$i]);$j+=2) { // bords
if (!isset($bords[$i][$j + 1])) {
continue;
}
for ($k = round($bords[$i][$j]); $k<=$bords[$i][$j+1];$k++) { for ($k = round($bords[$i][$j]); $k<=$bords[$i][$j+1];$k++) {
$res[$k][$i] = true; //filling the array with trues $res[$k][$i] = true; //filling the array with trues
if ($test == 1) { if ($test == 1) {
@ -203,6 +207,7 @@ function poly_compile($poly, $max, $test = false) {
echo $k.' '.$i; echo '<br />'; echo $k.' '.$i; echo '<br />';
} }
} }
}
} }
return $res; return $res;

Loading…
Cancel
Save