Changeset 57c4d8a in iPeer


Ignore:
Timestamp:
2012-12-23T14:05:43-08:00 (6 years ago)
Author:
Compass <pan.luo@…>
Branches:
3.1.x, dev, hotfix, master, pagodabox, ticket463
Children:
0462ffe
Parents:
7e9f21e
Message:

Merge event header in table in export

Location:
app
Files:
3 edited

Legend:

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

    r7e9f21e r57c4d8a  
    7777
    7878    /**
    79      * generateHeader
    80      *
    81      * @param mixed $params params
    82      * @param mixed $event  event
    83      *
    84      * @access public
    85      * @return void
    86      */
    87     function generateHeader($params, $event)
    88     {
    89         $header = '';
    90 
    91         if (!empty($params['include_course']) || !empty($params['include_eval_event_names'])) {
    92             $header .= "********************************************\n";
    93             if (!empty($params['include_course'])) {
    94                 $header .= "Course Name : ,,".$event['Course']['title']."\n";
    95             }
    96             if (!empty($params['include_eval_event_names'])) {
    97                 $header .= "Event : ,,".$event['Event']['title']."\n";
    98             }
    99         }
    100         if (!empty($params['include_eval_event_type'])) {
    101             $header .= "Evaluation Type : ,,".$this->eventType[$event['Event']['event_template_type_id']]."\n\n";
    102         }
    103         if (!empty($params['include_date'])) {
    104             $header .= "Date : ,,".date("F j Y g:i a")."\n";
    105         }
    106         if (!empty($params['include_instructors'])) {
    107             $header .= "Instructors :,,";
    108             foreach ($event['Course']['Instructor'] as $i) {
    109                 $header .= $i['full_name'].",";
    110             }
    111         }
    112 
    113         $header .= "\n********************************************\n";
    114         return $header;
    115     }
    116 
    117     /**
    11879     * buildEvaluationScoreTableByGroup
    11980     *
     
    191152        foreach ($group['Member'] as $evaluator) {
    192153            $row = array();
     154            if (!empty($params['include']['course'])) {
     155                array_push($row, $event['Course']['course']);
     156            }
     157            if (!empty($params['include']['eval_event_names'])) {
     158                array_push($row, $event['Event']['title']);
     159            }
     160            if (!empty($params['include']['eval_event_type'])) {
     161                array_push($row, $this->eventType[$event['Event']['event_template_type_id']]);
     162            }
    193163            if (!empty($params['include']['group_names'])) {
    194164                array_push($row, $group['Group']['group_name']);
  • app/controllers/components/export_csv.php

    r7e9f21e r57c4d8a  
    7272    }
    7373
    74 
    75     /**
    76      * creteCsvSubHeaderHelper
    77      *
    78      * @param mixed $params     params
    79      * @param mixed &$subHeader sub header
    80      *
    81      * @access public
    82      * @return void
    83      */
    84     function creteCsvSubHeaderHelper($params, &$subHeader)
    85     {
    86         if (!empty($params['include']['group_names'])) {
    87             $subHeader .= "Group Name, ";
    88         }
    89         if (!empty($params['include']['student_email'])) {
    90             $subHeader .= "Email, ";
    91         }
    92         if (!empty($params['include']['student_name'])) {
    93             $subHeader .= "Evaluatee, ";
    94         }
    95         if (!empty($params['include']['student_id'])) {
    96             $subHeader .= "Evaluatee S#, ";
    97         }
    98         if (!empty($params['include']['student_name'])) {
    99             $subHeader .= "Evaluator, ";
    100         }
    101         if (!empty($params['include']['student_id'])) {
    102             $subHeader .= "Evaluator S#, ";
    103         }
    104     }
    105 
    10674    /**
    10775     * createCsvSubHeader
     
    11583    function createCsvSubHeader($params, $questions, $evalType)
    11684    {
    117         $subHeader = '';
    118         $this->creteCsvSubHeaderHelper($params, $subHeader);
    119 
    120         // comment header
    121         if ($evalType != 4 && $params['include']['comments']) {
    122             $subHeader .= 'Comment, ';
    123         }
    124 
    125         foreach ($questions as $key => $question) {
    126             if (isset($question['question_type'])) {
    127                 if ((isset($params['include']['grade_tables']) && $question['question_type'] == 'S') ||
    128                 (isset($params['include']['comments']) && $question['question_type'] == 'T')) {
    129                     $subHeader .= "Q".($key+1)." ( /".$question['multiplier']."), ";
    130                 }
    131             } else {
    132                 $subHeader .= "Q".($key+1)." ( /".$question['multiplier']."), ";
    133             }
    134         }
    135         $subHeader .= "Raw Score, Late Penalty";
    136 
    137         if (isset($params['include']['final_marks'])) {
    138             $subHeader .= ", Final Score";
    139         }
    140 
    141         return $subHeader;
    14285    }
    14386
     
    15598    {
    15699        $csv = '';
    157         $eventHeader = $this->generateHeader($params, $event);
    158         $csv = $eventHeader."\n";
    159100        $groupEvents = $event['GroupEvent'];
    160101        $groupEventIds = Set::extract($groupEvents, '/id');
     
    168109        $event = array_merge($event, $evaluation);
    169110
    170         $subHeader = $this->createCsvSubHeader($params, $event['Question'], $event['Event']['event_template_type_id']);
    171         $csv .= $subHeader."\n\n";
     111        $header = $this->generateHeader($params, $event);
     112
     113        $csv .= $header."\n\n";
    172114        $csv .= $this->buildEvaluationScoreTableByEvent($params, $event, $results);
    173115
    174116        return $csv;
     117    }
     118
     119    /**
     120     * generateHeader
     121     *
     122     * @param mixed $params params
     123     * @param mixed $event  event
     124     *
     125     * @access public
     126     * @return void
     127     */
     128    function generateHeader($params, $event)
     129    {
     130        $header = array();
     131
     132        if (!empty($params['include']['course'])) {
     133            $header[] = "Course Name";
     134        }
     135        if (!empty($params['include']['eval_event_names'])) {
     136            $header[] = "Event";
     137        }
     138        if (!empty($params['include']['eval_event_type'])) {
     139            $header[] = "Evaluation Type";
     140        }
     141
     142        if (!empty($params['include']['group_names'])) {
     143            $header[] = "Group Name";
     144        }
     145        if (!empty($params['include']['student_email'])) {
     146            $header[] = "Email";
     147        }
     148        if (!empty($params['include']['student_name'])) {
     149            $header[] = "Evaluatee";
     150        }
     151        if (!empty($params['include']['student_id'])) {
     152            $header[] = "Evaluatee S#";
     153        }
     154        if (!empty($params['include']['student_name'])) {
     155            $header[] = "Evaluator";
     156        }
     157        if (!empty($params['include']['student_id'])) {
     158            $header[] = "Evaluator S#";
     159        }
     160
     161        // comment header
     162        if ($event['Event']['event_template_type_id'] != 4 && $params['include']['comments']) {
     163            $header[] = 'Comment';
     164        }
     165
     166        foreach ($event['Question'] as $key => $question) {
     167            if (isset($question['question_type'])) {
     168                if ((isset($params['include']['grade_tables']) && $question['question_type'] == 'S') ||
     169                (isset($params['include']['comments']) && $question['question_type'] == 'T')) {
     170                    $header[] = "Q".($key+1)." ( /".$question['multiplier']."), ";
     171                }
     172            } else {
     173                $header[] = "Q".($key+1)." ( /".$question['multiplier']."), ";
     174            }
     175        }
     176        $header[] = "Raw Score";
     177        $header[] = "Late Penalty";
     178
     179        if (isset($params['include']['final_marks'])) {
     180            $header[] = "Final Score";
     181        }
     182
     183        return join(', ', $header);
    175184    }
    176185
  • app/views/evaluations/export.ctp

    r7e9f21e r57c4d8a  
    1919        <td>
    2020            <select name="event_id" class= "event_id">
    21             <?php if($fromEvent): ?>
     21            <?php if ($fromEvent): ?>
    2222            <option value="<?php echo $selectedEvent['Event']['id']?>"><?php echo $selectedEvent['Event']['title']?></option>
    2323            <?php else: ?>
    24                 <?php foreach($events as $e): ?>
     24                <?php foreach ($events as $e): ?>
    2525                    <option value="<?php echo $e['Event']['id']?>"><?php echo $e["Event"]["title"]?></option>
    2626                <?php endforeach; ?>
     
    3030    </tr>
    3131    <tr>
    32       <th colspan="2">Header</th>
     32      <th colspan="2">Evaluation Info</th>
    3333    </tr>
    3434    <tr>
    35       <td>Include Course Name:&nbsp;<font color="red">*</td><td><input type="checkbox" name="include_course" checked /></td>
     35      <td>Include Course Name:&nbsp;<font color="red">*</td><td><input type="checkbox" name="include[course]" checked /></td>
    3636    </tr>
    3737    <tr>
    38       <td>Include Event Name:&nbsp;<font color="red">*</td><td><input type="checkbox" name="include_eval_event_names" checked /></td>
     38      <td>Include Event Name:&nbsp;<font color="red">*</td><td><input type="checkbox" name="include[eval_event_names]" checked /></td>
     39    </tr>
     40    <!--<tr>
     41      <td>Include Date of Export:</td><td><input type="checkbox" name="include[date]" checked /></td>
    3942    </tr>
    4043    <tr>
    41       <td>Include Date of Export:</td><td><input type="checkbox" name="include_date" checked /></td>
     44      <td>Include Instructor Name:</td><td><input type="checkbox" name="include[instructors]" checked /></td>
     45    </tr>-->
     46    <tr>
     47      <td>Include Evaluation Type:</td><td><input type="checkbox" name="include[eval_event_type]" checked /></td>
    4248    </tr>
    4349    <tr>
    44       <td>Include Instructor Name:</td><td><input type="checkbox" name="include_instructors" checked /></td>
    45     </tr>
    46     <tr>
    47       <td>Include Evaluation Type:</td><td><input type="checkbox" name="include_eval_event_type" checked /></td>
    48     </tr>
    49     <tr>
    50       <th colspan="3">Body</th>
     50      <th colspan="3">Group and Result</th>
    5151    </tr>
    5252    <tr>
Note: See TracChangeset for help on using the changeset viewer.