Skip to content

Commit

Permalink
[conflict_resolver] api + dataframework (version 3) (#7558)
Browse files Browse the repository at this point in the history
implements the auto-saving of conflict resolution
Add 2 endpoints (/conflict_resolver/unresolved and /conflict_resolver/resolved)
Adds a schema.yml file

PR #6862
PR #5140
  • Loading branch information
xlecours authored Sep 24, 2021
1 parent 57aa485 commit 3d15403
Show file tree
Hide file tree
Showing 27 changed files with 1,793 additions and 1,430 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ requesting a new account and will be displayed in the User Accounts module (PR #
- Deletion of support for the oldest version of the API (v0.0.2) (PR #6944)
#### Candidate Parameters
- Consents may now be grouped in UI of consent tab (PR #6042, PR #6044)
#### Conflict Resolver
- Changes are now saved automatically, one by one. Once a conflict is resolved the cell that contains the input field will glow green. It is possible to change
the resolved conflicts to a new value until the page is refreshed. [(PR #7558)](https://github.com/aces/Loris/pull/7558)
- This module's API is now described in a Open API Specification file (schema.yml) that can be loaded in the new API Documentation module.
#### API Documentation (**New Module**)
- New module mostly intended for developers, this module provides a user interface to inspect and try LORIS modules API.
### Clean Up
Expand Down
3 changes: 2 additions & 1 deletion SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,8 @@ CREATE TABLE `conflicts_resolved` (
`OldValue2` text DEFAULT NULL,
`NewValue` text DEFAULT NULL,
`ConflictID` int(10) DEFAULT NULL,
PRIMARY KEY (`ResolvedID`)
PRIMARY KEY (`ResolvedID`),
UNIQUE KEY `ConflictID` (`ConflictID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ********************************
Expand Down
3 changes: 3 additions & 0 deletions SQL/New_patches/2021-08-27_conflict_resolved_unique_key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Add UNIQUE key to ConflictID so we can use REPLACE INTO ...
ALTER TABLE conflicts_resolved ADD UNIQUE KEY (ConflictID);

23 changes: 6 additions & 17 deletions modules/api/php/endpoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace LORIS\Api;
use \Psr\Http\Message\ServerRequestInterface;
use \Psr\Http\Server\RequestHandlerInterface;
use \Psr\Http\Message\ResponseInterface;


use \LORIS\Http\Endpoint as LORISEndpoint;
/**
* An abstract class for common concerns of different API endpoints.
*
Expand All @@ -27,7 +26,7 @@ use \Psr\Http\Message\ResponseInterface;
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://github.com/aces/Loris
*/
abstract class Endpoint implements RequestHandlerInterface
abstract class Endpoint extends LORISEndpoint implements RequestHandlerInterface
{
/**
* Return an array of valid HTTP methods for this endpoint
Expand All @@ -45,16 +44,13 @@ abstract class Endpoint implements RequestHandlerInterface
abstract protected function supportedVersions() : array;

/**
* An API endpoint overrides the default LORIS middleware to remove the
* PageDecorationMiddleware, since the API only deals with JSON.
*
* It also acts as its own middleware by validating that an endpoint supports
* both the version of the API passed, and the HTTP method request type.
* An API endpoint overrides the default LORIS Endpoint to add checks for
* supported version(s).
*
* @param ServerRequestInterface $request The incoming PSR7 request
* @param RequestHandlerInterface $handler The PSR15 request handler
*
* @return ResponseInterface The outgoing PSR7 response
* @return ResponseInterface
*/
public function process(
ServerRequestInterface $request,
Expand All @@ -66,13 +62,6 @@ abstract class Endpoint implements RequestHandlerInterface
return new \LORIS\Http\Response\JSON\BadRequest('Unsupported version');
}

// Hack so that phan doesn't forget it's a RequestHandler inside
// the if statement when passed as an argument to process
$h = $handler;
if ($handler instanceof \LORIS\Middleware\ETagCalculator) {
return (new \LORIS\Middleware\ETag())->process($request, $h);
}

return $handler->handle($request);
return parent::process($request, $handler);
}
}
2 changes: 1 addition & 1 deletion modules/api/php/endpoints/login.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Login extends Endpoint
*
* @return boolean true if access is permitted
*/
function _hasAccess(\User $user) : bool
function hasAccess(\User $user) : bool
{
// Anyone can try and login. Even you.
return true;
Expand Down
4 changes: 2 additions & 2 deletions modules/conflict_resolver/help/conflict_resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ This module is designed to identify and resolve data conflicts in a study. LORIS

Conflicts are displayed in a table with two separate tabs—resolved and unresolved conflicts. By default, the module displays the *Unresolved Conflicts* tab. You can narrow this list of results using any combination of filters in the *Selection Filters* section.

You can resolve all conflicts in the **Correct Answer** column of the resulting table. Click the drop-down to reveal two different responses—this is the conflict. These are two distinct values that were entered initially and during double data entry—they should be the same value. After cross-checking your data records for accuracy, select the correct response of the two.
You can resolve conflicts in the **Correct Answer** column of the resulting table. Click the drop-down to reveal two different responses—this is the conflict. These are two distinct values that were entered initially and during double data entry—they should be the same value. After cross-checking your data records for accuracy, select the correct response of the two. Changes are saved automatically. Once a conflict is resolved a green check will appear beside the input filed. If a red cross is displayed, the conflict could not be saved (Your browser console log will display the error message.)

You can continue resolving conflicts in this list. To save your changes, click **Save** below the table. All saved, resolved conflicts will now appear in the *Resolved Conflicts* tab of the table.
It is possible to change the resolved conflicts to a new value until the page is refreshed. After refresh or when changing tab, the newly resolved conflicts will appear in the *Resolved Conflicts* tab.
Loading

0 comments on commit 3d15403

Please sign in to comment.