Skip to content

Commit 0e6ed3d

Browse files
committed
Merge branch '3.1.x'
2 parents 4043d95 + 7a0d1ec commit 0e6ed3d

40 files changed

+1096
-894
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.1.0');
345+
define('IPEER_VERSION', '3.1.1');
346346

347347

348348
/**

app/config/sql/delta_6b.sql

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
ALTER TABLE mixeval_question_descs DROP FOREIGN KEY mixeval_question_descs_ibfk_1;
88
ALTER TABLE mixeval_question_descs DROP KEY question_num;
9+
10+
-- Remove the orphan records before adding the foreign key so that it will not fail.
11+
DELETE FROM mixeval_question_descs WHERE question_id NOT IN (SELECT id FROM mixeval_questions);
912
ALTER TABLE mixeval_question_descs ADD FOREIGN KEY (`question_id`) REFERENCES `mixeval_questions` (`id`) ON DELETE CASCADE;
1013

1114
ALTER TABLE simple_evaluations ADD UNIQUE KEY `name` (`name`);

app/controllers/components/ajax_list.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function getListByState()
240240
if (!empty($state->mapFilterSelections)) {
241241
foreach ($state->mapFilterSelections as $column => $value) {
242242
if (!empty($column) && null !== $value && "" != $value) {
243-
$conditions[mysql_real_escape_string($column)] = mysql_real_escape_string($value);
243+
$conditions[$column] = $value;
244244
}
245245
}
246246
}
@@ -278,10 +278,10 @@ function getListByState()
278278
if (!empty($filter) && !empty($value)) {
279279
// Keywords starting with !!! are a special case
280280
if (!$this->isSpecialValue($value)) {
281-
$conditions[mysql_real_escape_string($filter)] = mysql_real_escape_string($value);
281+
$conditions[$filter] = $value;
282282
} else {
283283
// note: no quotes around special value
284-
$conditions[mysql_real_escape_string($filter)] = mysql_real_escape_string(substr($value, 3));
284+
$conditions[$filter] = substr($value, 3);
285285
}
286286
}
287287
}
@@ -301,7 +301,7 @@ function getListByState()
301301

302302
// Add in the search conditions
303303
if (!empty($state->searchBy) && !empty($state->searchValue)) {
304-
$conditions[mysql_real_escape_string($state->searchBy) . " LIKE"] = '%' . mysql_real_escape_string($state->searchValue) . '%';
304+
$conditions[$state->searchBy . " LIKE"] = '%' . $state->searchValue . '%';
305305
}
306306

307307
// The default functions for searhing

app/controllers/components/export_base_new.php

+21-6
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function buildEvaluationScoreTableByGroup($params, $groupEvent, $event, $results
9494

9595
$group = $this->Group->getGroupWithMemberRoleByGroupIdEventId($groupEvent['group_id'], $event['Event']['id']);
9696
$dropped = $this->User->getDroppedStudentsWithRole($this->responseModelName, $results, $group);
97-
97+
9898
$grid = array();
9999
$subDate = Set::combine($results, '{n}.EvaluationSubmission.submitter_id', '{n}.EvaluationSubmission.date_submitted');
100100
$responsesByEvaluatee = Set::combine($results, '{n}.'.$this->responseModelName.'.evaluator', '{n}', '{n}.'.$this->responseModelName.'.evaluatee');
@@ -161,8 +161,18 @@ function buildScoreTableByEvaluatee($params, $group, $evaluatee, $event, $respon
161161

162162
foreach ($group['Member'] as $evaluator) {
163163
if (!$peerEval && $evaluator['id'] != $evaluatee['id']) {
164-
continue; // skip peer evaluations for self-evaluation
164+
continue; // skip peer evaluations for self-evaluation section
165+
}
166+
167+
if (!$event['Event']['self_eval'] && $evaluator['id'] == $evaluatee['id']) {
168+
continue; // skip self-eval when self-evaluation is not set in event
169+
}
170+
171+
//TODO: change the condition to not depend on Role's name, which can change
172+
if ($evaluatee['Role']['name'] == 'tutor') {
173+
continue; // skip evaluations where the tutor is the evaluatee
165174
}
175+
166176
$row = array();
167177
if ($params['include']['course']) {
168178
array_push($row, $event['Course']['course']);
@@ -194,9 +204,14 @@ function buildScoreTableByEvaluatee($params, $group, $evaluatee, $event, $respon
194204
array_push($row, $evaluator['student_no']);
195205
}
196206

197-
// check if we have a reponse for this evaluator
207+
/* Export all determines whether or not to export all results
208+
including those that don't have values. */
198209
if (!isset($responses[$evaluatee['id']]) || !array_key_exists($evaluator['id'], $responses[$evaluatee['id']])) {
199-
array_push($row, array_fill(0, $xDimension - count($row), ''));
210+
if ($params['include']['export_all']) {
211+
$row += array_fill(count($row), $xDimension - count($row), '');
212+
$grid[] = $row;
213+
$yInc++;
214+
}
200215
continue;
201216
}
202217

@@ -234,13 +249,13 @@ function buildScoreTableByEvaluatee($params, $group, $evaluatee, $event, $respon
234249
}
235250
}
236251
}
237-
252+
238253
if (!$peerEval) {
239254
$grid[] = $row;
240255
$yInc++;
241256
continue; // skip final marks/penalty for self-evaluation
242257
}
243-
258+
244259
array_push($row, $response[$this->responseModelName]['score']);
245260
$date = isset($subDate[$evaluatee['id']]) ? $subDate[$evaluatee['id']] : false;
246261

app/controllers/evaluations_controller.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,15 @@ function _makeSurveyEvaluation ($event)
533533
$eventId = $event['Event']['id'];
534534
$userId = $this->Auth->user('id');
535535
$courseId = $event['Event']['course_id'];
536-
// Make sure user is a student in this course
537-
$ret = $this->UserEnrol->field('id',
538-
array('course_id' => $courseId, 'user_id' => $userId ));
536+
if (empty($studentId)) {
537+
// Make sure user is a student in this course
538+
$ret = $this->UserEnrol->field('id',
539+
array('course_id' => $courseId, 'user_id' => $userId ));
540+
} else {
541+
// Make sure user has access to the course (eg. instructor, admin)
542+
$ret = $this->Course->getAccessibleCourseById($courseId, $userId,
543+
User::getCourseFilterPermission(), array('Instructor', 'Department'));
544+
}
539545
if (!$ret) {
540546
$this->Session->setFlash(_t('Error: Invalid Id'));
541547
$this->redirect('/home/index');
@@ -716,7 +722,8 @@ function _makeRubricEvaluation ($event, $groupId)
716722
$comReq = ($commentsNeeded && $event['Event']['com_req']);
717723
$this->set('allDone', $allDone);
718724
$this->set('comReq', $comReq);
719-
725+
$this->set('fullName', User::get('full_name'));
726+
$this->set('userId', User::get('id'));
720727

721728
$this->render('rubric_eval_form');
722729
} else {
@@ -929,6 +936,7 @@ function _makeMixevalEvaluation ($event, $groupId)
929936
$this->set('questions', $questions);
930937
$this->set('mixeval', $mixeval);
931938
$this->set('enrol', $enrol);
939+
$this->set('userId', $userId);
932940

933941
$this->render('mixeval_eval_form');
934942
} else {
@@ -999,7 +1007,7 @@ function _makeMixevalEvaluation ($event, $groupId)
9991007
$evaluationSubmission['EvaluationSubmission']['date_submitted'] = date('Y-m-d H:i:s');
10001008
$evaluationSubmission['EvaluationSubmission']['submitted'] = 1;
10011009
if (!$this->EvaluationSubmission->save($evaluationSubmission)) {
1002-
$this->Session->setFlash(__('Error: Unable to submit the evaluation. Please try again.', truej));
1010+
$this->Session->setFlash(__('Error: Unable to submit the evaluation. Please try again.', true));
10031011
}
10041012
}
10051013

app/controllers/upgrade_controller.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,11 @@ function index()
6363
$dbv = $this->SysParameter->get('database.version');
6464
// workaround for a mistake in a sql templates in v3.0.x where
6565
// we forgot to add the system.version entry into sys_parameters
66-
if (empty($sysv) && $dbv == 4)
67-
{ // upgrading from iPeer v3.0
66+
if (empty($sysv) && $dbv == 4) {
67+
// upgrading from iPeer v3.0
6868
$sysv = '3.0.x';
6969
$dbv = 5;
70-
}
71-
else {
70+
} else {
7271
$sysv = $this->SysParameter->get('system.version', '2.x');
7372
}
7473
$this->set('is_upgradable', $this->Upgrader->isUpgradable());

app/controllers/v1_controller.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,8 @@ public function departments($departmentId = null)
827827
foreach ($dps as $dp) {
828828
$departments[] = $dp['Department'];
829829
}
830-
$statusCode = 'HTTP/1.1 200 OK';
831-
} else {
832-
$departments = null;
833-
$statusCode = 'HTTP/1.1 404 Not Found';
834830
}
831+
$statusCode = 'HTTP/1.1 200 OK';
835832
} else {
836833
$courseDepts = $this->CourseDepartment->find('list',
837834
array('conditions' => array('department_id' => $departmentId),

app/libs/toolkit.php

+179
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,184 @@ static function isStartWith($haystack, $needle)
148148
return (substr($haystack, 0, strlen($needle)) == $needle);
149149
}
150150

151+
/**
152+
* getSimpleEvalDemoData return demo data for simple evaluation preview
153+
*
154+
* @param mixed $points the points assign to the students
155+
*
156+
* @static
157+
* @access public
158+
* @return array demo data
159+
*/
160+
static function getSimpleEvalDemoData($points)
161+
{
162+
return array(
163+
'event' => array(
164+
'Event' => array(
165+
'id' => 0,
166+
'title' => 'Preview Event',
167+
'due_date' => Toolkit::formatDate(time()+(5*24*60*60)),
168+
'description' => 'Preview for simple evaluation event.',
169+
'com_req' => true,
170+
),
171+
'Group' => array(
172+
'id' => 0,
173+
'group_name' => 'Demo Group',
174+
),
175+
),
176+
'groupMembers' => array(
177+
array(
178+
'User' => array(
179+
'id' => 1,
180+
'first_name' => 'Demo',
181+
'last_name' => 'Student1',
182+
),
183+
),
184+
array(
185+
'User' => array(
186+
'id' => 2,
187+
'first_name' => 'Demo',
188+
'last_name' => 'Student2',
189+
),
190+
),
191+
array(
192+
'User' => array(
193+
'id' => 3,
194+
'first_name' => 'Demo',
195+
'last_name' => 'Student3',
196+
),
197+
),
198+
),
199+
'courseId' => 0,
200+
'userId' => 1,
201+
'evaluateeCount' => 2,
202+
'fullName' => User::get('full_name'),
203+
'remaining' => $points,
204+
'preview' => true,
205+
);
206+
}
151207

208+
/**
209+
* getRubricEvalDemoData get demo data for rubric evaluation preview
210+
*
211+
* @param mixed $data rubric data
212+
*
213+
* @static
214+
* @access public
215+
* @return array demo data
216+
*/
217+
static function getRubricEvalDemoData()
218+
{
219+
return array(
220+
'event' => array(
221+
'Event' => array(
222+
'id' => 0,
223+
'title' => 'Preview Event',
224+
'due_date' => Toolkit::formatDate(time()+(5*24*60*60)),
225+
'description' => 'Preview for rubric evaluation event.',
226+
'com_req' => true,
227+
),
228+
'Group' => array(
229+
'id' => 0,
230+
'group_name' => 'Demo Group',
231+
),
232+
),
233+
'groupMembers' => array(
234+
array(
235+
'User' => array(
236+
'id' => 1,
237+
'first_name' => 'Demo',
238+
'last_name' => 'Student1',
239+
),
240+
),
241+
array(
242+
'User' => array(
243+
'id' => 2,
244+
'first_name' => 'Demo',
245+
'last_name' => 'Student2',
246+
),
247+
),
248+
array(
249+
'User' => array(
250+
'id' => 3,
251+
'first_name' => 'Demo',
252+
'last_name' => 'Student3',
253+
),
254+
),
255+
),
256+
'courseId' => 0,
257+
'userId' => 1,
258+
'evaluateeCount' => 2,
259+
'fullName' => User::get('full_name'),
260+
'preview' => true,
261+
);
262+
}
263+
264+
/**
265+
* getMixEvalDemoData get demo data for mix evaluation preview
266+
*
267+
* @param mixed $data mix data
268+
*
269+
* @static
270+
* @access public
271+
* @return array demo data
272+
*/
273+
static function getMixEvalDemoData($mixeval)
274+
{
275+
return array(
276+
'event' => array(
277+
'Event' => array(
278+
'id' => 0,
279+
'title' => 'Preview Event',
280+
'due_date' => Toolkit::formatDate(time()+(5*24*60*60)),
281+
'release_date_end' => Toolkit::formatDate(time()+(6*24*60*60)),
282+
'description' => 'Preview for mix evaluation event.',
283+
'com_req' => true,
284+
'template_id' => 0,
285+
),
286+
'Group' => array(
287+
'id' => 0,
288+
'group_name' => 'Demo Group',
289+
),
290+
'GroupEvent' => array(
291+
'id' => 0,
292+
),
293+
),
294+
'groupMembers' => array(
295+
array(
296+
'User' => array(
297+
'id' => 1,
298+
'first_name' => 'Demo',
299+
'last_name' => 'Student1',
300+
'full_name' => 'Demo Student1',
301+
),
302+
),
303+
array(
304+
'User' => array(
305+
'id' => 2,
306+
'first_name' => 'Demo',
307+
'last_name' => 'Student2',
308+
'full_name' => 'Demo Student2',
309+
),
310+
),
311+
array(
312+
'User' => array(
313+
'id' => 3,
314+
'first_name' => 'Demo',
315+
'last_name' => 'Student3',
316+
'full_name' => 'Demo Student3',
317+
),
318+
),
319+
),
320+
'mixeval' => array('Mixeval' => $mixeval),
321+
'courseId' => 0,
322+
'userId' => 1,
323+
'evaluateeCount' => 2,
324+
'fullName' => User::get('full_name'),
325+
'members' => 0,
326+
'enrol' => 1,
327+
'self' => null,
328+
'preview' => true,
329+
);
330+
}
152331
}

app/models/evaluation_base.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function getBelongingOrPublic($user_id)
115115

116116
$conditions = array('creator_id' => $user_id);
117117
$conditions = array('OR' => array_merge(array('availability' => 'public'), $conditions));
118-
return $this->find('list', array('conditions' => $conditions, 'fields' => array('name')));
118+
return $this->find('list', array('conditions' => $conditions, 'fields' => array('name'), 'order' => 'name ASC'));
119119
}
120120

121121

@@ -167,12 +167,8 @@ function formatPenaltyArray($groupMembers, $eventId, $groupId)
167167
$event_due = strtotime($event['Event']['due_date']);
168168
// assign penalty to groupMember if they submitted late or never submitted by release_date_end
169169
$submissions = $this->EvaluationSubmission->find('all', array(
170-
'conditions' => array('submitter_id' => $memberIds, 'EvaluationSubmission.event_id' => $eventId),
171-
'contain' => array(
172-
'GroupEvent' => array(
173-
'conditions' => array('GroupEvent.group_id' => $groupId, 'GroupEvent.event_id' => $eventId),
174-
),
175-
)
170+
'conditions' => array('submitter_id' => $memberIds, 'EvaluationSubmission.event_id' => $eventId,
171+
'GroupEvent.group_id' => $groupId),
176172
));
177173

178174
foreach ($submissions as $submission) {

0 commit comments

Comments
 (0)