Changeset 7fc2072 in iPeer


Ignore:
Timestamp:
2012-12-06T16:05:43-08:00 (6 years ago)
Author:
Compass <pan.luo@…>
Branches:
3.1.x, dev, hotfix, master, pagodabox, ticket463
Children:
57ef617
Parents:
135d67e
Message:

fixed event_id issue caused by adding GroupEvent? relationship to EvaluationSubmission?

Location:
app/models
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • app/models/evaluation_mixeval.php

    r135d67e r7fc2072  
    203203    function getReceivedTotalScore($grpEventId=null, $evaluatee=null)
    204204    {
    205         //        return $this->find('grp_event_id=' . $grpEventId .
    206         //             ' AND evaluatee=' . $evaluatee,
    207         //             'AVG(score) AS received_total_score');
    208205        return $this->find('first', array(
    209206            'conditions' => array('grp_event_id' => $grpEventId, 'evaluatee' => $evaluatee),
     
    225222    function getReceivedTotalEvaluatorCount($grpEventId, $evaluatee)
    226223    {
    227         //return $this->find('grp_event_id='.$grpEventId.' AND evaluatee='.$evaluatee, 'COUNT(*) AS ttl_count');
    228224        return $this->find('count', array(
    229225            'conditions' => array('grp_event_id' => $grpEventId, 'evaluatee' => $evaluatee)
     
    377373
    378374        $data = array();
    379         foreach($list as $mark) {
     375        foreach ($list as $mark) {
    380376            if (!isset($data[$mark['EvaluationMixeval']['evaluatee']])) {
    381377                $data[$mark['EvaluationMixeval']['evaluatee']]['user_id'] = $mark['EvaluationMixeval']['evaluatee'];
     
    388384        }
    389385
    390         $sub = $evalSub->find('all', array('conditions' => array('event_id' => $eventId)));
     386        $sub = $evalSub->getEvalSubmissionsByEventId($eventId);
    391387        $event = $this->Event->find('first', array('conditions' => array('Event.id' => $eventId)));
    392388
    393         foreach($sub as $stu) {
     389        foreach ($sub as $stu) {
    394390            if (isset($data[$stu['EvaluationSubmission']['submitter_id']])) {
    395391                $diff = strtotime($stu['EvaluationSubmission']['date_submitted']) - strtotime($event['Event']['due_date']);
     
    401397        }
    402398
    403         foreach($data as $demo) {
     399        foreach ($data as $demo) {
    404400            if (!isset($demo['penalty'])) {
    405401                $data[$demo['user_id']]['penalty'] = 0;
  • app/models/evaluation_rubric.php

    r135d67e r7fc2072  
    383383
    384384        $data = array();
    385         foreach($list as $mark) {
     385        foreach ($list as $mark) {
    386386            if (!isset($data[$mark['EvaluationRubric']['evaluatee']])) {
    387387                $data[$mark['EvaluationRubric']['evaluatee']]['user_id'] = $mark['EvaluationRubric']['evaluatee'];
     
    394394        }
    395395
    396         $sub = $evalSub->find('all', array('conditions' => array('event_id' => $eventId)));
     396        $sub = $evalSub->getEvalSubmissionsByEventId($eventId);
    397397        $event = $this->Event->find('first', array('conditions' => array('Event.id' => $eventId)));
    398398
    399         foreach($sub as $stu) {
     399        foreach ($sub as $stu) {
    400400            if (isset($data[$stu['EvaluationSubmission']['submitter_id']])) {
    401401                $diff = strtotime($stu['EvaluationSubmission']['date_submitted']) - strtotime($event['Event']['due_date']);
     
    407407        }
    408408
    409         foreach($data as $demo) {
     409        foreach ($data as $demo) {
    410410            if (!isset($demo['penalty'])) {
    411411                $data[$demo['user_id']]['penalty'] = 0;
  • app/models/evaluation_simple.php

    r135d67e r7fc2072  
    529529        }
    530530
    531         $sub = $evalSub->find('all', array('conditions' => array('event_id' => $eventId)));
     531        $sub = $evalSub->getEvalSubmissionsByEventId($eventId);
    532532        $event = $this->Event->find('first', array('conditions' => array('Event.id' => $eventId)));
    533533        $template = $simp->find('first', array('conditions' => array('SimpleEvaluation.id' => $event['Event']['template_id'])));
  • app/models/evaluation_submission.php

    r135d67e r7fc2072  
    2626
    2727    /**
     28     * getEvalSubmissionsByEventId
     29     *
     30     * @param mixed $eventId event id
     31     *
     32     * @access public
     33     * @return void
     34     */
     35    function getEvalSubmissionsByEventId($eventId)
     36    {
     37        return $this->find('all', array(
     38            'conditions' => array($this->alias.'.event_id' => $eventId),
     39            'contain' => false,
     40        ));
     41    }
     42
     43    /**
    2844     * getEvalSubmissionByGrpEventIdSubmitter
    2945     *
     
    3652    function getEvalSubmissionByGrpEventIdSubmitter($grpEventId=null, $submitter=null)
    3753    {
    38         //return $this->find('grp_event_id='.$grpEventId.' AND submitter_id='.$submitter);
    3954        return $this->find('first', array(
    40             'conditions' => array('EvaluationSubmission.grp_event_id' => $grpEventId, 'EvaluationSubmission.submitter_id' => $submitter)
     55            'conditions' => array($this->alias.'.grp_event_id' => $grpEventId, $this->alias.'.submitter_id' => $submitter)
    4156        ));
    42 
    4357    }
    44 
    4558
    4659    /**
     
    5366     * @return void
    5467     */
    55     function getEvalSubmissionByEventIdSubmitter($eventId=null, $submitter=null)
     68    function getEvalSubmissionByEventIdSubmitter($eventId, $submitter)
    5669    {
    57         //return $this->find('event_id='.$eventId.' AND submitter_id='.$submitter);
    5870        return $this->find('first', array(
    59             'conditions' => array('event_id' => $eventId, 'submitter_id' => $submitter)
     71            'conditions' => array($this->alias.'.event_id' => $eventId, 'submitter_id' => $submitter),
     72            'contain' => false,
    6073        ));
    6174    }
     
    8295    }
    8396
    84 
    85 
    8697    /**
    8798     * daysLate
    8899     *
    89      * @param mixed $event          event
     100     * @param mixed $eventId        event id
    90101     * @param mixed $submissionDate submission date
    91102     *
     
    93104     * @return void
    94105     */
    95     function daysLate($event, $submissionDate)
     106    function daysLate($eventId, $submissionDate)
    96107    {
    97108        $days = 0;
    98         $dueDate = $this->Event->find('first', array('conditions' => array('Event.id' => $event), 'fields' => array('Event.due_date')));
     109        $dueDate = $this->Event->find('first', array('conditions' => array('Event.id' => $eventId), 'fields' => array('Event.due_date')));
    99110        $dueDate = $dueDate['Event']['due_date'];
    100111        $seconds = strtotime($dueDate) - strtotime($submissionDate);
     
    106117        return $days;
    107118    }
    108 
    109119
    110120    /**
     
    120130        return $this->find('count', array('conditions' => array('grp_event_id' => $grpEventId,)));
    121131    }
    122 
    123 
    124     // Deprecated: replaced by virtual field in event model
    125     /*function numCountInEventCompleted($eventId=null)
    126 {
    127 //        $condition = 'EvaluationSubmission.submitted = 1 AND EvaluationSubmission.event_id='.$eventId;
    128 //        $fields = 'Count(EvaluationSubmission.submitter_id) AS count';
    129 //        $joinTable = array(' LEFT JOIN groups_members as GroupMember ON GroupMember.user_id=EvaluationSubmission.submitter_id');
    130 //
    131 //       // return $this->find('all', $condition, $fields, null, null, null, null, $joinTable );
    132 //       return $this-> find('all', $condition, $fields, null, null, null, null );
    133             return $this->find('count', array(
    134                 'conditions' => array('EvaluationSubmission.submitted' => 1, 'EvaluationSubmission.event_id' => $eventId)
    135             ));
    136 
    137     }*/
    138132}
Note: See TracChangeset for help on using the changeset viewer.