Changeset 57ef617 in iPeer


Ignore:
Timestamp:
2012-12-06T16:34:50-08:00 (6 years ago)
Author:
Compass <pan.luo@…>
Branches:
3.1.x, dev, hotfix, master, pagodabox, ticket463
Children:
42f7955
Parents:
7fc2072
git-author:
Compass <pan.luo@…> (12/06/2012 04:28:07 PM)
git-committer:
Compass <pan.luo@…> (12/06/2012 04:34:50 PM)
Message:

moved EvaluationSubmission? find function into model and fixed the
event_id issue. refacted evaluation submission model

Location:
app
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • app/controllers/evaluations_controller.php

    r7fc2072 r57ef617  
    594594
    595595            // students can't submit again
    596             $submission = $this->EvaluationSubmission->find(
    597                 'all',
    598                 array(
    599                     'conditions' => array(
    600                         'event_id' => $eventId,
    601                         'submitter_id' => $this->Auth->user('id'),
    602                         'submitted' => '1'
    603                 )));
     596            $submission = $this->EvaluationSubmission->getEvalSubmissionByEventIdSubmitter($eventId, User::get('id'));
    604597            if (!empty($submission)) {
    605598                $this->Session->setFlash(__('Error: Survey has already been submitted', true));
  • app/models/evaluation_submission.php

    r7fc2072 r57ef617  
    3636    {
    3737        return $this->find('all', array(
    38             'conditions' => array($this->alias.'.event_id' => $eventId),
     38            'conditions' => array(
     39                $this->alias.'.event_id' => $eventId,
     40                $this->alias.'.submitted' => '1',
     41            ),
    3942            'contain' => false,
    4043        ));
     
    5356    {
    5457        return $this->find('first', array(
    55             'conditions' => array($this->alias.'.grp_event_id' => $grpEventId, $this->alias.'.submitter_id' => $submitter)
     58            'conditions' => array(
     59                $this->alias.'.grp_event_id' => $grpEventId,
     60                $this->alias.'.submitter_id' => $submitter,
     61                $this->alias.'.submitted' => '1',
     62            ),
    5663        ));
    5764    }
     
    6976    {
    7077        return $this->find('first', array(
    71             'conditions' => array($this->alias.'.event_id' => $eventId, 'submitter_id' => $submitter),
     78            'conditions' => array(
     79                $this->alias.'.event_id' => $eventId,
     80                $this->alias.'.submitter_id' => $submitter,
     81                $this->alias.'.submitted' => 1,
     82            ),
    7283            'contain' => false,
    7384        ));
     
    8899            array(
    89100                'conditions' => array(
    90                     'EvaluationSubmission.submitted' => 1,
    91                     'EvaluationSubmission.grp_event_id' => $groupEventId
     101                    $this->alias.'.submitted' => 1,
     102                    $this->alias.'.grp_event_id' => $groupEventId
    92103                ),
    93104            )
Note: See TracChangeset for help on using the changeset viewer.