jenkins-bot has submitted this change and it was merged. Change subject: Update proposals/view_reviews.html for new storage ......................................................................
Update proposals/view_reviews.html for new storage Change-Id: I1304b1f9251683f039b60f68761e0ef14e2911b0 --- M data/templates/proposals/view_reviews.html M src/Controllers/Proposals/View.php M src/Dao/Reviews.php 3 files changed, 94 insertions(+), 92 deletions(-) Approvals: BryanDavis: Looks good to me, approved jenkins-bot: Verified diff --git a/data/templates/proposals/view_reviews.html b/data/templates/proposals/view_reviews.html index ebbcccd..40290de 100644 --- a/data/templates/proposals/view_reviews.html +++ b/data/templates/proposals/view_reviews.html @@ -1,59 +1,74 @@ {% import _self as helpers %} -{% macro criteria( reviews, crit, ctx ) %} +{% macro criteria( reviews, ques, ctx, type ) %} {% import _self as helpers %} -{% set note = crit ~ '_note' %} <section class="panel panel-default"> <div class="panel-heading"> - <h3 class="panel-title">{{ ( 'review-' ~ crit )|message }}</h3> + <h3 class="panel-title">{{ ques.question_title|wikitext }}</h3> </div> <table class="table table-bordered table-hover table-condensed"> <thead> <tr> - <th>{{ 'summary-list-mean'|message }}</th> - <th>{{ 'summary-list-median'|message }}</th> - <th>{{ 'summary-list-range'|message }}</th> - <th>{{ 'summary-list-stddev'|message }}</th> + {% if type == 'score' %} + <th>{{ 'summary-list-mean'|message }}</th> + <th>{{ 'summary-list-median'|message }}</th> + <th>{{ 'summary-list-range'|message }}</th> + <th>{{ 'summary-list-stddev'|message }}</th> + {% elseif type == 'recommend' %} + <th>{{ 'form-yes'|message }}</th> + <th>{{ 'form-conditional'|message }}</th> + <th>{{ 'form-neutral'|message }}</th> + <th>{{ 'form-no'|message }}</th> + {% endif %} </tr> </thead> <tbody> - {{ helpers.stats( reviews, crit ) }} + {% if type == 'score' %} + {{ helpers.scorestats( reviews, ques.id ) }} + {% elseif type == 'recommend' %} + {{ helpers.recommendstats( reviews, ques.id ) }} + {% endif %} </tbody> </table> <section class="panel panel-default muted"> <div class="panel-heading"> - <a class="accordion-toggle collapsed" data-toggle="collapse" href="#{{ crit }}-notes"> + <a class="accordion-toggle collapsed" data-toggle="collapse" href="#{{ ques.id }}-notes"> <span class="text-muted">{{ 'reviews-notes'|message }}</span> </a> </div> - <div id="{{ crit }}-notes" class="panel-body panel-collapse collapse"> + <div id="{{ ques.id }}-notes" class="panel-body panel-collapse collapse"> <ul class="list-group"> - {% for review in reviews %} - {% if review[note] %} - <li class="list-group-item clearfix"> - {{ review[note] }} - {% if ctx.isadmin|default( false ) %} - <cite class="pull-right text-muted">— {{ review.reviewer_name }}</cite> - {% endif %} - </li> - {% endif %} - {% endfor %} + {{ helpers.comments( reviews, ques.id, ctx ) }} </ul> </div> </section> </section> {% endmacro %} -{% macro stats( reviews, name ) %} +{% macro comments( reviews, qid, ctx ) %} +{% for r in reviews %} + {% if r.question == qid and r.comments is not empty %} + <li class="list-group-item clearfix">{{ r.comments }} + {% if ctx.isadmin|default( false ) %} + <cite class="pull-right text-muted">— {{ r.reviewer_name }}</cite> + {% endif %} + </li> + {% endif %} +{% endfor %} +{% endmacro %} + +{% macro scorestats( reviews, qid ) %} {% import _self as helpers %} {% set scores = [] %} {% set sum = 0 %} {% set squares = 0 %} {% for review in reviews %} -{% set val = review[name] %} - {% set scores = scores|merge( [ val ] ) %} - {% set sum = sum + val %} - {% set squares = squares + ( val * val ) %} + {% if review.question == qid %} + {% set val = review.points %} + {% set scores = scores|merge( [ val ] ) %} + {% set sum = sum + val %} + {% set squares = squares + ( val * val ) %} + {% endif %} {% endfor %} <tr> <td class="text-right">{{ ( sum / scores|length )|number_format( 2 ) }}</td> @@ -63,20 +78,51 @@ </tr> {% endmacro %} +{% macro recommendstats( reviews, qid ) %} +{% set countyes = 0 %} +{% set countconditional = 0 %} +{% set countneutral = 0 %} +{% set countno = 0 %} +{% for review in reviews %} + {% if review.question == qid %} + {% if review.points == '-1' %} + {% set countno = countno + 1 %} + {% elseif review.points == '0' %} + {% set countneutral = countneutral + 1 %} + {% elseif review.points == '1' %} + {% set countconditional = countconditional + 1 %} + {% elseif review.points == '2' %} + {% set countyes = countyes + 1 %} + {% endif %} + {% endif %} +{% endfor %} +<tr> + <td class="text-right">{{ countyes }}</td> + <td class="text-right">{{ countconditional }}</td> + <td class="text-right">{{ countneutral }}</td> + <td class="text-right">{{ countno }}</td> +</tr> +{% endmacro %} + {% macro median( list, precision = 2 ) %} {% set midlow = ( list|length / 2 )|round( 1, 'floor') %} {% set midhi = ( list|length / 2 )|round( 1, 'ceil') %} {{ ( ( list[midlow] + list[midhi] ) / 2 )|number_format( precision ) }} {% endmacro %} -{% macro count( reviews, name, value ) %} -{% set count = 0 %} -{% for review in reviews %} - {% if review[name] == value %} - {% set count = count + 1 %} +{% macro reviewers( reviews, ctx ) %} +{% set revs = [] %} +{% for r in reviews %} + {% if r.reviewer_name not in revs %} + {% set revs = revs|merge( [ r.reviewer_name ] ) %} {% endif %} {% endfor %} -{{ count }} +<li>{{ revs|length }}</li> +{% if ctx.isadmin|default(false) %} + {% for rev in revs %} + <li class="text-muted">{{ rev }}</li> + {% endfor %} +{% endif %} {% endmacro %} {% spaceless %} @@ -91,62 +137,16 @@ <dl class="dl-horizontal"> <dt>{{ 'summary-list-reviewers'|message }}</dt> <dd><ul class="list-inline"> - <li>{{ reviews|length }}</li> - {% if isadmin|default(false) %} - {% for review in reviews %} - <li class="text-muted">{{ review.reviewer_name }}</li> - {% endfor %} - {% endif %} + {{ helpers.reviewers( reviews, _context ) }} </ul></dd> </dl> - {{ helpers.criteria( reviews, 'impact', _context ) }} - {{ helpers.criteria( reviews, 'innovation', _context ) }} - {{ helpers.criteria( reviews, 'ability', _context ) }} - {{ helpers.criteria( reviews, 'engagement', _context ) }} - <section class="panel panel-default"> - <div class="panel-heading"> - <h3 class="panel-title">{{ 'review-recommendation'|message }} - </div> - <table class="table table-bordered table-hover table-condensed"> - <thead> - <tr> - <th>{{ 'form-yes'|message }}</th> - <th>{{ 'form-conditional'|message }}</th> - <th>{{ 'form-neutral'|message }}</th> - <th>{{ 'form-no'|message }}</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{ helpers.count( reviews, 'recommendation', 2 ) }}</td> - <td>{{ helpers.count( reviews, 'recommendation', 1 ) }}</td> - <td>{{ helpers.count( reviews, 'recommendation', 0 ) }}</td> - <td>{{ helpers.count( reviews, 'recommendation', -1 ) }}</td> - </tr> - </tbody> - </table> - <section class="panel panel-default muted"> - <div class="panel-heading"> - <a class="accordion-toggle collapsed" data-toggle="collapse" href="#recommendation-notes"> - <span class="text-muted">{{ 'reviews-notes'|message }}</span> - </a> - </div> - <div id="recommendation-notes" class="panel-body panel-collapse collapse"> - <ul class="list-group"> - {% for review in reviews %} - {% if review.comments %} - <li class="list-group-item clearfix"> - {{ review.comments }} - {% if isadmin|default( false ) %} - <cite class="pull-right text-muted">— {{ review.reviewer_name }}</cite> - {% endif %} - </li> - {% endif %} - {% endfor %} - </ul> - </div> - </section> - </section> + {% for q in questions %} + {% if q.type == 'score' %} + {{ helpers.criteria( reviews, q, _context, 'score' ) }} + {% elseif q.type == 'recommend' %} + {{ helpers.criteria( reviews, q, _context, 'recommend' ) }} + {% endif %} + {% endfor %} </div> </section> </article> diff --git a/src/Controllers/Proposals/View.php b/src/Controllers/Proposals/View.php index aea430c..52b16a8 100644 --- a/src/Controllers/Proposals/View.php +++ b/src/Controllers/Proposals/View.php @@ -59,7 +59,8 @@ $this->view->setData( 'questions', $questions ); $userId = $this->authManager->getUserId(); - if ( $this->campaignsDao->isReviewer( $this->activeCampaign, $userId ) ) { + $isreviewer = $this->campaignsDao->isReviewer( $this->activeCampaign, $userId ); + if ( $isreviewer ) { $review = $this->reviewsDao->reviewByUser( $id ); $myReview = array(); if ( $review ) { @@ -79,7 +80,8 @@ // showing/hiding information based on the user's permissions. $this->addReviewsToView( $id ); } - + $this->view->setData( 'isreviewer', $isreviewer ); + $this->view->setData( 'isadmin', $this->authManager->isAdmin() ); $this->render( 'proposals/view.html' ); } diff --git a/src/Dao/Reviews.php b/src/Dao/Reviews.php index 9b76b0a..8068f6d 100644 --- a/src/Dao/Reviews.php +++ b/src/Dao/Reviews.php @@ -125,11 +125,11 @@ public function getReviews( $proposal ) { $sql = self::concat( - 'SELECT r.*, u.username as reviewer_name', - 'FROM reviews r', - 'LEFT OUTER JOIN users u on u.id = r.reviewer', - 'WHERE proposal = ?', - 'ORDER BY r.id' + 'SELECT ra.*, u.username as reviewer_name', + 'FROM review_answers ra,', + 'users u', + 'WHERE ra.reviewer = u.id', + 'AND ra.proposal = ?' ); return $this->fetchAll( $sql, array( $proposal ) ); } -- To view, visit https://gerrit.wikimedia.org/r/199313 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1304b1f9251683f039b60f68761e0ef14e2911b0 Gerrit-PatchSet: 8 Gerrit-Project: wikimedia/iegreview Gerrit-Branch: master Gerrit-Owner: Niharika29 <niharikakohl...@gmail.com> Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org> Gerrit-Reviewer: Niharika29 <niharikakohl...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits