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 4, 2021
1 parent caccdec commit 3990912
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 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,21 @@ 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())
->withHeader("Location", $url);
}

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

0 comments on commit 3990912

Please sign in to comment.