Changeset b6d44ab in iPeer


Ignore:
Timestamp:
2012-12-24T14:50:09-08:00 (5 years ago)
Author:
Compass <pan.luo@…>
Branches:
3.1.x, dev, hotfix, master, pagodabox, ticket463
Children:
742d257
Parents:
557173a
Message:

Fix #441

Location:
app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • app/controllers/home_controller.php

    r557173a rb6d44ab  
    7979        }
    8080
    81         // format the 'due in' time interval for display 
     81        // format the 'due in' time interval for display
    8282        foreach ($events as &$types) {
    8383            foreach ($types as &$event) {
     
    121121            $minutes = (int) ($seconds / 60);
    122122            $seconds = $seconds % 60;
    123             $ret = $minutes . __(' minutes ', true) . $seconds 
     123            $ret = $minutes . __(' minutes ', true) . $seconds
    124124                . __(' seconds', true);
    125125        }
     
    127127            $hours = (int) ($seconds / 3600);
    128128            $minutes = (int) ($seconds % 3600 / 60);
    129             $ret = $hours . __(' hours ', true) . $minutes . 
     129            $ret = $hours . __(' hours ', true) . $minutes .
    130130                __(' minutes', true);
    131131        }
     
    135135    /**
    136136     * Helper to filter events into 3 different categories and to
    137      * discard inactive events. 
     137     * discard inactive events.
    138138     *
    139139     * The 3 categories are: Upcoming, Submitted, Expired
     
    141141     * - Upcoming are events that the user can still make submissions for.
    142142     * - Submitted are events that the user has already made a submission.
    143      * - Expired are events that the user hasn't made and can no longer make 
     143     * - Expired are events that the user hasn't made and can no longer make
    144144     * submissions, but they can still view results from their peers.
    145145     *
     
    153153     * into upcoming, submitted, and expired.
    154154     * */
    155     private function _splitSubmittedEvents($events) 
     155    private function _splitSubmittedEvents($events)
    156156    {
    157157        $submitted = $upcoming = $expired = array();
     
    163163            }
    164164            else if (!empty($event['EvaluationSubmission']) &&
    165                 strtotime('NOW') < 
     165                strtotime('NOW') <
    166166                strtotime($event['Event']['result_release_date_end'])
    167167            ) { // has submission and can or will be able to view results soon
     
    180180            }
    181181            else if (empty($event['EvaluationSubmission']) &&
    182                 strtotime('NOW') < 
     182                strtotime('NOW') <
    183183                strtotime($event['Event']['result_release_date_end'])
    184184            ) { // student did not do the survey within the allowed time
     
    187187            }
    188188        }
    189         return array('upcoming' => $upcoming, 
     189        return array('upcoming' => $upcoming,
    190190            'submitted' => $submitted,
    191191            'expired' => $expired
  • app/models/event.php

    r557173a rb6d44ab  
    552552     * Get evaluations and surveys assigned to the given user. Also gets the
    553553     * evaluation submission entries made by this specific user.
    554      * 
     554     *
    555555     * @param mixed $userId
    556556     *
     
    583583        ));
    584584
     585        // to find the surveys, we need to find the courses that user is enrolled in
     586        // can't use find('list') as we are query the conditions on HABTM
     587        $courses = $this->Course->find('all', array(
     588            'fields' => array('id'),
     589            'conditions' => array('Enrol.id' => $userId),
     590            'contain' => 'Enrol',
     591        ));
     592        $courseIds = Set::extract($courses, '/Course/id');
    585593        // find survey events based on the groups this user is in
    586594        $surveyEvents = $this->find('all', array(
    587             'conditions' => array('event_template_type_id' => '3'),
     595            'conditions' => array('event_template_type_id' => '3', 'course_id' => $courseIds),
    588596            'order' => array('due_in ASC'),
    589597            'contain' => array(
     
    595603        ));
    596604
    597         return array('Evaluations' => $evaluationEvents, 
     605        return array('Evaluations' => $evaluationEvents,
    598606            'Surveys' => $surveyEvents);
    599607    }
  • app/tests/cases/models/event.test.php

    r557173a rb6d44ab  
    275275    }
    276276
     277    function testGetEventsByUserId()
     278    {
     279        $events = $this->Event->getEventsByUserId(5);
     280        $evaluations = $events['Evaluations'];
     281        $this->assertEqual(count($evaluations), 7);
     282        $surveys = $events['Surveys'];
     283        $this->assertEqual(count($surveys), 2);
     284
     285        $events = $this->Event->getEventsByUserId(27);
     286        $evaluations = $events['Evaluations'];
     287        $this->assertEqual(count($evaluations), 0);
     288        $surveys = $events['Surveys'];
     289        $this->assertEqual(count($surveys), 0);
     290    }
    277291
    278292    #####################################################################################################################################################
Note: See TracChangeset for help on using the changeset viewer.