From 5e25f1d7991efd3dabe61dc6e936582a406792c7 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 9 Mar 2016 10:38:40 -0500 Subject: [PATCH] Remove E_NOTICE when resolving the hotspot delineation question - refs #8124 --- main/exercice/exercise_submit_modal.php | 32 +++++++++++++++---------- main/inc/lib/geometry.lib.php | 11 ++++++--- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/main/exercice/exercise_submit_modal.php b/main/exercice/exercise_submit_modal.php index 84fbba8dc47..e43bf145e22 100755 --- a/main/exercice/exercise_submit_modal.php +++ b/main/exercice/exercise_submit_modal.php @@ -26,7 +26,9 @@ $threadhold2 = null; $threadhold3 = null; -if (empty ($exerciseResult)) { +$exerciseResult = []; + +if (isset($_SESSION['exerciseResult'])) { $exerciseResult = $_SESSION['exerciseResult']; } @@ -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']); @@ -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 = ''; diff --git a/main/inc/lib/geometry.lib.php b/main/inc/lib/geometry.lib.php index cc3b67ac94d..27f93103b55 100755 --- a/main/inc/lib/geometry.lib.php +++ b/main/inc/lib/geometry.lib.php @@ -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 @@ -188,7 +188,11 @@ function poly_compile($poly, $max, $test = false) { sort($bords[$i]); } - for ($j = 0; $j'; } } + } } return $res;