Skip to content

Commit b1fa541

Browse files
committed
Merge branch 'hotfix'
2 parents 421fbbf + 6f83ce0 commit b1fa541

File tree

109 files changed

+1885
-1369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1885
-1369
lines changed

app/config/core.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
$CWL['applicationID'] = '';
343343
$CWL['applicationPassword'] = '';
344344

345-
define('IPEER_VERSION', '3.0.0');
345+
define('IPEER_VERSION', '3.0.1');
346346

347347

348348
/**

app/config/sql/ipeer_samples_data.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ INSERT INTO `groups_members` VALUES (4, 1, 35);
792792
INSERT INTO `groups_members` VALUES (5, 2, 31);
793793
INSERT INTO `groups_members` VALUES (6, 2, 32);
794794
INSERT INTO `groups_members` VALUES (7, 2, 33);
795-
INSERT INTO `groups_members` VALUES (8, 2, 36);
795+
INSERT INTO `groups_members` VALUES (8, 2, 7);
796796

797797
-- --------------------------------------------------------
798798

app/controllers/components/TeamMaker

100644100755
File mode changed.

app/controllers/components/evaluation.php

+122-156
Large diffs are not rendered by default.
130 Bytes
Binary file not shown.

app/controllers/components/xml_handler.php

+40-62
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ class XmlHandlerComponent extends Object
1313
/**
1414
* makeTeamMakerXML
1515
*
16-
* @param mixed $survey survey
16+
* @param mixed $questions questions for make groups
17+
* @param mixed $responses user responses
1718
* @param mixed $numGroups number of groups
1819
* @param mixed $weight weight
1920
*
2021
* @access public
2122
* @return void
2223
*/
23-
function makeTeamMakerXML($survey, $numGroups, $weight, $eventId)
24+
function makeTeamMakerXML($questions, $responses, $numGroups, $weight)
2425
{
2526
if (phpversion() < 5) {
2627
$appendChildFunc = 'append_child';
@@ -41,73 +42,50 @@ function makeTeamMakerXML($survey, $numGroups, $weight, $eventId)
4142
$team_input = $doc->$createElementFunc('team_input');
4243
$team_input->$setAttributeFunc('num_groups', $numGroups);
4344
$doc->$appendChildFunc($team_input);
44-
foreach ($survey['Question'] as $q) {
45-
if (in_array($q['type'], array('M', 'C'))) {
46-
//questions
47-
$question = $doc->$createElementFunc('question');
48-
$question->$setAttributeFunc('id', $q['id']);
49-
$question->$setAttributeFunc('type', ($q['type'] == 'C' ? 'CAO':'MC'));
50-
$question->$setAttributeFunc('title', $q['prompt']);
51-
$team_input->$appendChildFunc($question);
45+
foreach ($questions as $q) {
46+
//questions
47+
$question = $doc->$createElementFunc('question');
48+
$question->$setAttributeFunc('id', $q['id']);
49+
$question->$setAttributeFunc('type', ($q['type'] == 'C' ? 'CAO':'MC'));
50+
$question->$setAttributeFunc('title', $q['prompt']);
51+
$team_input->$appendChildFunc($question);
5252

53-
//weight
54-
$element_weight = $doc->$createElementFunc('weight');
55-
$element_weight->$setAttributeFunc('value', $weight[$q['id']]);
56-
$question->$appendChildFunc($element_weight);
57-
}
53+
//weight
54+
$element_weight = $doc->$createElementFunc('weight');
55+
$element_weight->$setAttributeFunc('value', $weight[$q['id']]);
56+
$question->$appendChildFunc($element_weight);
5857
}
59-
$userData = $survey['Course']['Enrol'];
60-
foreach ($userData as $user) {
58+
59+
foreach ($responses as $user) {
6160
//students
6261
$student = $doc->$createElementFunc('student');
63-
$student->$setAttributeFunc('username', $user['student_no']);
62+
$student->$setAttributeFunc('username', $user['User']['id']);
6463
$team_input->$appendChildFunc($student);
6564

66-
foreach ($survey['Question'] as $q) {
67-
if (in_array($q['type'], array('M', 'C'))) {
68-
//response
69-
$response = $doc->$createElementFunc('response');
70-
$response->$setAttributeFunc('q_id', $q['id']);
71-
$response->$setAttributeFunc('type', ($q['type'] == 'C' ? 'CAO':'MC'));
72-
$student->$appendChildFunc($response);
65+
foreach ($questions as $q) {
66+
//response
67+
$response = $doc->$createElementFunc('response');
68+
$response->$setAttributeFunc('q_id', $q['id']);
69+
$response->$setAttributeFunc('type', ($q['type'] == 'C' ? 'CAO':'MC'));
70+
$student->$appendChildFunc($response);
7371

74-
$responses = $this->SurveyInput->getByEventIdUserIdQuestionId($eventId, $user['id'], $q['id']);
75-
//print_r($responses);
76-
if (count($responses) != 0) {
77-
for ($j=0; $j < count($responses); $j++) {
78-
$response_tmp = $responses[$j]['SurveyInput'];
79-
if ($response_tmp['response_text']==null && $response_tmp['response_id']==null) {
80-
//response/answer
81-
$value = $doc->$createElementFunc('value');
82-
$value->$setAttributeFunc('id', $response_tmp['id']);
83-
$value->$setAttributeFunc('answer',0);
84-
$response->$appendChildFunc($value);
85-
} elseif ($response_tmp['response_text']=='' || $response_tmp['response_text']==null) {
86-
//response/answer
87-
$value = $doc->$createElementFunc('value');
88-
$value->$setAttributeFunc('id', $response_tmp['id']);
89-
$value->$setAttributeFunc('answer',1);
90-
$response->$appendChildFunc($value);
91-
} else {
92-
//$mcResponse = explode('_', $response_tmp['response_text']);debug($mcResponse);
93-
//if (isset($mcResponse[0])) {
94-
// $mcTmp = $this->Response->read(null, $mcResponse[1]);
95-
// if ($mcTmp['Response']['response']==$mcResponse[0]) {
96-
//response/answer
97-
$value = $doc->$createElementFunc('value');
98-
$value->$setAttributeFunc('id', $response_tmp['id']);
99-
//$value->setAttribute('answer',1);
100-
$response->$appendChildFunc($value);
101-
// }
102-
//}
103-
}
104-
}
105-
} else {
106-
if ('M' == $q['type']) {
107-
$value = $doc->$createElementFunc('value');
108-
$value->$setAttributeFunc('id', '');
109-
$response->$appendChildFunc($value);
110-
}
72+
// TODO: handle CAO (checkbox questions. See the example xml in teammaker
73+
// source directory
74+
$responses = Set::extract($user, '/SurveyInput[question_id='.$q['id'].']');
75+
if (!empty($responses)) {
76+
foreach ($responses as $resp) {
77+
$response_tmp = $resp['SurveyInput'];
78+
//response/answer
79+
$value = $doc->$createElementFunc('value');
80+
$value->$setAttributeFunc('id', $response_tmp['response_id'] == null ? '':$response_tmp['response_id']);
81+
#$value->$setAttributeFunc('answer', 1);
82+
$response->$appendChildFunc($value);
83+
}
84+
} else {
85+
if ('M' == $q['type']) {
86+
$value = $doc->$createElementFunc('value');
87+
$value->$setAttributeFunc('id', '');
88+
$response->$appendChildFunc($value);
11189
}
11290
}
11391
}

app/controllers/courses_controller.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function edit($courseId)
265265
{
266266
$this->_initFormEnv();
267267

268-
$course = $this->Course->getAccessibleCourseById($courseId, User::get('id'), User::getCourseFilterPermission(), array('Instructor'));
268+
$course = $this->Course->getAccessibleCourseById($courseId, User::get('id'), User::getCourseFilterPermission(), array('Instructor', 'Department'));
269269
if (!$course) {
270270
$this->Session->setFlash(__('Error: Course does not exist or you do not have permission to view this course.', true));
271271
$this->redirect('index');
@@ -284,7 +284,6 @@ public function edit($courseId)
284284
}
285285

286286
$this->data = $course;
287-
$this->set('instructorSelected', Set::extract($course, '/Instructor/id'));
288287
$this->set('breadcrumb', $this->breadcrumb->push(array('course' => $course['Course']))->push(__('Edit Course', true)));
289288
}
290289

app/controllers/evaluations_controller.php

+30-62
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ function view($eventId = null)
190190
return;
191191
}
192192

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-
199193
// Survey Results are on a different page for now
200194
if ($event['Event']['event_template_type_id'] == 3) {
201195
$this->redirect("viewSurveySummary/$eventId");
@@ -397,9 +391,6 @@ function _makeSimpleEvaluation($event, $groupId)
397391
return;
398392
}
399393

400-
// students can submit again
401-
$submission = $this->EvaluationSubmission->getEvalSubmissionByEventIdGroupIdSubmitter($eventId, $groupId, User::get('id'));
402-
403394
$now = time();
404395
// students can't submit outside of release date range
405396
if ($now < strtotime($event['Event']['release_date_begin']) ||
@@ -409,6 +400,17 @@ function _makeSimpleEvaluation($event, $groupId)
409400
return;
410401
}
411402

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+
412414
//Get the target event
413415
$eventId = $this->Sanitize->paranoid($eventId);
414416
$event = $this->Event->getEventByIdGroupId($eventId, $groupId);
@@ -439,7 +441,10 @@ function _makeSimpleEvaluation($event, $groupId)
439441

440442
// enough points to distribute amongst number of members - 1 (evaluator does not evaluate him or herself)
441443
$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+
));
443448
$remaining = $simpleEvaluation['SimpleEvaluation']['point_per_member'] * $numMembers;
444449
// if ($in['points']) $out['points']=$in['points']; //saves previous points
445450
//$points_to_ratio = $numMembers==0 ? 0 : 1 / ($simpleEvaluation['SimpleEvaluation']['point_per_member'] * $numMembers);
@@ -540,22 +545,12 @@ function _makeSurveyEvaluation ($event)
540545
$this->set('survey_id', $survey_id);
541546

542547
// 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);
556551
$this->set('courseId', $courseId);
557552
$this->set('eventId', $event['Event']['id']);
558-
$this->set('questions', $result);
553+
$this->set('survey', $survey);
559554
$this->render('survey_eval_form');
560555

561556
} else {
@@ -632,14 +627,6 @@ function _makeRubricEvaluation ($event, $groupId)
632627
return;
633628
}
634629

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-
643630
// students can't submit outside of release date range
644631
$now = time();
645632

@@ -842,7 +829,6 @@ function _makeMixevalEvaluation ($event, $groupId)
842829
$this->set('courseId', $courseId);
843830
$this->set('title_for_layout', $this->Course->getCourseName($courseId, 'S').__(' > Evaluate Peers', true));
844831
$mixEvalDetail = $this->Evaluation->loadMixEvaluationDetail($event);
845-
$this->set('viewData', $this->Mixeval->compileViewDataShort($mixEvalDetail['mixeval'], $this));
846832
$this->set('data', $mixEvalDetail['mixeval']);
847833
$this->set('groupMembers', $mixEvalDetail['groupMembers']);
848834
$this->set('evaluateeCount', $mixEvalDetail['evaluateeCount']);
@@ -1343,21 +1329,6 @@ function markCommentRelease($param = null)
13431329
$this->redirect('/home');
13441330
}
13451331

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-
13611332
$this->autoRender = false;
13621333
if ($param !=null) {
13631334
$tok = strtok($param, ';');
@@ -1366,9 +1337,12 @@ function markCommentRelease($param = null)
13661337
$eventId = $this->params['form']['event_id'];
13671338
}
13681339

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+
}
13721346

13731347
switch ($event['Event']['event_template_type_id']) {
13741348
case "1":
@@ -1652,30 +1626,24 @@ function viewSurveySummary($eventId)
16521626

16531627
// Check that course is accessible by user
16541628
$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'));
16561630
if (!$course) {
16571631
$this->Session->setFlash(__('Error: Course does not exist or you do not have permission to view this course.', true));
16581632
$this->redirect('index');
16591633
}
16601634

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');
16621638
$formattedResult = $this->Evaluation->formatSurveyEvaluationSummary(
1663-
$survey['Survey']['id'], $eventId);
1639+
$survey['Survey']['id'], $eventId, $studentIds);
16641640

16651641
$this->set('questions', $formattedResult);
16661642
$this->set('breadcrumb',
16671643
$this->breadcrumb->push(array('course' => $course['Course']))
16681644
->push(array('survey' => $survey['Survey']))
16691645
->push(__('Summary', true)));
16701646

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-
);
16791647
$submissions = $this->SurveyInput->findAllByEventId($eventId);
16801648
// add submission status for each enroled user
16811649
foreach ($course['Enrol'] as $key => $student) {

app/controllers/events_controller.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ function setUpAjaxList($courseId = null)
101101
array("!Custom.results", __("View", true), "4em", "action", "View Results"),
102102
array("Event.event_template_type_id", __("Type", true), "", "map",
103103
array(
104-
"1" => __("Simple", true),
105-
"2" => __("Rubric", true),
106-
"3" => __("Survey", true),
104+
"1" => __("Simple", true),
105+
"2" => __("Rubric", true),
106+
"3" => __("Survey", true),
107107
"4" => __("Mixed", true))),
108108
array("Event.due_date", __("Due Date", true), "10em", "date"),
109109
array("!Custom.isReleased", __("Released ?", true), "8em", "string"),
@@ -326,6 +326,9 @@ function add($courseId)
326326
} else if ($typeId == 2) {
327327
$this->data['Event']['template_id'] =
328328
$this->data['Event']['Rubric'];
329+
} else if ($typeId == 3) {
330+
$this->data['Event']['template_id'] =
331+
$this->data['Event']['Survey'];
329332
} else if ($typeId == 4) {
330333
$this->data['Event']['template_id'] =
331334
$this->data['Event']['Mixeval'];

app/controllers/framework_controller.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function calendarDisplay($datetime = '', $id='')
5252
}
5353

5454

55+
// Deprecated. It's the same as users/view.
5556
/**
5657
* userInfoDisplay
5758
*
@@ -60,7 +61,7 @@ function calendarDisplay($datetime = '', $id='')
6061
* @access public
6162
* @return void
6263
*/
63-
function userInfoDisplay($id)
64+
/*function userInfoDisplay($id)
6465
{
6566
$this->AccessControl->check('functions/user', 'read');
6667
@@ -105,7 +106,7 @@ function userInfoDisplay($id)
105106
$this->autoRender = false;
106107
$this->set('user', $this->data);
107108
$this->render("userinfo");
108-
}
109+
}*/
109110

110111

111112
/**

0 commit comments

Comments
 (0)