Changeset 2aec9c8 in iPeer


Ignore:
Timestamp:
2012-12-06T12:27:52-08:00 (6 years ago)
Author:
Compass <pan.luo@…>
Branches:
3.1.x, dev, hotfix, master, pagodabox, ticket463
Children:
b4fc9f8
Parents:
9030960
git-author:
Compass <pan.luo@…> (12/04/2012 01:06:51 PM)
git-committer:
Compass <pan.luo@…> (12/06/2012 12:27:52 PM)
Message:

Made the change in home page to handle the case that one student may be in two or
more groups in the same event. Added format date.

Location:
app
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • app/controllers/home_controller.php

    r9030960 r2aec9c8  
    5252            $submitted = $upcoming = array();
    5353            foreach ($events as $event) {
    54                 if (isset($event['EvaluationSubmission'][0])) {
     54                if (isset($event['EvaluationSubmission']['id'])) {
    5555                    $submitted[] = $event;
    5656                } else {
  • app/models/event.php

    r9030960 r2aec9c8  
    106106            'foreignKey' => 'event_id'
    107107        ),
    108         'EvaluationSubmission' =>
    109         array(
    110             'className' => 'EvaluationSubmission',
    111             'conditions' => '',
    112             'order' => '',
    113             'dependent' => true,
    114             'foreignKey' => 'event_id'
    115         ),
    116108        'Penalty' =>
    117109        array(
     
    562554                'Course',
    563555                'Group',
    564                 'EvaluationSubmission' => 'submitter_id = '.$userId,
    565556                'Penalty' => array(
    566557                    'conditions' => array(
     
    575566        ));
    576567
     568        // find submission separately, doesn't work in on query
     569        $submissions = $this->GroupEvent->EvaluationSubmission->find('all', array(
     570            'conditions' => array('grp_event_id' => Set::extract('/GroupEvent/id', $evaluationEvents), 'submitter_id' => $userId),
     571            'contain' => false,
     572        ));
     573
     574        foreach ($submissions as $submission) {
     575            foreach ($evaluationEvents as $key => $event) {
     576                if ($submission['EvaluationSubmission']['grp_event_id'] == $event['GroupEvent']['id']) {
     577                    $evaluationEvents[$key]['EvaluationSubmission'] = $submission['EvaluationSubmission'];
     578                }
     579            }
     580        }
     581
    577582        // find survey events
     583        $this->bindModel(array(
     584            'hasOne' => array(
     585                'EvaluationSubmission' => array('conditions' => array('EvaluationSubmission.submitter_id' => $userId))
     586        )));
    578587        $surveyEvents = $this->find('all', array(
    579588            'conditions' => array('event_template_type_id' => '3'),
    580589            'contain' => array(
    581590                'Course',
    582                 'EvaluationSubmission' => 'submitter_id = '.$userId,
     591                'EvaluationSubmission',
    583592            )
    584593        ));
    585594
     595        // clean up the empty EvaluationSubmissions, Cake put them in even if they are empty
     596        foreach ($surveyEvents as $key => $events) {
     597            if (!isset($events['EvaluationSubmission']['id']) || empty($events['EvaluationSubmission']['id'])) {
     598                unset($surveyEvents[$key]['EvaluationSubmission']);
     599            }
     600        }
     601
    586602        return array_merge($evaluationEvents, $surveyEvents);
    587603    }
  • app/models/group_event.php

    r9030960 r2aec9c8  
    3232        ),
    3333    );
     34
     35    public $hasMany = array(
     36        'EvaluationSubmission' => array(
     37            'className' => 'EvaluationSubmission',
     38            'conditions' => '',
     39            'order' => '',
     40            'dependent' => true,
     41            'foreignKey' => 'grp_event_id'
     42        ),
     43    );
     44
    3445
    3546    /**
  • app/views/home/student_index.ctp

    r9030960 r2aec9c8  
    2020    <td><?php echo $event['Group']['group_name']?></td>
    2121    <td><?php echo $event['Course']['course']?></td>
    22     <td><?php echo $event['Event']['due_date']?></td>
     22    <td><?php echo Toolkit::formatDate($event['Event']['due_date'])?></td>
    2323    <td><font color="<?php echo $event['Event']['due_in']>0 ? '' : 'red'?>">
    2424        <?php echo abs($event['Event']['due_in'])?>
     
    4646    <td><?php echo $html->link($event['Event']['title'], '/evaluations/makeEvaluation/'.$event['Event']['id'])?></td>
    4747    <td><?php echo $event['Course']['course']?></td>
    48     <td><?php echo $event['Event']['due_date']?></td>
     48    <td><?php echo Toolkit::formatDate($event['Event']['due_date'])?></td>
    4949    <td><font color="<?php echo $event['Event']['due_in']>0 ? '' : 'red'?>"><?php echo abs($event['Event']['due_in'])?></font></td>
    5050</tr>
     
    7979    <td><?php echo $event['Group']['group_name']?></td>
    8080    <td><?php echo $event['Course']['course']?></td>
    81     <td><?php echo $event['Event']['due_date']?></td>
    82     <td><?php echo $event['EvaluationSubmission'][0]['date_submitted']?></td>
     81    <td><?php echo Toolkit::formatDate($event['Event']['due_date'])?></td>
     82    <td><?php echo Toolkit::formatDate($event['EvaluationSubmission']['date_submitted'])?></td>
    8383</tr>
    8484<?php endforeach; ?>
Note: See TracChangeset for help on using the changeset viewer.