Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 75 additions & 16 deletions modules/behavioural_qc/jsx/tabs_content/behaviouralFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ import Loader from 'jsx/Loader';
import FilterableDataTable from 'jsx/FilterableDataTable';
import {withTranslation} from 'react-i18next';

/**
* Build a URL with query parameters.
*
* @param {string} baseURL - LORIS base URL.
* @param {string} path - The URL path.
* @param {object} params - Query parameters to append.
* @return {string} the URL with query parameters.
*/
const buildURL = (baseURL, path, params) => {
const query = new URLSearchParams();

Object.entries(params).forEach(([key, value]) => {
if (value !== undefined && value !== null && value !== '') {
query.append(key, value);
}
});

return baseURL + path + (query.toString() ? '?' + query.toString() : '');
};

/**
* Behavioural Feedback Component.
*
Expand Down Expand Up @@ -88,6 +108,7 @@ class BehaviouralFeedback extends Component {
const labelInstrument = t('Instrument', {ns: 'loris', count: 1});
const labelTestName = t('Test Name', {ns: 'behavioural_qc'});
const labelVisit = t('Visit', {ns: 'loris'});
const candID = rowData[labelDCCID];

// PSCID column (match English or translated)
if (column === 'PSCID' || column === labelPSCID) {
Expand Down Expand Up @@ -117,26 +138,64 @@ class BehaviouralFeedback extends Component {
if (column === 'Feedback Level' || column === labelBVL) {
let bvlLink = '';
let bvlLevel = '';
if (rowData[labelInstrument]) {
bvlLink = this.props.baseURL +
'/instruments/' +
rowData[labelTestName] +
'/?candID=' + rowData[labelDCCID] +
'&sessionID=' + rowData['sessionID'] +
'&commentID=' + rowData['commentID'] +
'&showFeedback=true';
const feedbackLevel = rowData[labelBVL];
const sessionID = rowData['sessionID'];
const commentID = rowData['commentID'];
const testName = rowData[labelTestName];
const instrument = rowData[labelInstrument] || testName || commentID;
const hasSession = sessionID !== undefined
&& sessionID !== null
&& sessionID !== ''
&& sessionID !== 0
&& sessionID !== '0';

if (feedbackLevel === 'instrument') {
if (hasSession) {
bvlLink = buildURL(
this.props.baseURL,
'/instrument_list/',
{
candID,
sessionID,
commentID,
showFeedback: true,
}
);
} else {
bvlLink = buildURL(
this.props.baseURL,
'/' + candID + '/',
{showFeedback: true}
);
}
bvlLevel = labelInstrument + ' : '
+ rowData[labelInstrument];
} else if (rowData[labelVisit]) {
bvlLink = this.props.baseURL +
'/instrument_list/?candID=' + rowData[labelDCCID] +
'&sessionID=' + rowData['sessionID'] +
'&showFeedback=true';
+ instrument;
} else if (feedbackLevel === 'visit') {
if (hasSession) {
bvlLink = buildURL(
this.props.baseURL,
'/instrument_list/',
{
candID,
sessionID,
showFeedback: true,
}
);
} else {
bvlLink = buildURL(
this.props.baseURL,
'/' + candID + '/',
{showFeedback: true}
);
}
bvlLevel = labelVisit + ' : '
+ rowData[labelVisit];
} else {
bvlLink = this.props.baseURL + '/' + rowData[labelDCCID]
+ '/?showFeedback=true';
bvlLink = buildURL(
this.props.baseURL,
'/' + candID + '/',
{showFeedback: true}
);
bvlLevel = t('Profile', {ns: 'behavioural_qc'}) + ' : '
+ rowData[labelPSCID];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<?php declare(strict_types=1);

/**
* Behavioural QC data provisioner for behavioural feedback.
*
* PHP version 7
*
* @category Behavioural
* @package Loris
* @author Xavier Lecours <xavier.lecours@mcin.ca>
* Alizée Wickenheiser <alizee.wickenheiser@mcin.ca>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://github.com/aces/Loris-Trunk
*/
namespace LORIS\behavioural_qc\Provisioners;

/**
* TThis class implements a data provisioner to get all feedback level
* This class implements a data provisioner to get all feedback level
* of visits.
*
* PHP version 7
Expand Down Expand Up @@ -49,7 +61,7 @@ class BehaviouralProvisioner extends \LORIS\Data\Provisioners\DBObjectProvisione
LEFT JOIN test_names tn ON (tn.ID = f.TestID)
WHERE
fb.Public = 'Y'
AND fb.Status = 'opened'
AND fb.Status <> 'closed'
AND fb.active = 'Y'
",
[],
Expand Down
6 changes: 5 additions & 1 deletion modules/instrument_list/php/instrument_list.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,11 @@ class Instrument_List extends \NDB_Menu_Filter
*/
function getFeedbackPanel(CandID $candID, ?\SessionID $sessionID): string
{
$feedbackPanel = new \BVL_Feedback_Panel($candID, $sessionID);
$feedbackPanel = new \BVL_Feedback_Panel(
$candID,
$sessionID,
$this->commentID ?: null
);
$html = $feedbackPanel->display();
return $html;
}
Expand Down
4 changes: 2 additions & 2 deletions php/libraries/NDB_BVL_Feedback.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ class NDB_BVL_Feedback
ON (c.ID=ft.CandidateID)
LEFT JOIN session as s
ON (s.ID = ft.SessionID)
JOIN feedback_bvl_type as ftp
LEFT JOIN feedback_bvl_type as ftp
ON (ftp.Feedback_type=ft.Feedback_type)";
if (!empty($this->_feedbackObjectInfo['CommentID'])) {
$query .= ", flag as f LEFT JOIN test_names tn ON (tn.ID=f.TestID)";
Expand All @@ -574,7 +574,7 @@ class NDB_BVL_Feedback
// cause SQL syntax errors on any code paths.
// This would make more sense to put in an array and then
// call "join($arrayname, ", ") at the end to construct the string.
$query .= " WHERE ftp.Feedback_type = ft.Feedback_type";
$query .= " WHERE 1=1";

if (!empty($this->_feedbackObjectInfo['CommentID'])) {
$query .= " AND ft.SessionID = :SID";
Expand Down
Loading