Skip to content

Commit

Permalink
pkp#9453 Let reviewers view their recommendations for previous rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
nibou230 committed Nov 21, 2023
1 parent 80eb1bc commit 7f9de49
Show file tree
Hide file tree
Showing 9 changed files with 472 additions and 0 deletions.
29 changes: 29 additions & 0 deletions classes/log/SubmissionEmailLogDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,35 @@ public function getBySubmissionId($submissionId)
return $this->getByAssoc(Application::ASSOC_TYPE_SUBMISSION, $submissionId);
}

/**
* Get submission email log entries by submission ID, event type and sender ID
*
* @param int $submissionId
* @param int $eventType SubmissionEmailLogEntry::SUBMISSION_EMAIL_*
* @param int $senderId Return only emails sent by this user.
*
* @return DAOResultFactory<SubmissionEmailLogEntry>
*/
function getBySenderId($submissionId, $eventType, $senderId) {
$result = $this->retrieveRange(
'SELECT e.*
FROM email_log e
WHERE
e.assoc_type = ? AND
e.assoc_id = ? AND
e.event_type = ? AND
e.sender_id = ?',
[
Application::ASSOC_TYPE_SUBMISSION,
(int) $submissionId,
(int) $eventType,
(int) $senderId
]
);

return new DAOResultFactory($result, $this, 'build');
}

/**
* Create a log entry from data in a Mailable class
*
Expand Down
145 changes: 145 additions & 0 deletions controllers/review/ReviewRoundModalHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?php

/**
* @defgroup controllers_review Review Handlers
*/

/**
* @file controllers/review/ReviewRoundModalHandler.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2021 Université Laval
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ReviewRoundModalHandler
* @ingroup controllers_review
*
* @brief Reviewer review round info handler.
*/

namespace PKP\controllers\review;

use APP\facades\Repo;
use APP\handler\Handler;
use APP\template\TemplateManager;
use Exception;
use PKP\core\JSONMessage;
use PKP\core\PKPRequest;
use PKP\log\SubmissionEmailLogEntry;
use PKP\security\authorization\RoleBasedHandlerOperationPolicy;
use PKP\db\DAORegistry;
use PKP\security\Role;

class ReviewRoundModalHandler extends Handler
{
/**
* Constructor
*/
function __construct()
{
parent::__construct();

$this->addRoleAssignment(
[Role::ROLE_ID_REVIEWER],
['viewRoundInfo', 'closeModal']
);
}

//
// Implement template methods from PKPHandler.
//

/**
* @copydoc PKPHandler::authorize()
*/
function authorize($request, &$args, $roleAssignments): bool
{
$this->addPolicy(new RoleBasedHandlerOperationPolicy(
$request,
[Role::ROLE_ID_REVIEWER],
['viewRoundInfo', 'close']
));

return parent::authorize($request, $args, $roleAssignments);
}

//
// Public operations
//

/**
* Display the review round info modal.
*
* @param array $args
* @param PKPRequest $request
*
* @return JSONMessage JSON object
* @throws Exception
*/
function viewRoundInfo($args, $request)
{
$this->setupTemplate($request);

$submission = Repo::submission()->get($args['submissionId']);
$submissionId = $submission->getId();
$reviewerId = $request->getUser()->getId();

$reviewAssignments = Repo::reviewAssignment()->getCollector()
->filterByReviewerIds([$reviewerId])
->getMany();
$declinedReviewAssignments = array();
foreach ($reviewAssignments as $submissionReviewAssignment) {
if ($submissionReviewAssignment->getDeclined() and $submissionId == $submissionReviewAssignment->getSubmissionId()) {
$declinedReviewAssignments[] = $submissionReviewAssignment;
}
}

$reviewAssignment = Repo::reviewAssignment()->getCollector()
->filterByReviewRoundIds([$args['reviewRoundId']])
->filterByReviewerIds([$reviewerId])
->filterByContextIds([$request->getContext()->getId()])
->getMany()
->first();
$submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
$reviewComments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignment->getId());

$reviewRoundNumber = $args['reviewRoundNumber'];
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$emailLogs = $submissionEmailLogDao
->getBySenderId($submissionId, SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_DECLINE, $reviewerId)
->toArray();
$declineEmail = null;
$i = 0;
foreach ($declinedReviewAssignments as $declinedReviewAssignment) {
if (isset($emailLogs[$i]) && $reviewRoundNumber == $declinedReviewAssignment->getRound()) {
$declineEmail = $emailLogs[$i];
}
$i++;
}

$displayFilesGrid = true;
$lastReviewAssignment = Repo::reviewAssignment()->getCollector()
->filterBySubmissionIds([$submissionId])
->filterByReviewerIds([$reviewerId])
->filterByLastReviewRound(true)
->getMany()
->first();
if($lastReviewAssignment->getDeclined() == 1) {
$displayFilesGrid = false;
}

$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign([
'submission' => $submission,
'reviewAssignment' => $reviewAssignment,
'reviewRoundNumber' => $reviewRoundNumber,
'reviewRoundId' => $args['reviewRoundId'],
'reviewComments' => $reviewComments,
'declineEmail' => $declineEmail,
'displayFilesGrid' => $displayFilesGrid
]);

return $templateMgr->fetchJson('controllers/modals/reviewRound/reviewRound.tpl');
}
}
87 changes: 87 additions & 0 deletions controllers/review/linkAction/ReviewRoundModalLinkAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

/**
* @file controllers/review/linkAction/ReviewRoundModalLinkAction.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2021 Université Laval
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ReviewRoundModalLinkAction
*
* @ingroup controllers_review_linkAction
*
* @brief An action to show a modal with the information about a review round.
*/

namespace PKP\controllers\review\linkAction;

use APP\core\Request;
use Exception;
use PKP\core\PKPApplication;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use APP\facades\Repo;

class ReviewRoundModalLinkAction extends LinkAction
{
/** @var int The round number */
public int $_round;

/**
* Constructor
*
* @param Request $request
* @param int $submissionId The ID of the submission to present link for
* @param int $reviewRoundId The ID of the review round
* @param int $reviewRoundNumber The round number to show information about
* @throws Exception
*/
public function __construct($request, $submissionId, $reviewRoundId, $reviewRoundNumber)
{
$this->_round = $reviewRoundNumber;

$submission = Repo::submission()->get($submissionId);
$submissionTitle = $submission->getCurrentPublication()->getLocalizedTitle();
$router = $request->getRouter();
$actionArgs = [
'submissionId' => $submissionId,
'reviewRoundId' => $reviewRoundId,
'reviewRoundNumber' => $reviewRoundNumber
];

$ajaxModal = new AjaxModal(
$router->getDispatcher()->url(
$request,
PKPApplication::ROUTE_COMPONENT,
null,
'review.ReviewRoundModalHandler',
'viewRoundInfo',
null,
$actionArgs
),
__(
'reviewer.submission.reviewRound.info.modal.title',
[
'reviewRoundNumber' => $reviewRoundNumber,
'submissionTitle' => $submissionTitle
]
),
'modal_information'
);

// Configure the link action.
parent::__construct('viewRoundInfo', $ajaxModal);
}

/**
* Get the review round number.
*
* @return int
*/
function getRound(): int
{
return $this->_round;
}
}
18 changes: 18 additions & 0 deletions locale/en/reviewer.po
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ msgstr ""
"Upload files you would like the editor and/or author to consult, including "
"revised versions of the original review file(s)."

msgid "reviewer.submission.reviewRound.info"
msgstr "Read my former reviews: "

msgid "reviewer.submission.reviewRound.info.modal.title"
msgstr "Evaluation cycle {$reviewRoundNumber} : {$submissionTitle}"

msgid "reviewer.submission.reviewRound.info.history"
msgstr "Review history"

msgid "reviewer.submission.comments.authorAndEditor"
msgstr "Author and editor"

msgid "reviewer.submission.comments.editorOnly"
msgstr "Pour la rédaction seulement"

msgid "reviewer.submission.comments.review"
msgstr "Review"

msgid "reviewer.complete"
msgstr "Review Submitted"

Expand Down
18 changes: 18 additions & 0 deletions locale/fr_CA/reviewer.po
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ msgstr ""
"consulter, y compris les versions révisées des fichiers d'évaluation "
"originaux."

msgid "reviewer.submission.reviewRound.info"
msgstr "Consulter mes évaluations précédentes : "

msgid "reviewer.submission.reviewRound.info.modal.title"
msgstr "Évaluation cycle {$reviewRoundNumber} : {$submissionTitle}"

msgid "reviewer.submission.reviewRound.info.history"
msgstr "Historique d'évaluation"

msgid "reviewer.submission.comments.authorAndEditor"
msgstr "Pour l'auteur et la rédaction"

msgid "reviewer.submission.comments.editorOnly"
msgstr "Editor only"

msgid "reviewer.submission.comments.review"
msgstr "Évaluation"

msgid "reviewer.complete"
msgstr "Évaluation envoyée"

Expand Down
Loading

0 comments on commit 7f9de49

Please sign in to comment.