@@ -190,12 +190,6 @@ function view($eventId = null)
190
190
return ;
191
191
}
192
192
193
- // for surveys, redirect to survey result page
194
- if (3 == $ event ['Event ' ]['event_template_type_id ' ]) {
195
- $ this ->redirect ('/surveygroups/viewresult/ ' .$ event ['Event ' ]['course_id ' ].'/ ' .$ eventId );
196
- return ;
197
- }
198
-
199
193
// Survey Results are on a different page for now
200
194
if ($ event ['Event ' ]['event_template_type_id ' ] == 3 ) {
201
195
$ this ->redirect ("viewSurveySummary/ $ eventId " );
@@ -397,9 +391,6 @@ function _makeSimpleEvaluation($event, $groupId)
397
391
return ;
398
392
}
399
393
400
- // students can submit again
401
- $ submission = $ this ->EvaluationSubmission ->getEvalSubmissionByEventIdGroupIdSubmitter ($ eventId , $ groupId , User::get ('id ' ));
402
-
403
394
$ now = time ();
404
395
// students can't submit outside of release date range
405
396
if ($ now < strtotime ($ event ['Event ' ]['release_date_begin ' ]) ||
@@ -409,6 +400,17 @@ function _makeSimpleEvaluation($event, $groupId)
409
400
return ;
410
401
}
411
402
403
+ // students can submit again
404
+ $ submission = $ this ->EvaluationSubmission ->getEvalSubmissionByEventIdGroupIdSubmitter ($ eventId , $ groupId , User::get ('id ' ));
405
+ if (!empty ($ submission )) {
406
+ // load the submitted values
407
+ $ evaluation = $ this ->EvaluationSimple ->getSubmittedResultsByGroupIdEventIdAndEvaluator ($ groupId , $ eventId , User::get ('id ' ));
408
+ foreach ($ evaluation as $ eval ) {
409
+ $ this ->data ['Evaluation ' ]['point ' .$ eval ['EvaluationSimple ' ]['evaluatee ' ]] = $ eval ['EvaluationSimple ' ]['score ' ];
410
+ $ this ->data ['Evaluation ' ]['comment_ ' .$ eval ['EvaluationSimple ' ]['evaluatee ' ]] = $ eval ['EvaluationSimple ' ]['comment ' ];
411
+ }
412
+ }
413
+
412
414
//Get the target event
413
415
$ eventId = $ this ->Sanitize ->paranoid ($ eventId );
414
416
$ event = $ this ->Event ->getEventByIdGroupId ($ eventId , $ groupId );
@@ -439,7 +441,10 @@ function _makeSimpleEvaluation($event, $groupId)
439
441
440
442
// enough points to distribute amongst number of members - 1 (evaluator does not evaluate him or herself)
441
443
$ numMembers = count ($ groupMembers );
442
- $ simpleEvaluation = $ this ->SimpleEvaluation ->find ('id= ' .$ event ['Event ' ]['template_id ' ]);
444
+ $ simpleEvaluation = $ this ->SimpleEvaluation ->find ('first ' , array (
445
+ 'conditions ' => array ('id ' => $ event ['Event ' ]['template_id ' ]),
446
+ 'contain ' => false ,
447
+ ));
443
448
$ remaining = $ simpleEvaluation ['SimpleEvaluation ' ]['point_per_member ' ] * $ numMembers ;
444
449
// if ($in['points']) $out['points']=$in['points']; //saves previous points
445
450
//$points_to_ratio = $numMembers==0 ? 0 : 1 / ($simpleEvaluation['SimpleEvaluation']['point_per_member'] * $numMembers);
@@ -540,22 +545,12 @@ function _makeSurveyEvaluation ($event)
540
545
$ this ->set ('survey_id ' , $ survey_id );
541
546
542
547
// Get all required data from each table for every question
543
- $ surveyQuestion = new SurveyQuestion ();
544
- $ tmp = $ surveyQuestion ->getQuestionsID ($ survey_id );
545
- $ tmp = $ this ->Question ->fillQuestion ($ tmp );
546
- $ tmp = $ this ->Response ->fillResponse ($ tmp );
547
- $ result = array ();
548
- // Sort the resultant array by question number
549
- for ($ i =0 ; $ i <=count ($ tmp ); $ i ++) {
550
- for ($ j =0 ; $ j <count ($ tmp ); $ j ++) {
551
- if ($ i == $ tmp [$ j ]['Question ' ]['number ' ]) {
552
- $ result []['Question ' ] = $ tmp [$ j ]['Question ' ];
553
- }
554
- }
555
- }
548
+ $ survey = $ this ->Survey ->getSurveyWithQuestionsById ($ survey_id );
549
+
550
+ $ this ->set ('event ' , $ event );
556
551
$ this ->set ('courseId ' , $ courseId );
557
552
$ this ->set ('eventId ' , $ event ['Event ' ]['id ' ]);
558
- $ this ->set ('questions ' , $ result );
553
+ $ this ->set ('survey ' , $ survey );
559
554
$ this ->render ('survey_eval_form ' );
560
555
561
556
} else {
@@ -632,14 +627,6 @@ function _makeRubricEvaluation ($event, $groupId)
632
627
return ;
633
628
}
634
629
635
- // students can submit again
636
- $ submission = $ this ->EvaluationSubmission ->getEvalSubmissionByEventIdGroupIdSubmitter ($ eventId , $ groupId , User::get ('id ' ));
637
- // if (!empty($submission)) {
638
- // $this->Session->setFlash(__('Error: Submissions had been made', true));
639
- // $this->redirect('/home/index');
640
- // return;
641
- // }
642
-
643
630
// students can't submit outside of release date range
644
631
$ now = time ();
645
632
@@ -842,7 +829,6 @@ function _makeMixevalEvaluation ($event, $groupId)
842
829
$ this ->set ('courseId ' , $ courseId );
843
830
$ this ->set ('title_for_layout ' , $ this ->Course ->getCourseName ($ courseId , 'S ' ).__ (' > Evaluate Peers ' , true ));
844
831
$ mixEvalDetail = $ this ->Evaluation ->loadMixEvaluationDetail ($ event );
845
- $ this ->set ('viewData ' , $ this ->Mixeval ->compileViewDataShort ($ mixEvalDetail ['mixeval ' ], $ this ));
846
832
$ this ->set ('data ' , $ mixEvalDetail ['mixeval ' ]);
847
833
$ this ->set ('groupMembers ' , $ mixEvalDetail ['groupMembers ' ]);
848
834
$ this ->set ('evaluateeCount ' , $ mixEvalDetail ['evaluateeCount ' ]);
@@ -1343,21 +1329,6 @@ function markCommentRelease($param = null)
1343
1329
$ this ->redirect ('/home ' );
1344
1330
}
1345
1331
1346
- $ tok = strtok ($ param , '; ' );
1347
- $ eventId = $ tok ;
1348
- $ groupId = strtok ('; ' );
1349
- $ evaluateeId = strtok ('; ' );
1350
- $ groupEventId = strtok ('; ' );
1351
- $ releaseStatus = strtok ('; ' );
1352
-
1353
- $ courseId = $ this ->Event ->getCourseByEventId ($ eventId );
1354
-
1355
- $ course = $ this ->Course ->getAccessibleCourseById ($ courseId , User::get ('id ' ), User::getCourseFilterPermission ());
1356
- if (!$ course ) {
1357
- $ this ->Session ->setFlash (__ ('Error: Course does not exist or you do not have permission to view this course. ' , true ));
1358
- $ this ->redirect ('index ' );
1359
- }
1360
-
1361
1332
$ this ->autoRender = false ;
1362
1333
if ($ param !=null ) {
1363
1334
$ tok = strtok ($ param , '; ' );
@@ -1366,9 +1337,12 @@ function markCommentRelease($param = null)
1366
1337
$ eventId = $ this ->params ['form ' ]['event_id ' ];
1367
1338
}
1368
1339
1369
- $ this ->Event ->id = $ eventId ;
1370
- $ event = $ this ->Event ->read ();
1371
-
1340
+ // Check whether the event exists or user has permission to access it
1341
+ if (!($ event = $ this ->Event ->getAccessibleEventById ($ eventId , User::get ('id ' ), User::getCourseFilterPermission (), array ()))) {
1342
+ $ this ->Session ->setFlash (__ ('Error: That event does not exist or you dont have access to it ' , true ));
1343
+ $ this ->redirect ('index ' );
1344
+ return ;
1345
+ }
1372
1346
1373
1347
switch ($ event ['Event ' ]['event_template_type_id ' ]) {
1374
1348
case "1 " :
@@ -1652,30 +1626,24 @@ function viewSurveySummary($eventId)
1652
1626
1653
1627
// Check that course is accessible by user
1654
1628
$ course = $ this ->Course ->getAccessibleCourseById (
1655
- $ event ['Event ' ]['course_id ' ], User::get ('id ' ), User::getCourseFilterPermission ());
1629
+ $ event ['Event ' ]['course_id ' ], User::get ('id ' ), User::getCourseFilterPermission (), array ( ' Enrol ' ) );
1656
1630
if (!$ course ) {
1657
1631
$ this ->Session ->setFlash (__ ('Error: Course does not exist or you do not have permission to view this course. ' , true ));
1658
1632
$ this ->redirect ('index ' );
1659
1633
}
1660
1634
1661
- // Prepare data to pass to view
1635
+ // Prepare data to pass to view, get current enrolled student Ids first
1636
+ // so that we can exclude the dropped students
1637
+ $ studentIds = Set::extract ($ course ['Enrol ' ], '/id ' );
1662
1638
$ formattedResult = $ this ->Evaluation ->formatSurveyEvaluationSummary (
1663
- $ survey ['Survey ' ]['id ' ], $ eventId );
1639
+ $ survey ['Survey ' ]['id ' ], $ eventId, $ studentIds );
1664
1640
1665
1641
$ this ->set ('questions ' , $ formattedResult );
1666
1642
$ this ->set ('breadcrumb ' ,
1667
1643
$ this ->breadcrumb ->push (array ('course ' => $ course ['Course ' ]))
1668
1644
->push (array ('survey ' => $ survey ['Survey ' ]))
1669
1645
->push (__ ('Summary ' , true )));
1670
1646
1671
- // Get enrolment data for the individual responses
1672
- $ course = $ this ->Course ->find (
1673
- 'first ' ,
1674
- array (
1675
- 'conditions ' => array ('id ' => $ course ['Course ' ]['id ' ]),
1676
- 'contain ' => array ('Enrol ' )
1677
- )
1678
- );
1679
1647
$ submissions = $ this ->SurveyInput ->findAllByEventId ($ eventId );
1680
1648
// add submission status for each enroled user
1681
1649
foreach ($ course ['Enrol ' ] as $ key => $ student ) {
0 commit comments