From 378fcec3d249d53d749f320f139bd90b02f4b6db Mon Sep 17 00:00:00 2001 From: Zaliqa Date: Tue, 14 May 2019 13:56:53 -0400 Subject: [PATCH] Instruments module (#46) - Names commentID in ControlPanel to match its parent's - Replaces REQUESTS with variables --- php/libraries/NDB_BVL_Instrument.class.inc | 10 +++++---- ...VL_InstrumentStatus_ControlPanel.class.inc | 22 +++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 8b99796bb30..2b8b5a2ba53 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -2199,16 +2199,19 @@ abstract class NDB_BVL_Instrument extends NDB_Page */ function getControlPanel(): string { + $sessionID = $this->getSessionID(); + $timepoint = \TimePoint::singleton($sessionID); + $candID = $timepoint->getCandID(); if (!empty($_REQUEST['commentID'])) { // make the control panel object for the current instrument $controlPanel = new NDB_BVL_InstrumentStatus_ControlPanel( $this->testName, $this->getCommentID() ?? '', - 0, - $this->getSessionID(), + $candID, + $sessionID, $this->page ?? '' ); - $this->addHidden('test_name', $this->testName); + $this->addHidden('test_name', $this->testName); $this->addHidden('page', $this->page); $this->addHidden('subtest', $this->page); @@ -2624,7 +2627,6 @@ abstract class NDB_BVL_Instrument extends NDB_Page */ public function handle(ServerRequestInterface $request) : ResponseInterface { - $this->setup($this->commentID, $this->page); if ($request->getMethod() === "POST") { $this->save(); } diff --git a/php/libraries/NDB_BVL_InstrumentStatus_ControlPanel.class.inc b/php/libraries/NDB_BVL_InstrumentStatus_ControlPanel.class.inc index c93b913452b..06b514bef06 100644 --- a/php/libraries/NDB_BVL_InstrumentStatus_ControlPanel.class.inc +++ b/php/libraries/NDB_BVL_InstrumentStatus_ControlPanel.class.inc @@ -42,11 +42,11 @@ class NDB_BVL_InstrumentStatus_ControlPanel extends NDB_BVL_InstrumentStatus int $sessionid, ?string $subtest ) { - $this->candID = $candid; - $this->testname = $testname; - $this->commentID = $commentid; - $this->sessionID = $sessionid; - $this->subtest = $subtest; + $this->candID = $candid; + $this->testname = $testname; + $this->_commentID = $commentid; + $this->sessionID = $sessionid; + $this->subtest = $subtest; } /** @@ -63,7 +63,7 @@ class NDB_BVL_InstrumentStatus_ControlPanel extends NDB_BVL_InstrumentStatus $this->tpl_data['candID'] = $this->candID ?? ''; $this->tpl_data['sessionID'] = $this->sessionID; - $this->tpl_data['commentID'] = $this->commentID; + $this->tpl_data['commentID'] = $this->_commentID; $this->tpl_data['test_name'] = $this->testname; $this->tpl_data['subtest'] = $this->subtest ?? ''; @@ -88,7 +88,7 @@ class NDB_BVL_InstrumentStatus_ControlPanel extends NDB_BVL_InstrumentStatus // create an instance of the instrument $instrument = NDB_BVL_Instrument::factory( $this->testname, - $this->commentID, + $this->_commentID, $this->subtest ?? '' ); @@ -158,9 +158,9 @@ class NDB_BVL_InstrumentStatus_ControlPanel extends NDB_BVL_InstrumentStatus $user = User::singleton(); if ($user->hasPermission('send_to_dcc')) { $instrument = \NDB_BVL_Instrument::factory( - $_REQUEST['test_name'], - $_REQUEST['commentID'], - $_REQUEST['subtest'] + $this->testname, + $this->_commentID, + $this->subtest ?? '' ); $instrument->clearInstrument(); return false; @@ -382,7 +382,7 @@ class NDB_BVL_InstrumentStatus_ControlPanel extends NDB_BVL_InstrumentStatus $user = \User::singleton(); // make a timepoint object - $timePoint = \TimePoint::singleton($this->getSessionID()); + $timePoint = \TimePoint::singleton($this->sessionID); // make sure user belongs to same site as timepoint if (!$user->hasPermission('data_entry')