Skip to content

Commit

Permalink
pkp#1660 fixed issue with review read recommendation view
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Jan 10, 2025
1 parent 85de3aa commit 1964523
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,10 @@ public function readReview($args, $request)
ReviewAssignment::SUBMISSION_REVIEWER_RATING_POOR => str_repeat($starHtml, ReviewAssignment::SUBMISSION_REVIEWER_RATING_POOR),
ReviewAssignment::SUBMISSION_REVIEWER_RATING_VERY_POOR => str_repeat($starHtml, ReviewAssignment::SUBMISSION_REVIEWER_RATING_VERY_POOR),
],
'reviewerRecommendationOptions' => ReviewAssignment::getReviewerRecommendationOptions($context),
'reviewerRecommendationOptions' => ReviewAssignment::getReviewerRecommendationOptions(
context: $context,
reviewAssignment: $reviewAssignment
),
]);

if ($reviewAssignment->getReviewFormId()) {
Expand Down
27 changes: 19 additions & 8 deletions classes/submission/reviewAssignment/ReviewAssignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,12 @@ public function getWeeksDue()
*
* @return array recommendation => localizedTitle
*/
public static function getReviewerRecommendationOptions(?Context $context = null, ?bool $active = true): array
public static function getReviewerRecommendationOptions(
Context $context = null,
?bool $active = true,
?self $reviewAssignment = null
): array
{
$context ??= Application::get()->getRequest()->getContext();
static $reviewerRecommendationOptions = [];

if (!empty($reviewerRecommendationOptions)) {
Expand All @@ -811,6 +814,14 @@ public static function getReviewerRecommendationOptions(?Context $context = null
return $reviewerRecommendationOptions = ReviewerRecommendation::query()
->withContextId($context->getId())
->when(!is_null($active), fn ($query) => $query->withActive($active))
->when(
$reviewAssignment,
fn ($query) => $query->orWhere(
fn ($query) => $query->withRecommendation(
$reviewAssignment->getData("recommendation")
)
)
)
->get()
->mapWithKeys(
fn (ReviewerRecommendation $recommendation): array => [
Expand All @@ -824,13 +835,13 @@ public static function getReviewerRecommendationOptions(?Context $context = null
/**
* Return a localized string representing the reviewer recommendation.
*/
public function getLocalizedRecommendation(): string
public function getLocalizedRecommendation(?Context $context = null): string
{
$options = static::getReviewerRecommendationOptions();

return array_key_exists($this->getRecommendation(), $options)
? $options[$this->getRecommendation()]
: '';
$options = static::getReviewerRecommendationOptions(
$context ?? Application::get()->getRequest()->getContext()
);

return $options[$this->getRecommendation()] ?? '';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,9 @@ public function scopeWithActive(Builder $query, bool $active = true): Builder
{
return $query->where('status', $active);
}

public function scopeWithRecommendation(Builder $query, int $recommendation): Builder
{
return $query->where('value', $recommendation);
}
}

0 comments on commit 1964523

Please sign in to comment.