Skip to content

Commit

Permalink
Instruments module (#46)
Browse files Browse the repository at this point in the history
- Names commentID in ControlPanel to match its parent's
- Replaces REQUESTS with variables
  • Loading branch information
zaliqarosli authored and Dave MacFarlane committed May 14, 2019
1 parent fbcd8cc commit 378fcec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
10 changes: 6 additions & 4 deletions php/libraries/NDB_BVL_Instrument.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
Expand Down
22 changes: 11 additions & 11 deletions php/libraries/NDB_BVL_InstrumentStatus_ControlPanel.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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 ?? '';

Expand All @@ -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 ?? ''
);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 378fcec

Please # to comment.