Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/plagiarism#52 iThenticate API update and plugin update #57

Merged
merged 76 commits into from
Sep 30, 2024

Conversation

touhidurabir
Copy link
Member

@touhidurabir touhidurabir commented Feb 6, 2024

for #52 . The PR has following updates :

  1. update of iThenticate API to latest version
  2. EUAL confirmation process
  3. New credentials added
  4. Removal of previous API library and introduced new custom service class for API communication
  5. Removal of composer dependency
  6. Presenting the possible proper EULA as submission checklist
  7. stamping of EULA to submission and submitter
  8. verification of user provided ithenticate service access(API URL/KEY) before storing.
  9. context wise EULA caching to avoid continuous data polling form API service .
  10. allow iThenticate retry, polling, similarity score presentation for each file, refreshing similarity scores and launch similarity viewer .
  11. Config to manage auto upload which allow iThenticate auto upload at submission time or later upload manually
  12. Compatible with OPS

Following Issues get resolved by this PR

  1. Send submissions to iThenticate at later stage #4
  2. Add iThenticate plugin support for OPS #55
  3. PNG in supplemental files causes entire submission process to hang when plugin activated #48
  4. New Submissions Confirmation is Failed #46
  5. Cleanup error handling #23
  6. Enabling the plugin impossible if settings are present in config file when plugin is first installed #49

PlagiarismPlugin.inc.php Outdated Show resolved Hide resolved
PlagiarismPlugin.inc.php Outdated Show resolved Hide resolved
Copy link
Member

@asmecher asmecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some early comments -- I'll have a look at the schema extension issue next week.

IThenticate.inc.php Outdated Show resolved Hide resolved
IThenticate.inc.php Outdated Show resolved Hide resolved
IThenticate.inc.php Show resolved Hide resolved
IThenticate.inc.php Outdated Show resolved Hide resolved
PlagiarismPlugin.inc.php Show resolved Hide resolved
Copy link
Member

@asmecher asmecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more changes -- I'll review these with you shortly!

IThenticate.inc.php Outdated Show resolved Hide resolved
IThenticate.inc.php Show resolved Hide resolved
IThenticate.inc.php Outdated Show resolved Hide resolved
IThenticate.inc.php Outdated Show resolved Hide resolved
IThenticate.inc.php Outdated Show resolved Hide resolved
IThenticate.inc.php Show resolved Hide resolved
PlagiarismPlugin.inc.php Outdated Show resolved Hide resolved
);
public function initData() {
$this->_data = [
'ithenticateApiUrl' => $this->_plugin->getSetting($this->_contextId, 'ithenticateApiUrl'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(spaces in with tabs)

}

public function handle() {
error_log('handle webhook request');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't leave this in the distribution version of the plugin, as it's debugging/dev code. But if we did, it should be prefixed with something to indicate more about what this is, e.g. "PKP Plagiarism plugin".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will eventually implement some functionality through webhook but probably not for stable-3.3.0 .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we initially planed not to use the webhook for 3.3.0-x but we have to as without webhook, we can not initiate the similarity report generation process .

IThenticate.inc.php Outdated Show resolved Hide resolved
Copy link
Member

@asmecher asmecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch more minor comments; I've mentioned a few of these before (mixed spacing/tabs and variants of EULA), so please double-check to make sure it's all cleaned up for the next round. Thanks!

class IThenticate
{
/**
* The base api url in the format of schems://host
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*scheme

protected $integrationVersion;

/**
* The EULA(end user license agreement) that user need to confrim before making request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*confirm

}

/**
* Validate the service access by retrieving the the enabled feature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the the

'Content-Type' => 'application/json'
]),
'json' => [
'owner' => $author->getId(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using our internal IDs for owner and submitter? We use email addresses as unique account identifiers in OJS; maybe those would be more appropriate for users; we can't always count on having those for authors, though.

If this is something we can use for our own arbitrary purposes, it might be worth adding some kind of namespacing to avoid confusion -- e.g. author/54 and user/54 rather than just the numeric 54. It'll be easy to forget where we're using Users and where we're using Authors and the IDs aren't comparable. If iThenticate ever does a comparison between them for e.g. permission purposes, it'll mistakenly conclude that they're the same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email addresses as unique account identifiers in OJS; maybe those would be more appropriate for users; we can't always count on having those for authors, though

That was my initial approach also but because an author may not have an email address and author/owner details is required, we could not use email

If this is something we can use for our own arbitrary purposes

Not actually . According to TAC developer doc, submission author/owner unique system identifier is required . The submitter information is optional but in that case owner/author must accept/confirm EULA . As in our case, the author/owner and submitter can be different and it's the submitter who confirms the EULA, we also need to pass it .

it might be worth adding some kind of namespacing to avoid confusion -- e.g. author/54 and user/54

I think that a good idea and will do it .


$response = Application::get()->getHttpClient()->request(
'PUT',
$this->getApiPath("submissions/{$submissionTacId}/original"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where we're building parameters into URL strings, we should probably be using rawurlencode (here and elsewhere).

Copy link
Member Author

@touhidurabir touhidurabir Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bad idea but then rather than using the rawurlencode directly we should let the Guzzel handle it by returning an instance of \GuzzleHttp\Psr7\Uri .

public function retrieveApplicableEulaDetails($cache, $cacheId) {
$context = Application::get()->getRequest()->getContext();
$ithenticate = $this->initIthenticate(...$this->getServiceAccess($context)); /** @var \IThenticate $ithenticate */
$eualDetails = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be eulaDetails (here and below)

*
* @return void
*/
protected function stampEualVersionToSubmittingUser($user, $version) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Eula, not Eual.

* @copydoc Form::validate()
*/
public function validate($callHooks = true) {
$this->addCheck(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks should be added in the form constructor, not the call to validate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we need to init the ithenticate service to test the given creds, using the getData in constructor does not work and pass null . well fixed it using $request->getUserVar and moved it to constructor .


msgid "plugins.generic.plagiarism.manager.settings.areForced"
msgstr "iThenticate settings were found in config.inc.php and the settings here will not be used."

msgid "plugins.generic.plagiarism.errorMessage"
msgstr "Upload of submission {$submissionId} to iThenticate failed with error: {$errorMessage}"

msgid "plugins.generic.plagiarism.submission.checklist.eula"
msgstr "Plagiarism EULA <a target=\"_blank\" href=\"{$localizedEulaUrl}\">link</a>"
Copy link
Member

@asmecher asmecher Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be iThenticate EULA, not Plagiarism EULA, I think


msgid "plugins.generic.plagiarism.manager.settings.serviceAccessInvalid"
msgstr ""
"The specified API URL/KEY is invalid and can not establish connection to IThenticate API service."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be iThenticate, not IThenticate

@touhidurabir
Copy link
Member Author

@asmecher ready for next review round . forced to have the vital implementation in webhook handler as no other way . Also as we get submission id from ithenticate for each submission file , moved some the association to submission file setting .

@asmecher
Copy link
Member

Another issue to resolve: Try editing config.inc.php and setting Installed to Off. This will cause the installation to give an error:

PHP Fatal error:  Uncaught Error: Undefined constant "SCHEMA_SUBMISSION" in /home/asmecher/git/ojs-stable-3_3_0/plugins/generic/plagiarism/PlagiarismPlugin.inc.php:95

...rather than sending the user to the installation form.

@touhidurabir
Copy link
Member Author

Another issue to resolve: Try editing config.inc.php and setting Installed to Off. This will cause the installation to give an error:

PHP Fatal error:  Uncaught Error: Undefined constant "SCHEMA_SUBMISSION" in /home/asmecher/git/ojs-stable-3_3_0/plugins/generic/plagiarism/PlagiarismPlugin.inc.php:95

...rather than sending the user to the installation form.

@asmecher please the commit touhidurabir@6042142 . This resolve the above issue along with #49 but updated the behaviour a bit as follow

  1. Admin must set the ithenticate to On in config.inc.php file to enable the service/plugin globally .
  2. Admin/Journal Manager enable the plugin from plugin gallery for the given context and once it's done, the enable/disable checkbox will grey out . This also resolve issue Enabling the plugin impossible if settings are present in config file when plugin is first installed #49 .

However I still think there is room for more improvement . With our current implementation, it is impossible to disable the plugin once enabled without globally disable it by setting ithenticate to Off in config.inc.php file . This is ok for a single context based installation but does not seems flexible for a multi context based installation .

For example , in a multi context based installation, may be the JM/Admin want to disable it for one specific context for some reason but no way to do it . My proposal is to remove the plugin based implementation of getCanEnable and getCanDisable so that JM/Admin can anytime disable/enable the plugin for a given context . And if needed to disable it globally , they still has the option to do it from config.inc.php file by setting the ithenticate to Off . what you say ?

@touhidurabir touhidurabir merged commit d6b08c5 into pkp:stable-3_3_0 Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants