@@ -43,11 +43,11 @@ function createCSV($params) {
43
43
$ eventId = $ event ['Event ' ]['id ' ];
44
44
$ eventTemplateId = $ event ['Event ' ]['template_id ' ];
45
45
$ eventTypeId = $ event ['Event ' ]['event_template_type_id ' ];
46
- $ groupEvents = $ this ->GroupEvent ->findAll ('event_id= ' .$ eventId );
46
+ $ groupEvents = $ this ->GroupEvent ->findAll ('event_id= ' .$ eventId. ' AND group_id != 0 ' );
47
47
48
48
//too much garbage... outsourced to createBody
49
49
if (!empty ($ groupEvents )) {
50
- $ csvContent .= $ this ->createBody ($ event , $ groupEvents ,$ params ,$ eventTemplateId ,$ eventTypeId );
50
+ $ csvContent .= $ this ->createBody ($ event , $ groupEvents , $ params , $ eventTemplateId , $ eventTypeId );
51
51
}
52
52
}
53
53
@@ -90,19 +90,21 @@ function createBody ($event, $groupEvents,$params,$eventTemplateId,$eventTypeId)
90
90
$ this ->User = new User ;
91
91
$ this ->SimpleEvaluation = new SimpleEvaluation ;
92
92
$ this ->Rubric = new Rubric ;
93
- $ this ->Mixeval = new Mixeval ;
94
93
$ this ->RubricsCriteria = new RubricsCriteria ;
95
94
$ this ->MixEvalsQuestionDesc = new MixevalsQuestionDesc ;
96
95
$ this ->EvaluationSimple = new EvaluationSimple ;
97
96
$ this ->EvaluationRubric = new EvaluationRubric ;
98
97
$ this ->EvaluationMixeval = new EvaluationMixeval ;
98
+ $ this ->EvaluationMixevalDetail = new EvaluationMixevalDetail ;
99
+ $ this ->User = new User ;
99
100
$ mixedEvalNumeric = '' ;
100
101
101
102
$ globEventId = $ groupEvents [0 ]['GroupEvent ' ]['event_id ' ];
102
103
103
104
$ data = array ();
104
105
$ legends = array ();
105
106
$ i =0 ;
107
+
106
108
foreach ($ groupEvents as $ groupEvent ) {
107
109
//*******beef
108
110
$ groupId = $ groupEvent ['GroupEvent ' ]['group_id ' ];
@@ -113,37 +115,41 @@ function createBody ($event, $groupEvents,$params,$eventTemplateId,$eventTypeId)
113
115
//get group stati
114
116
$ data [$ i ]['group_status ' ] = $ groupEvent ['GroupEvent ' ]['marked ' ];
115
117
116
- $ groupMembers = $ this ->GroupsMembers ->getMembers ($ groupId );
117
- unset( $ groupMembers[ ' member_count ' ] );
118
+ // $groupMembers = $this->GroupsMembers->getMembers($groupId, null );
119
+ $ groupMembers = $ this -> User -> getGroupMembers ( $ groupId );
118
120
$ j =0 ;
119
121
$ data [$ i ]['students ' ] = array ();
120
122
121
123
global $ globUsersArr ;
122
124
foreach ($ groupMembers as $ groupMember ) {
123
- $ userId = $ groupMember ['GroupsMembers ' ]['user_id ' ];
124
- $ student = $ this ->User ->findUserByid ($ userId );
125
- $ globUsersArr [$ student ['User ' ]['student_no ' ]] = $ userId ;
125
+ $ userId = $ groupMember ['User ' ]['id ' ];
126
+ $ globUsersArr [] = $ userId ;
126
127
}
128
+
127
129
if (!empty ($ globUsersArr )) {
128
- $ incompletedArr = $ this ->buildIncompletedArr ();
130
+ $ incompletedArr = $ this ->buildIncompletedArr ($ groupEventId );
129
131
} else {
130
132
$ incompletedArr = array ();
131
133
}
134
+
132
135
$ count = 0 ;
133
- foreach ($ groupMembers as $ groupMember ) {
134
- if (in_array ($ groupMember ['GroupsMembers ' ]['user_id ' ], $ incompletedArr )) {
135
- $ count ++;
136
- }
136
+ foreach ($ groupMembers as $ key => $ groupMember ) {
137
+ if (in_array ($ groupMember ['User ' ]['id ' ], $ incompletedArr )) {
138
+ $ groupMembers [$ key ]['User ' ]['incomplete ' ] = true ;
139
+ $ count ++;
140
+ } else {
141
+ $ groupMembers [$ key ]['User ' ]['incomplete ' ] = false ;
142
+ }
137
143
}
138
144
139
145
foreach ($ groupMembers as $ groupMember ) {
140
146
//get student info: first_name, last_name, id, email
141
- $ userId = $ groupMember ['GroupsMembers ' ]['user_id ' ];
142
- $ student = $ this -> User -> findUserByid ( $ userId ) ;
143
- $ data [$ i ]['students ' ][$ j ]['student_id ' ] = $ student ['User ' ]['student_no ' ];
144
- $ data [$ i ]['students ' ][$ j ]['first_name ' ] = $ student ['User ' ]['first_name ' ];
145
- $ data [$ i ]['students ' ][$ j ]['last_name ' ] = $ student ['User ' ]['last_name ' ];
146
- $ data [$ i ]['students ' ][$ j ]['email ' ] = $ student ['User ' ]['email ' ];
147
+ $ userId = $ groupMember ['User ' ]['id ' ];
148
+ $ data [ $ i ][ ' students ' ][ $ j ][ ' student_id ' ] = $ groupMember [ ' User ' ][ ' student_no ' ] ;
149
+ $ data [$ i ]['students ' ][$ j ]['first_name ' ] = $ groupMember ['User ' ]['first_name ' ];
150
+ $ data [$ i ]['students ' ][$ j ]['last_name ' ] = $ groupMember ['User ' ]['last_name ' ];
151
+ $ data [$ i ]['students ' ][$ j ]['email ' ] = $ groupMember ['User ' ]['email ' ];
152
+ $ data [$ i ]['students ' ][$ j ]['incomplete ' ] = $ groupMember ['User ' ]['incomplete ' ];
147
153
148
154
switch ($ eventTypeId ) {
149
155
case 1 ://simple
@@ -154,7 +160,7 @@ function createBody ($event, $groupEvents,$params,$eventTemplateId,$eventTypeId)
154
160
}
155
161
$ data [$ i ]['students ' ][$ j ]['score ' ] = '' ;
156
162
$ score_tmp = $ this ->EvaluationSimple ->getReceivedTotalScore ($ groupEventId ,$ userId );
157
- /**
163
+ /**
158
164
* 6 in the group, 4 incompleted
159
165
* ----------------------------------------------
160
166
* | | self eval on | self eval off |
@@ -196,68 +202,62 @@ function createBody ($event, $groupEvents,$params,$eventTemplateId,$eventTypeId)
196
202
}
197
203
break ;
198
204
case 4 ://mixeval
205
+ // get the score
206
+ $ score_tmp = $ this ->EvaluationMixeval ->getReceivedTotalScore ($ groupEventId , $ userId );
207
+ $ data [$ i ]['students ' ][$ j ]['score ' ] = !isset ($ score_tmp [0 ]['received_total_score ' ])?'' :$ score_tmp [0 ]['received_total_score ' ];
199
208
200
- $ score_tmp = $ this ->EvaluationMixeval ->getReceivedTotalScore ($ groupEventId ,$ userId );
201
- #Text data for specific questions is inside the userResults variable
202
- $ userResults = $ this ->EvaluationMixeval ->getResultsDetailByEvaluatee ($ groupEventId ,$ userId );
203
- $ data [$ i ]['students ' ][$ j ]['score ' ] = !isset ($ score_tmp [0 ]['received_total_score ' ])?'' :$ score_tmp [0 ]['received_total_score ' ];
204
- $ data [$ i ]['students ' ][$ j ]['comments ' ] = '' ;
209
+ // Text data for specific questions is inside the userResults variable
210
+ $ userResults = $ this ->EvaluationMixevalDetail ->getResultsDetailByEvaluatee ($ groupEventId , $ userId );
211
+ $ data [$ i ]['students ' ][$ j ]['comments ' ] = '' ;
205
212
206
- #Here we add some generic information to the mixedEvalNumeric variable. First we add the name of the person being evaluated in this particular mixed eval(evaluatee)
207
- #then we sample index 0 of the userResults array to just get the number of numeric questions. Then we can make column headers for each question (1,2,3...)
208
- $ nameArray = $ this ->User ->findUserByid ($ userId );
209
- $ name =$ nameArray ['User ' ]['first_name ' ] . ' ' . $ nameArray ['User ' ]['last_name ' ];
210
- $ mixedEvalNumeric .= "\n" .$ name . ", " . $ data [$ i ]['group_name ' ] . "\n" ;
211
- $ tempEvaluatee = '' ;
212
- $ counter = 0 ;
213
-
214
- #go through userResults just to get the number of numeric questions.
215
- #YES we could combine this with the other loop but I'm running out of time and this is so much easier.
216
- foreach ($ userResults as $ comment ){
217
- if (!isset ($ comment ['EvaluationMiexevalDetail ' ]['question_comment ' ])){
218
- if (is_null ($ comment ['EvaluationMixevalDetail ' ]['question_comment ' ])){
213
+ //Here we add some generic information to the mixedEvalNumeric variable. First we add the name of the person being evaluated in this particular mixed eval(evaluatee)
214
+ //then we sample index 0 of the userResults array to just get the number of numeric questions. Then we can make column headers for each question (1,2,3...)
215
+ //$nameArray = $this->User->findUserByid($userId);
216
+ $ name = $ groupMember ['User ' ]['first_name ' ] . ' ' . $ groupMember ['User ' ]['last_name ' ];
217
+ $ mixedEvalNumeric .= "\n" .$ name . ", " . $ data [$ i ]['group_name ' ] . "\n" ;
218
+ $ tempEvaluatee = '' ;
219
+ $ mixedEvalNumeric .= "Evaluator, " ;
220
+
221
+ //go through userResults just to get the number of numeric questions.
222
+ $ counter = 1 ;
223
+ $ lastQ = 0 ;
224
+ foreach ($ userResults as $ comment ) {
225
+ if ($ lastQ > $ comment ['EvaluationMixevalDetail ' ]['question_number ' ]) {
226
+ break ;
227
+ }
228
+ //Here we create the columns for our .csv file, to be imported into excel
229
+ $ mixedEvalNumeric .= "Q $ counter " .", " ;
219
230
$ counter ++;
220
- } else {
221
- break ;
222
- }
231
+ $ lastQ = $ comment ['EvaluationMixevalDetail ' ]['question_number ' ];
223
232
}
224
233
225
- }
226
- #Here we create the columns for our .csv file, to be imported into excel
227
- $ mixedEvalNumeric .= ", " ;
228
- for ($ k = 1 ; $ k < $ counter +1 ; $ k ++) {
229
- $ mixedEvalNumeric .= "Q $ k " .", " ;
230
- }
231
- $ mixedEvalNumeric .= "\n" ;
232
- ##########
233
- foreach ($ userResults as $ comment ){
234
- $ results = $ this ->EvaluationMixeval ->find ('id= ' .$ comment ['EvaluationMixevalDetail ' ]['evaluation_mixeval_id ' ]);
235
-
236
- #Set some variables that hold the USER data for the evaluator and evaluatee, then set the names for convenience
237
- $ evaluatorArray = $ this ->User ->find ('id= ' .$ results ['EvaluationMixeval ' ]['evaluator ' ]);
238
- $ evaluatorName = $ evaluatorArray ['User ' ]['first_name ' ] . ' ' . $ evaluatorArray ['User ' ]['last_name ' ];
239
- $ evaluateeArray = $ this ->User ->find ('id= ' .$ results ['EvaluationMixeval ' ]['evaluatee ' ]);
240
- $ evaluateeName = $ evaluateeArray ['User ' ]['first_name ' ] . ' ' . $ evaluateeArray ['User ' ]['last_name ' ];
241
-
242
- #The $userResults variable is a long list of entries for EVERY evaluatee. If the evaluator changes, it means we are on a new 'survey' created by a different person.
243
- #Then we want to add a new line to our numeric data variable.
244
- if ($ evaluatorArray ['User ' ]['username ' ] != $ tempEvaluatee ){
245
- $ mixedEvalNumeric .= "\n" ;
246
- $ mixedEvalNumeric .= $ evaluatorName . ", " ;
247
- }
248
- #Set the temp variable
249
- $ tempEvaluatee = $ evaluatorArray ['User ' ]['username ' ];
234
+ foreach ($ userResults as $ comment ) {
235
+ //Set some variables that hold the USER data for the evaluator and evaluatee, then set the names for convenience
236
+ $ evaluatorArray = $ groupMembers [$ comment ['EvaluationMixeval ' ]['evaluator ' ]];
237
+ $ evaluatorName = $ evaluatorArray ['User ' ]['first_name ' ] . ' ' . $ evaluatorArray ['User ' ]['last_name ' ];
238
+ $ evaluateeName = $ groupMember ['User ' ]['first_name ' ].' ' .$ groupMember ['User ' ]['last_name ' ];
250
239
251
- #Here we go through the text responses for the mixed evaluation answers. If there is text content, we append it to the contents of the comments parameter for the evaluatee.
252
- $ data [$ i ]['students ' ][$ j ]['comments ' ] .= isset ($ comment ['EvaluationMixevalDetail ' ]['question_comment ' ])&&!empty ($ comment ['EvaluationMixevalDetail ' ]['question_comment ' ]) ? $ evaluatorName .' on ' .$ evaluateeName . ' Q ' .$ comment ['EvaluationMixevalDetail ' ]['question_number ' ] .' : ' .$ comment ['EvaluationMixevalDetail ' ]['question_comment ' ]."\n" .'' :'' ;
253
- if (!isset ($ comment ['EvaluationMixevalDetail ' ]['question_comment ' ])){
254
- $ mixedEvalNumeric .= trim ($ comment ['EvaluationMixevalDetail ' ]['grade ' ]).", " ;
240
+ //The $userResults variable is a long list of entries for EVERY evaluatee. If the evaluator changes, it means we are on a new 'survey' created by a different person.
241
+ //Then we want to add a new line to our numeric data variable.
242
+ if ($ comment ['EvaluationMixeval ' ]['evaluator ' ] != $ tempEvaluatee ) {
243
+ $ mixedEvalNumeric .= "\n" ;
244
+ $ mixedEvalNumeric .= $ evaluatorName . ", " ;
245
+ }
246
+ //Set the temp variable
247
+ $ tempEvaluatee = $ comment ['EvaluationMixeval ' ]['evaluator ' ];
248
+
249
+ //Here we go through the text responses for the mixed evaluation answers. If there is text content, we append it to the contents of the comments parameter for the evaluatee.
250
+ //$data[$i]['students'][$j]['comments'] .= isset($comment['EvaluationMixevalDetail']['question_comment'])&&!empty($comment['EvaluationMixevalDetail']['question_comment']) ? $evaluatorName.' on ' .$evaluateeName. ' Q'.$comment['EvaluationMixevalDetail']['question_number'] .' : '.$comment['EvaluationMixevalDetail']['question_comment']."\n".'':'';
251
+ if (!isset ($ comment ['EvaluationMixevalDetail ' ]['question_comment ' ])){
252
+ $ mixedEvalNumeric .= trim ($ comment ['EvaluationMixevalDetail ' ]['grade ' ]).", " ;
253
+ } else {
254
+ $ mixedEvalNumeric .= '" ' .trim ($ comment ['EvaluationMixevalDetail ' ]['question_comment ' ]).'" ' .", " ;
255
+ }
255
256
}
256
- }
257
- $ mixedEvalNumeric .= "\n" ;
258
- break ;
257
+ $ mixedEvalNumeric .= "\n" ;
258
+ break ;
259
259
default :
260
- break ;
260
+ break ;
261
261
}
262
262
$ j ++;
263
263
}
@@ -302,46 +302,48 @@ function formatBody($data, $params, $legends=null, $mixedEvalNumeric) {
302
302
for ($ i =1 ; $ i <= $ question_count ; $ i ++) {
303
303
$ content .= $ i .', ' ;
304
304
}
305
- $ content .= !isset ($ params ['form ' ]['include_general_comments ' ]) ? '' :'Comments ' ;
305
+ // $content .= !isset($params['form']['include_general_comments']) ? '':'Comments';
306
306
if ($ hasContent ) $ content .= "\n\n" ;
307
307
308
308
foreach ($ data as $ group ) {
309
- foreach ($ group ['students ' ] as $ student ) {
310
- if (!empty ($ params ['form ' ]['include_group_status ' ])) {
311
- $ incompletedArr = $ this ->buildIncompletedArr ();
312
- set_time_limit (1200 );
313
- if (array_key_exists ($ student ['student_id ' ], $ incompletedArr ) )
314
- $ content .= 'X, ' ;
315
- else
316
- $ content .= 'OK, ' ;
317
- }
318
- $ content .= empty ($ params ['form ' ]['include_group_names ' ]) ? '' :$ group ['group_name ' ].", " ;$ stuff =true ;
319
- $ content .= empty ($ params ['form ' ]['include_student_first ' ]) ? '' :"\"" .$ student ['first_name ' ]."\", " ;
320
- $ content .= empty ($ params ['form ' ]['include_student_last ' ]) ? '' :"\"" .$ student ['last_name ' ]."\", " ;
321
- $ content .= empty ($ params ['form ' ]['include_student_id ' ]) ? '' :$ student ['student_id ' ].", " ;
322
- $ content .= empty ($ params ['form ' ]['include_student_email ' ]) ? '' :"\"" .$ student ['email ' ]."\", " ;
323
- $ content .= empty ($ params ['form ' ]['include_criteria_marks ' ]) ? '' :$ student ['score ' ].", " ;
324
- $ content .= (empty ($ params ['form ' ]['include_criteria_legend ' ])||!isset ($ student ['sub_score ' ]))? '' :$ student ['sub_score ' ];
325
- $ content .= empty ($ params ['form ' ]['include_general_comments ' ]) ? '' : "\"" .str_replace ('" ' , '"" ' , $ student ['comments ' ])."\", " ;
309
+ foreach ($ group ['students ' ] as $ student ) {
310
+ if (!empty ($ params ['form ' ]['include_group_status ' ])) {
311
+ if ($ student ['incomplete ' ]) {
312
+ $ content .= 'X, ' ;
313
+ } else {
314
+ $ content .= 'OK, ' ;
315
+ }
316
+ }
317
+ $ content .= empty ($ params ['form ' ]['include_group_names ' ]) ? '' :$ group ['group_name ' ].", " ;$ stuff =true ;
318
+ $ content .= empty ($ params ['form ' ]['include_student_first ' ]) ? '' :"\"" .$ student ['first_name ' ]."\", " ;
319
+ $ content .= empty ($ params ['form ' ]['include_student_last ' ]) ? '' :"\"" .$ student ['last_name ' ]."\", " ;
320
+ $ content .= empty ($ params ['form ' ]['include_student_id ' ]) ? '' :$ student ['student_id ' ].", " ;
321
+ $ content .= empty ($ params ['form ' ]['include_student_email ' ]) ? '' :"\"" .$ student ['email ' ]."\", " ;
322
+ $ content .= empty ($ params ['form ' ]['include_criteria_marks ' ]) ? '' :$ student ['score ' ].", " ;
323
+ $ content .= (empty ($ params ['form ' ]['include_criteria_legend ' ])||!isset ($ student ['sub_score ' ]))? '' :$ student ['sub_score ' ];
324
+ $ content .= empty ($ params ['form ' ]['include_general_comments ' ]) ? '' : "\"" .str_replace ('" ' , '"" ' , $ student ['comments ' ])."\", " ;
326
325
326
+ if ($ hasContent ) $ content .= "\n" ;
327
+ }
327
328
if ($ hasContent ) $ content .= "\n" ;
328
- }
329
- if ($ hasContent ) $ content .= "\n" ;
330
329
}
331
330
####
332
- #Append the numeric mixed evaluation variable to the end of the .csv. This should be a list of tables for each evaluatee.
331
+ #Append the numeric mixed evaluation variable to the end of the .csv. This should be a list of tables for each evaluatee.
333
332
#This is not a good way of doing things, but it works.
334
333
$ content .= $ mixedEvalNumeric ;
335
- ###
334
+
336
335
return $ content ;
337
336
}
338
337
339
- function buildIncompletedArr () {
340
- global $ globEventId , $ globUsersArr ;
338
+ function buildIncompletedArr ($ groupEventId ) {
339
+ global $ globUsersArr ;
341
340
$ this ->EvalSubmission = new EvaluationSubmission ();
341
+ $ submitters = $ this ->EvalSubmission ->getSubmittersByGroupEventId ($ groupEventId );
342
342
foreach ($ globUsersArr as $ globUserStuNum =>$ globUserId ) {
343
- if ($ this ->EvalSubmission ->getEvalSubmissionByEventIdSubmitter ($ globEventId , $ globUserId ) != null )
344
- unset($ globUsersArr [$ globUserStuNum ]);
343
+ // if($this->EvalSubmission->getEvalSubmissionByEventIdSubmitter($globEventId, $globUserId) != null)
344
+ if (array_search ($ globUserId , $ submitters ) !== false ) {
345
+ unset($ globUsersArr [$ globUserStuNum ]);
346
+ }
345
347
}
346
348
return $ globUsersArr ;
347
349
}
0 commit comments