$reviewAssignments */ protected function setupReviewerCommentsVariable(array $reviewAssignments, Submission $submission) { /** @var SubmissionCommentDAO $submissionCommentDao */ $submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO'); $reviewerNumber = 0; $comments = []; foreach ($reviewAssignments as $reviewAssignment) { $reviewerNumber++; $submissionComments = $submissionCommentDao->getReviewerCommentsByReviewerId( $submission->getId(), $reviewAssignment->getReviewerId(), $reviewAssignment->getId(), true ); $reviewerIdentity = $reviewAssignment->getReviewMethod() == ReviewAssignment::SUBMISSION_REVIEW_METHOD_OPEN ? $reviewAssignment->getReviewerFullName() : __('submission.comments.importPeerReviews.reviewerLetter', ['reviewerLetter' => $reviewerNumber]); $recommendation = $reviewAssignment->getLocalizedRecommendation(); $commentsBody = ''; /** @var SubmissionComment $comment */ while ($comment = $submissionComments->next()) { // If the comment is viewable by the author, then add the comment. if ($comment->getViewable()) { $commentsBody .= PKPString::stripUnsafeHtml($comment->getComments()); } } $comments[] = '

' . '' . $reviewerIdentity . '' . '
' . __('submission.recommendation', ['recommendation' => $recommendation]) . '

' . $commentsBody . $this->getReviewFormComments($reviewAssignment); } $this->addData([ static::$allReviewerComments => join('', $comments), ]); } protected function getReviewFormComments(ReviewAssignment $reviewAssignment): string { if (!$reviewAssignment->getReviewFormId()) { return ''; } /** @var ReviewFormElementDAO $reviewFormElementDao */ $reviewFormElementDao = DAORegistry::getDAO('ReviewFormElementDAO'); $reviewFormElements = $reviewFormElementDao->getByReviewFormId($reviewAssignment->getReviewFormId()); if ($reviewFormElements->wasEmpty()) { return ''; } /** @var ReviewFormResponseDAO $reviewFormResponseDao */ $reviewFormResponseDao = DAORegistry::getDAO('ReviewFormResponseDAO'); $comments = ''; while ($reviewFormElement = $reviewFormElements->next()) { if (!$reviewFormElement->getIncluded()) { continue; } /** @var ReviewFormResponse|null $reviewFormResponse */ $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewAssignment->getId(), $reviewFormElement->getId()); if (!$reviewFormResponse) { continue; } $comments .= PKPString::stripUnsafeHtml($reviewFormElement->getLocalizedQuestion()); $possibleResponses = $reviewFormElement->getLocalizedPossibleResponses(); // See issue #2437. if (in_array($reviewFormElement->getElementType(), [$reviewFormElement::REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES, $reviewFormElement::REVIEW_FORM_ELEMENT_TYPE_RADIO_BUTTONS])) { ksort($possibleResponses); $possibleResponses = array_values($possibleResponses); } if (in_array($reviewFormElement->getElementType(), $reviewFormElement->getMultipleResponsesElementTypes())) { if ($reviewFormElement->getElementType() == $reviewFormElement::REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES) { $comments .= ''; } else { $comments .= '

' . PKPString::stripUnsafeHtml($possibleResponses[$reviewFormResponse->getValue()]) . '

'; } } else { $comments .= '

' . nl2br(htmlspecialchars($reviewFormResponse->getValue())) . '

'; } } return $comments; } }