Skip to content

Commit

Permalink
Remove E_NOTICE when resolving the hotspot delineation question - ref…
Browse files Browse the repository at this point in the history
…s #8124
  • Loading branch information
AngelFQC committed Mar 9, 2016
1 parent f64eef3 commit 5e25f1d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
32 changes: 19 additions & 13 deletions main/exercice/exercise_submit_modal.php
Expand Up @@ -26,7 +26,9 @@
$threadhold2 = null;
$threadhold3 = null;

if (empty ($exerciseResult)) {
$exerciseResult = [];

if (isset($_SESSION['exerciseResult'])) {
$exerciseResult = $_SESSION['exerciseResult'];
}

Expand All @@ -40,18 +42,18 @@
// if origin is learnpath
$learnpath_id = 0;

if (empty($learnpath_id)) {
$learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']);
if (isset($_REQUEST['learnpath_id'])) {
$learnpath_id = intval($_REQUEST['learnpath_id']);
}

$learnpath_item_id = 0;

if (empty($learnpath_item_id)) {
$learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']);
if (isset($_REQUEST['learnpath_item_id'])) {
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
}

$_SESSION['hotspot_coord']=array();
$newquestionList= $_SESSION['newquestionList'];
$newquestionList= isset($_SESSION['newquestionList']) ? $_SESSION['newquestionList'] : [];
$questionList = $_SESSION['questionList'];

$exerciseId = intval($_GET['exerciseId']);
Expand All @@ -65,15 +67,19 @@
Session::erase('questionListExtra'.$exerciseId);

//round-up the coordinates
$coords = explode('/', $_GET['hotspot']);
$user_array = '';
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).'/';

if (isset($_GET['hotspot'])) {
$coords = explode('/', $_GET['hotspot']);

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 = '';
Expand Down
11 changes: 8 additions & 3 deletions main/inc/lib/geometry.lib.php
Expand Up @@ -151,8 +151,8 @@ function poly_compile($poly, $max, $test = false) {

// doubling the first point if needed (see above)
if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) {
if (is_array($bords[$poly[$i]['y']]))
array_push($bords[$poly[$i]['y']], round($poly[$i]['x']));
if (is_array($bords[$poly[$i - 1]['y']]))
array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x']));
//if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') ';
}
// doubling the last point if neededd
Expand Down Expand Up @@ -188,7 +188,11 @@ function poly_compile($poly, $max, $test = false) {
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++) {
$res[$k][$i] = true; //filling the array with trues
if ($test == 1) {
Expand All @@ -203,6 +207,7 @@ function poly_compile($poly, $max, $test = false) {
echo $k.' '.$i; echo '<br />';
}
}
}
}

return $res;
Expand Down

0 comments on commit 5e25f1d

Please sign in to comment.