Skip to content

Commit

Permalink
[Instruments] Redirect on save success to load defaults from database
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Nov 10, 2021
1 parent caccdec commit 8613bc0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions php/libraries/NDB_BVL_Instrument.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2881,9 +2881,10 @@ abstract class NDB_BVL_Instrument extends NDB_Page
*/
public function handle(ServerRequestInterface $request) : ResponseInterface
{
$req = $request->getParsedBody();
$req = $request->getParsedBody();
$success = false;
if ($request->getMethod() === "POST" && !isset($req['ClearInstrument'])) {
$this->save();
$success = $this->save();
}

// Disable form if data entry is complete
Expand Down Expand Up @@ -2913,6 +2914,22 @@ abstract class NDB_BVL_Instrument extends NDB_Page
$this->freeze();
}

if ($success) {
$sessionID = $request->getQueryParams()["sessionID"];
$candID = $request->getQueryParams()["candID"];
$baseURL = \NDB_Factory::singleton()->settings()->getBaseURL();
$pageURL = !empty($this->page) ? urlencode($this->page) ."/" : "";
$url = $baseURL . "/instruments/" .
urlencode($this->testName) . "/" .
$pageURL .
'?commentID=' . urlencode($this->getCommentID()) .
'&candID=' . urlencode($candID) .
'&sessionID=' . urlencode($sessionID);
return (new \LORIS\Http\Response())
->withStatus(303)
->withHeader("Location", $url);
}

return (new \LORIS\Http\Response())
->withBody(new \LORIS\Http\StringStream($this->display() ?? ""));
}
Expand Down

0 comments on commit 8613bc0

Please sign in to comment.