Skip to content

Commit 27d9121

Browse files
authored
Merge pull request #6788 from christianbeeznest/ifa-22899-2
Exercise: Prevent duplicate question creation on Hotspot zone validation - refs BT#22899
2 parents 42bbb9a + 4a10e1c commit 27d9121

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

main/exercise/hotspot_admin.inc.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
* @author Toon Keppens
1414
*/
1515
$modifyAnswers = (int) $_GET['hotspotadmin'];
16-
if (!is_object($objQuestion)) {
16+
if (!is_object($objQuestion) || empty($objQuestion->iid) || (int)$objQuestion->iid !== $modifyAnswers) {
1717
$objQuestion = Question::read($modifyAnswers);
18+
if (!$objQuestion) {
19+
api_not_allowed();
20+
}
21+
Session::write('objQuestion', $objQuestion);
1822
}
1923

2024
$questionName = $objQuestion->selectTitle();
@@ -330,14 +334,16 @@
330334
);
331335
$objAnswer->save();
332336

333-
// sets the total weighting of the question
334-
$objQuestion->updateWeighting($questionWeighting);
337+
$objQuestion->iid = (int)$modifyAnswers;
338+
$objQuestion->course = api_get_course_info();
339+
$objQuestion->updateWeighting((float)$questionWeighting);
340+
335341
$objQuestion->save($objExercise);
336342

337-
$editQuestion = $questionId;
343+
$editQuestion = $objQuestion->iid;
338344
unset($modifyAnswers);
339-
echo '<script type="text/javascript">window.location.href="'.$hotspot_admin_url
340-
.'&message=ItemUpdated"</script>';
345+
echo '<script type="text/javascript">window.location.href="'.
346+
$hotspot_admin_url.'&message=ItemUpdated"</script>';
341347
}
342348
}
343349
}

0 commit comments

Comments
 (0)