Changeset 3c298ce in iPeer


Ignore:
Timestamp:
2012-12-20T13:10:36-08:00 (6 years ago)
Author:
Compass <pan.luo@…>
Branches:
3.1.x, dev, hotfix, master, pagodabox, ticket463
Children:
8687013
Parents:
3425550
git-author:
Compass <pan.luo@…> (12/20/2012 01:10:08 PM)
git-committer:
Compass <pan.luo@…> (12/20/2012 01:10:36 PM)
Message:

Fix a few bugs in mixeval result page

Location:
app
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • app/controllers/components/evaluation.php

    r3425550 r3c298ce  
    12751275                // no submissions
    12761276                if (!in_array($userId, $submissions)) {
    1277                     $inCompletedMembers[$pos++]=$user;
     1277                    $inCompletedMembers[$pos++] = $user;
     1278                }
     1279
     1280                // filter out the people who are not student, they should not get result
     1281                if ($user['Role'][0]['name'] != 'student') {
    12781282                    continue;
    12791283                }
     1284
     1285                // get the results for students
    12801286                $mixevalResult = $this->EvaluationMixeval->getResultsByEvaluatee($groupEventId, $userId);
    12811287                $evalResult[$userId] = $mixevalResult;
     
    12861292                $memberScoreSummary[$userId]['received_ave_score'] = ($memberScoreSummary[$userId]['received_count'] == 0 ?
    12871293                    0 : $memberScoreSummary[$userId]['received_total_score'] / $memberScoreSummary[$userId]['received_count']);
    1288 
    1289                 /*foreach ($mixevalResult as $row) {
    1290                     $evalMark = isset($row['EvaluationMixeval'])? $row['EvaluationMixeval']: null;
    1291                     if ($evalMark!=null) {
    1292                         $rubriDetail = $this->EvaluationMixevalDetail->getByEvalMixevalIdCritera($evalMark['id']);
    1293                         $evalResult[$userId][$userPOS++]['EvaluationMixeval']['details'] = $rubriDetail;
    1294                     }
    1295                 }*/
    1296 
    12971294            }
    12981295        }
     
    16481645
    16491646        //Get Detail information on Mixeval score
    1650         if ($displayFormat == 'Detail') {
    1651             $mixevalQuestion = $this->MixevalsQuestion->getQuestion($mixeval['Mixeval']['id']);
    1652             /*foreach ($mixevalQuestion as $row) {
    1653                 $row['MixevalsQuestion']['Description'] = $row['Description'];
    1654                 $question = $row['MixevalsQuestion'];
    1655                 $result['mixevalQuestion'][$question['question_num']] = $question;
    1656             }*/
    1657             $result['mixevalQuestion'] = $mixevalQuestion;
    1658             //$result['mixevalQuestion'] = $mixevalQuestion;
    1659         }
     1647        $mixevalQuestion = $this->MixevalsQuestion->getQuestion($mixeval['Mixeval']['id']);
     1648        $result['mixevalQuestion'] = $mixevalQuestion;
    16601649        $gradeReleaseStatus = $this->EvaluationMixeval->getTeamReleaseStatus($event['GroupEvent']['id']);
    16611650
  • app/controllers/evaluations_controller.php

    r3425550 r3c298ce  
    10061006            $formattedResult = $this->Evaluation->formatRubricEvaluationResult($event, $displayFormat);
    10071007            $this->set('rubric', $formattedResult['rubric']);
    1008             if (isset($formattedResult['groupMembers'])) {
    1009                 $this->set('groupMembers', $formattedResult['groupMembers']);
    1010             }
    1011             if (isset($formattedResult['groupMembersNoTutors'])) {
    1012                 $this->set('groupMembersNoTutors', $formattedResult['groupMembersNoTutors']);
    1013             }
    10141008            if (isset($formattedResult['reviewEvaluations'])) {
    10151009                $this->set('reviewEvaluations', $formattedResult['reviewEvaluations']);
     
    10661060                $this->set('reviewEvaluations', $formattedResult['reviewEvaluations']);
    10671061            }
    1068             if (isset($formattedResult['mixevalQuestion'])) {
    1069                 $this->set('mixevalQuestion', $formattedResult['mixevalQuestion']);
    1070             }
     1062
     1063            $this->set('mixevalQuestion', $formattedResult['mixevalQuestion']);
    10711064            $this->set('inCompletedMembers', $formattedResult['inCompletedMembers']);
    10721065            $this->set('scoreRecords', $formattedResult['scoreRecords']);
    1073             $this->set('memberScoreSummary', $formattedResult['memberScoreSummary']);
    10741066            $this->set('evalResult', $formattedResult['evalResult']);
    1075             $this->set('gradeReleaseStatus', $formattedResult['gradeReleaseStatus']);
    10761067
    10771068            // Set Penalty
     
    12761267        $groupEventId = $this->params['form']['group_event_id'];
    12771268        $reviewStatus = isset($this->params['form']['mark_reviewed'])? "mark_reviewed" : "mark_not_reviewed";
     1269        $display_format = $this->params['form']['display_format'];
    12781270
    12791271        //Get the target event
     
    13091301            }
    13101302        }
    1311         $this->redirect('viewEvaluationResults/'.$eventId.'/'.$groupId);
     1303        $this->redirect('viewEvaluationResults/'.$eventId.'/'.$groupId.'/'.$display_format);
    13121304    }
    13131305
  • app/views/evaluations/view_mixeval_evaluation_results.ctp

    r3425550 r3c298ce  
    11<?php
    2 $result = array();
    3 
    4 $aveScoreSum = 0;
    5 //This section will display the evaluatees' name
    6 //as display the average scores their peers gave them
    7 //for various criteria
    8 foreach ($groupMembersNoTutors as $member) {
    9     $score = 0;
    10     if (isset($memberScoreSummary[$member['User']['id']]['received_ave_score'])) {
    11         $totalScore = $memberScoreSummary[$member['User']['id']]['received_ave_score'];
    12         $penalty = number_format(($penalties[$member['User']['id']] / 100) * $totalScore, 2);
    13         $finalTotalScore = $totalScore - $penalty;
    14         $penalty > 0 ? $stringAddOn = ' - '."<font color=\"red\">".$penalty."</font> = ".number_format($finalTotalScore, 2) :
    15             $stringAddOn = '';
    16         $aveScoreSum += $finalTotalScore;
    17         $score = number_format($totalScore, 2).$stringAddOn;
     2$textQuestions = array();
     3foreach ($mixevalQuestion as $question) {
     4    if ($question['MixevalsQuestion']['question_type'] != 'S') {
     5        $textQuestions[] = $question;
    186    } else {
    19         $score = '-';
     7        $numberQuestions[] = $question;
    208    }
    21     $result[$member['User']['first_name']." ".$member['User']['last_name']] = $score;
    229}
     10$memberList = Set::combine($event, 'Member.{n}.id', 'Member.{n}.full_name');
     11$table = $this->Evaluation->getSummaryTable($memberList, $scoreRecords, $numberQuestions, $mixeval, $penalties);
    2312?>
    24 
    25 <div class="content-container">
    2613
    2714<!-- Render Event Info table -->
     
    3623    </tr>
    3724
    38     <?php foreach($result as $name => $score):?>
    39     <tr><td><?php echo $name?></td><td><?php echo $score?></td></tr>
     25    <?php foreach ($table as $row):?>
     26    <tr><td><?php echo $row[0]?></td><td><?php echo end($row)?></td></tr>
    4027    <?php endforeach; ?>
    4128
    42     <tr class="tablesummary">
    43         <td><?php __("Group Average:");?></td>
    44         <td><?php echo (empty($inCompletedMembers) ? number_format($aveScoreSum / count($groupMembers), 2) : '-')?></td>
    45     </tr>
    46     <tr align="center">
    47       <form name="evalForm" id="evalForm" method="POST" action="<?php echo $html->url('markEventReviewed') ?>">
    48               <input type="hidden" name="event_id" value="<?php echo $event['Event']['id']?>" />
    49               <input type="hidden" name="group_id" value="<?php echo $event['Group']['id']?>" />
    50               <input type="hidden" name="course_id" value="<?php echo $event['Event']['course_id']?>" />
    51               <input type="hidden" name="group_event_id" value="<?php echo $event['GroupEvent']['id']?>" />
    52               <input type="hidden" name="display_format" value="Basic" />
    53 
    54         <td colspan="<?php echo count($groupMembersNoTutors) +1; ?>">
    55     <?php if ($event['GroupEvent']['marked'] == "reviewed"): ?>
    56         <input class="reviewed" type="submit" name="mark_not_reviewed" value="<?php __('Mark Peer Evaluations as Not Reviewed')?>" />
    57     <?php else: ?>
    58         <input class="reviewed" type="submit" name="mark_reviewed" value="<?php __('Mark Peer Evaluations as Reviewed')?>" />
    59     <?php endif; ?>
    60         </td>
    61       </form>
    62     </tr>
     29    <tr><td colspan="2"><?php echo $this->Evaluation->getReviewButton($event, 'Basic')?></td></tr>
    6330</table>
    64 </div>
    65 
    66 </div>
  • app/views/evaluations/view_mixeval_evaluation_results_detail.ctp

    r3425550 r3c298ce  
    11<?php
    22$color = array("#FF3366","#ff66ff","#66ccff","#66ff66","#ff3333","#00ccff","#ffff33");
    3 $groupAve = 0;
    4 $groupAverage = array_fill(1, $mixeval['Mixeval']['lickert_question_max'], 0);
    53$averagePerQuestion = array();
    64$numberQuestions = array();
     
    1513$memberList = Set::combine($event, 'Member.{n}.id', 'Member.{n}.full_name');
    1614
    17 function array_avg($array) {
    18     if (empty($array)) {
    19         return 0;
    20     }
    21 
    22     return array_sum($array)/count($array);
    23 }
     15$summaryTableData = $this->Evaluation->getSummaryTable($memberList, $scoreRecords, $numberQuestions, $mixeval, $penalties);
     16$groupAvg = end(end($summaryTableData));
    2417
    2518echo $html->script('ricobase');
     
    3629
    3730<!-- summary table -->
    38 <form name="evalForm" id="evalForm" method="POST" action="<?php echo $html->url('markEventReviewed') ?>">
    39     <input type="hidden" name="event_id" value="<?php echo $event['Event']['id']?>" />
    40     <input type="hidden" name="group_id" value="<?php echo $event['Group']['id']?>" />
    41     <input type="hidden" name="course_id" value="<?php echo $event['Event']['course_id']?>" />
    42     <input type="hidden" name="group_event_id" value="<?php echo $event['GroupEvent']['id']?>" />
    43     <input type="hidden" name="display_format" value="Detail" />
    4431<table class="standardtable">
    4532    <?php echo $html->tableHeaders($this->Evaluation->getSummaryTableHeader($mixeval['Mixeval']['total_marks'], $mixevalQuestion));?>
    46     <?php echo $html->tableCells($this->Evaluation->getSummaryTable($memberList, $scoreRecords, $numberQuestions, $mixeval, $penalties));?>
    47     <tr align="center"><td colspan="<?php echo (count($numberQuestions) + 2); ?>">
    48         <?php
    49             if ($event['GroupEvent']['marked'] == "reviewed") {
    50                 echo "<input class=\"reviewed\" type=\"submit\" name=\"mark_not_reviewed\" value=\" ".__('Mark Peer Evaluations as Not Reviewed', true)."\" />";
    51             } else {
    52                 echo "<input class=\"reviewed\" type=\"submit\" name=\"mark_reviewed\" value=\" ".__('Mark Peer Evaluations as Reviewed', true)."\" />";
    53             }
    54         ?>
     33    <?php echo $html->tableCells($summaryTableData);?>
     34    <tr align="center">
     35        <td colspan="<?php echo (count($numberQuestions) + 2); ?>">
     36            <?php echo $this->Evaluation->getReviewButton($event, 'Detail')?>
    5537        </td>
    5638    </tr>
    5739</table>
    58 </form>
    5940<!-- end of summary table -->
    6041
     
    7455            $ave_deduction = number_format(array_avg($scores) * $penalties[$evaluteeId]/100, 2);
    7556            $ave_scaled = number_format(array_avg($scores) * (1 - $penalties[$evaluteeId]/100), 2);
    76             echo __("Number of Evaluator(s)", true).': '.count($scores)."<br/>";
    7757            echo __("Final Total", true).': '.number_format(array_sum($scores), 2);
    7858            $penalties[$evaluteeId] > 0 ? $penaltyAddOn = ' - '."<font color=\"red\">".$deduction."</font> = ".$scaled :
     
    9070                $ave_penaltyAddOn = '';
    9171            $memberAverageAve = number_format(array_sum($scores), 2);
    92             if ($memberAverageAve == $groupAve) {
     72            if ($memberAverageAve == $groupAvg) {
    9373                echo "&nbsp;&nbsp;<< ".__('Same Mark as Group Average', true)." >>";
    94             } else if ($memberAverageAve < $groupAve) {
     74            } else if ($memberAverageAve < $groupAvg) {
    9575                echo "&nbsp;&nbsp;<font color='#cc0033'><< ".__('Below Group Average', true)." >></font>";
    96             } else if ($memberAverageAve > $groupAve) {
     76            } else if ($memberAverageAve > $groupAvg) {
    9777                echo "&nbsp;&nbsp;<font color='#000099'><< ".__('Above Group Average', true)." >></font>";
    9878            }
  • app/views/helpers/evaluation.php

    r3425550 r3c298ce  
    11<?php
     2function array_avg($arr) {
     3    if (empty($arr)) {
     4        return 0;
     5    }
     6
     7    return array_sum($arr) / count(array_filter($arr, 'is_numeric'));
     8}
     9
    210class EvaluationHelper extends AppHelper {
    311    public $helpers = array('Html');
     
    2028    {
    2129        $totalScore = 0;
    22         foreach ($scoreRecords as $score) {
    23             $totalScore += array_sum($score);
    24         }
     30        $totalCounter = 0;
    2531        $table = array();
    2632
    2733        foreach ($scoreRecords as $evaluteeId => $scores) {
    2834            $tr = array();
    29             $total = array_sum($scores);
    30             $penalty = ($penalties[$evaluteeId] / 100) * $total;
    3135            $tr[] = $memberList[$evaluteeId];
    3236            foreach ($numberQuestions as $question) {
    3337                $tr[] = isset($scores[$question['MixevalsQuestion']['question_num']-1]) ?
    34                     $scores[$question['MixevalsQuestion']['question_num']-1] : 'N/A';
     38                    $scores[$question['MixevalsQuestion']['question_num']-1] : __('N/A', true);
    3539            }
    3640
    37             // find out penalties
    38             if ($penalty > 0) {
    39                 $tr[] = sprintf('%.2f - <font color="red">%.2f</font> = %.2f (%.2f%%)',
    40                     $total, $penalty, $total-$penalty, ($total-$penalty)/$mixeval['Mixeval']['total_marks']*100);
     41            // find out penalties for total column
     42            $filteredScore = array_filter($scores, 'is_numeric');
     43            if (empty($filteredScore)) {
     44                $tr[] = __('N/A', true);
    4145            } else {
    42                 $tr[] = sprintf('%.2f (%.2f%%)', $total, $total/$mixeval['Mixeval']['total_marks']*100);
     46                $total = array_sum($filteredScore);
     47                $penalty = ($penalties[$evaluteeId] / 100) * $total;
     48                if ($penalty > 0) {
     49                    $tr[] = sprintf('%.2f - <font color="red">%.2f</font> = %.2f (%.2f%%)',
     50                        $total, $penalty, $total-$penalty, ($total-$penalty)/$mixeval['Mixeval']['total_marks']*100);
     51                } else {
     52                    $tr[] = sprintf('%.2f (%.2f%%)', $total, $total/$mixeval['Mixeval']['total_marks']*100);
     53                }
     54                $totalScore += $total-$penalty;
     55                $totalCounter ++;
    4356            }
    4457            $table[] = $tr;
    4558        }
     59
     60        // group average row
    4661        $tr = array(__('Group Average', true));
    4762        foreach ($numberQuestions as $question) {
    48             $total = array_sum(Set::classicExtract($scoreRecords, '{n}.'.($question['MixevalsQuestion']['question_num']-1)));
    49             $tr[] = number_format($total/count($scoreRecords), 2);
     63            if ($totalCounter) {
     64                $avg = array_avg(Set::classicExtract($scoreRecords, '{n}.'.($question['MixevalsQuestion']['question_num']-1)));
     65                $tr[] = number_format($avg, 2);
     66            } else {
     67                // no values in the table
     68                $tr[] = __('N/A', true);
     69            }
    5070        }
    51         $tr[] = $totalScore;
     71        $tr[] = $totalCounter ? $totalScore/$totalCounter : __('N/A', true);
    5272        $table[] = $tr;
    5373
     
    138158                round(($total - $point)/$valuePerBall));
    139159    }
     160
     161    function getReviewButton($event, $displayFormat)
     162    {
     163        $button = '<form name="evalForm" id="evalForm" method="POST" action="'.$this->Html->url('markEventReviewed').'">'.
     164              '<input type="hidden" name="event_id" value="'.$event['Event']['id'].'" />'.
     165              '<input type="hidden" name="group_id" value="'.$event['Group']['id'].'" />'.
     166              '<input type="hidden" name="course_id" value="'.$event['Event']['course_id'].'" />'.
     167              '<input type="hidden" name="group_event_id" value="'.$event['GroupEvent']['id'].'" />'.
     168              '<input type="hidden" name="display_format" value="'.$displayFormat.'" />';
     169        if ($event['GroupEvent']['marked'] == "reviewed") {
     170            $button .= '<input class="reviewed" type="submit" name="mark_not_reviewed" value="'.__('Mark Peer Evaluations as Not Reviewed', true).'" />';
     171        } else {
     172            $button .= '<input class="reviewed" type="submit" name="mark_reviewed" value="'.__('Mark Peer Evaluations as Reviewed', true).'" />';
     173        }
     174        $button .= '</form>';
     175
     176        return $button;
     177    }
     178
    140179}
Note: See TracChangeset for help on using the changeset viewer.