Skip to content

Commit

Permalink
Merge branch '3.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
xcompass committed Mar 5, 2014
2 parents 4043d95 + 7a0d1ec commit 0e6ed3d
Show file tree
Hide file tree
Showing 40 changed files with 1,096 additions and 894 deletions.
2 changes: 1 addition & 1 deletion app/config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
$CWL['applicationID'] = '';
$CWL['applicationPassword'] = '';

define('IPEER_VERSION', '3.1.0');
define('IPEER_VERSION', '3.1.1');


/**
Expand Down
3 changes: 3 additions & 0 deletions app/config/sql/delta_6b.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

ALTER TABLE mixeval_question_descs DROP FOREIGN KEY mixeval_question_descs_ibfk_1;
ALTER TABLE mixeval_question_descs DROP KEY question_num;

-- Remove the orphan records before adding the foreign key so that it will not fail.
DELETE FROM mixeval_question_descs WHERE question_id NOT IN (SELECT id FROM mixeval_questions);
ALTER TABLE mixeval_question_descs ADD FOREIGN KEY (`question_id`) REFERENCES `mixeval_questions` (`id`) ON DELETE CASCADE;

ALTER TABLE simple_evaluations ADD UNIQUE KEY `name` (`name`);
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/components/ajax_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function getListByState()
if (!empty($state->mapFilterSelections)) {
foreach ($state->mapFilterSelections as $column => $value) {
if (!empty($column) && null !== $value && "" != $value) {
$conditions[mysql_real_escape_string($column)] = mysql_real_escape_string($value);
$conditions[$column] = $value;
}
}
}
Expand Down Expand Up @@ -278,10 +278,10 @@ function getListByState()
if (!empty($filter) && !empty($value)) {
// Keywords starting with !!! are a special case
if (!$this->isSpecialValue($value)) {
$conditions[mysql_real_escape_string($filter)] = mysql_real_escape_string($value);
$conditions[$filter] = $value;
} else {
// note: no quotes around special value
$conditions[mysql_real_escape_string($filter)] = mysql_real_escape_string(substr($value, 3));
$conditions[$filter] = substr($value, 3);
}
}
}
Expand All @@ -301,7 +301,7 @@ function getListByState()

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

// The default functions for searhing
Expand Down
27 changes: 21 additions & 6 deletions app/controllers/components/export_base_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function buildEvaluationScoreTableByGroup($params, $groupEvent, $event, $results

$group = $this->Group->getGroupWithMemberRoleByGroupIdEventId($groupEvent['group_id'], $event['Event']['id']);
$dropped = $this->User->getDroppedStudentsWithRole($this->responseModelName, $results, $group);

$grid = array();
$subDate = Set::combine($results, '{n}.EvaluationSubmission.submitter_id', '{n}.EvaluationSubmission.date_submitted');
$responsesByEvaluatee = Set::combine($results, '{n}.'.$this->responseModelName.'.evaluator', '{n}', '{n}.'.$this->responseModelName.'.evaluatee');
Expand Down Expand Up @@ -161,8 +161,18 @@ function buildScoreTableByEvaluatee($params, $group, $evaluatee, $event, $respon

foreach ($group['Member'] as $evaluator) {
if (!$peerEval && $evaluator['id'] != $evaluatee['id']) {
continue; // skip peer evaluations for self-evaluation
continue; // skip peer evaluations for self-evaluation section
}

if (!$event['Event']['self_eval'] && $evaluator['id'] == $evaluatee['id']) {
continue; // skip self-eval when self-evaluation is not set in event
}

//TODO: change the condition to not depend on Role's name, which can change
if ($evaluatee['Role']['name'] == 'tutor') {
continue; // skip evaluations where the tutor is the evaluatee
}

$row = array();
if ($params['include']['course']) {
array_push($row, $event['Course']['course']);
Expand Down Expand Up @@ -194,9 +204,14 @@ function buildScoreTableByEvaluatee($params, $group, $evaluatee, $event, $respon
array_push($row, $evaluator['student_no']);
}

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

Expand Down Expand Up @@ -234,13 +249,13 @@ function buildScoreTableByEvaluatee($params, $group, $evaluatee, $event, $respon
}
}
}

if (!$peerEval) {
$grid[] = $row;
$yInc++;
continue; // skip final marks/penalty for self-evaluation
}

array_push($row, $response[$this->responseModelName]['score']);
$date = isset($subDate[$evaluatee['id']]) ? $subDate[$evaluatee['id']] : false;

Expand Down
18 changes: 13 additions & 5 deletions app/controllers/evaluations_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,15 @@ function _makeSurveyEvaluation ($event)
$eventId = $event['Event']['id'];
$userId = $this->Auth->user('id');
$courseId = $event['Event']['course_id'];
// Make sure user is a student in this course
$ret = $this->UserEnrol->field('id',
array('course_id' => $courseId, 'user_id' => $userId ));
if (empty($studentId)) {
// Make sure user is a student in this course
$ret = $this->UserEnrol->field('id',
array('course_id' => $courseId, 'user_id' => $userId ));
} else {
// Make sure user has access to the course (eg. instructor, admin)
$ret = $this->Course->getAccessibleCourseById($courseId, $userId,
User::getCourseFilterPermission(), array('Instructor', 'Department'));
}
if (!$ret) {
$this->Session->setFlash(_t('Error: Invalid Id'));
$this->redirect('/home/index');
Expand Down Expand Up @@ -716,7 +722,8 @@ function _makeRubricEvaluation ($event, $groupId)
$comReq = ($commentsNeeded && $event['Event']['com_req']);
$this->set('allDone', $allDone);
$this->set('comReq', $comReq);

$this->set('fullName', User::get('full_name'));
$this->set('userId', User::get('id'));

$this->render('rubric_eval_form');
} else {
Expand Down Expand Up @@ -929,6 +936,7 @@ function _makeMixevalEvaluation ($event, $groupId)
$this->set('questions', $questions);
$this->set('mixeval', $mixeval);
$this->set('enrol', $enrol);
$this->set('userId', $userId);

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

Expand Down
7 changes: 3 additions & 4 deletions app/controllers/upgrade_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ function index()
$dbv = $this->SysParameter->get('database.version');
// workaround for a mistake in a sql templates in v3.0.x where
// we forgot to add the system.version entry into sys_parameters
if (empty($sysv) && $dbv == 4)
{ // upgrading from iPeer v3.0
if (empty($sysv) && $dbv == 4) {
// upgrading from iPeer v3.0
$sysv = '3.0.x';
$dbv = 5;
}
else {
} else {
$sysv = $this->SysParameter->get('system.version', '2.x');
}
$this->set('is_upgradable', $this->Upgrader->isUpgradable());
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/v1_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,11 +827,8 @@ public function departments($departmentId = null)
foreach ($dps as $dp) {
$departments[] = $dp['Department'];
}
$statusCode = 'HTTP/1.1 200 OK';
} else {
$departments = null;
$statusCode = 'HTTP/1.1 404 Not Found';
}
$statusCode = 'HTTP/1.1 200 OK';
} else {
$courseDepts = $this->CourseDepartment->find('list',
array('conditions' => array('department_id' => $departmentId),
Expand Down
179 changes: 179 additions & 0 deletions app/libs/toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,184 @@ static function isStartWith($haystack, $needle)
return (substr($haystack, 0, strlen($needle)) == $needle);
}

/**
* getSimpleEvalDemoData return demo data for simple evaluation preview
*
* @param mixed $points the points assign to the students
*
* @static
* @access public
* @return array demo data
*/
static function getSimpleEvalDemoData($points)
{
return array(
'event' => array(
'Event' => array(
'id' => 0,
'title' => 'Preview Event',
'due_date' => Toolkit::formatDate(time()+(5*24*60*60)),
'description' => 'Preview for simple evaluation event.',
'com_req' => true,
),
'Group' => array(
'id' => 0,
'group_name' => 'Demo Group',
),
),
'groupMembers' => array(
array(
'User' => array(
'id' => 1,
'first_name' => 'Demo',
'last_name' => 'Student1',
),
),
array(
'User' => array(
'id' => 2,
'first_name' => 'Demo',
'last_name' => 'Student2',
),
),
array(
'User' => array(
'id' => 3,
'first_name' => 'Demo',
'last_name' => 'Student3',
),
),
),
'courseId' => 0,
'userId' => 1,
'evaluateeCount' => 2,
'fullName' => User::get('full_name'),
'remaining' => $points,
'preview' => true,
);
}

/**
* getRubricEvalDemoData get demo data for rubric evaluation preview
*
* @param mixed $data rubric data
*
* @static
* @access public
* @return array demo data
*/
static function getRubricEvalDemoData()
{
return array(
'event' => array(
'Event' => array(
'id' => 0,
'title' => 'Preview Event',
'due_date' => Toolkit::formatDate(time()+(5*24*60*60)),
'description' => 'Preview for rubric evaluation event.',
'com_req' => true,
),
'Group' => array(
'id' => 0,
'group_name' => 'Demo Group',
),
),
'groupMembers' => array(
array(
'User' => array(
'id' => 1,
'first_name' => 'Demo',
'last_name' => 'Student1',
),
),
array(
'User' => array(
'id' => 2,
'first_name' => 'Demo',
'last_name' => 'Student2',
),
),
array(
'User' => array(
'id' => 3,
'first_name' => 'Demo',
'last_name' => 'Student3',
),
),
),
'courseId' => 0,
'userId' => 1,
'evaluateeCount' => 2,
'fullName' => User::get('full_name'),
'preview' => true,
);
}

/**
* getMixEvalDemoData get demo data for mix evaluation preview
*
* @param mixed $data mix data
*
* @static
* @access public
* @return array demo data
*/
static function getMixEvalDemoData($mixeval)
{
return array(
'event' => array(
'Event' => array(
'id' => 0,
'title' => 'Preview Event',
'due_date' => Toolkit::formatDate(time()+(5*24*60*60)),
'release_date_end' => Toolkit::formatDate(time()+(6*24*60*60)),
'description' => 'Preview for mix evaluation event.',
'com_req' => true,
'template_id' => 0,
),
'Group' => array(
'id' => 0,
'group_name' => 'Demo Group',
),
'GroupEvent' => array(
'id' => 0,
),
),
'groupMembers' => array(
array(
'User' => array(
'id' => 1,
'first_name' => 'Demo',
'last_name' => 'Student1',
'full_name' => 'Demo Student1',
),
),
array(
'User' => array(
'id' => 2,
'first_name' => 'Demo',
'last_name' => 'Student2',
'full_name' => 'Demo Student2',
),
),
array(
'User' => array(
'id' => 3,
'first_name' => 'Demo',
'last_name' => 'Student3',
'full_name' => 'Demo Student3',
),
),
),
'mixeval' => array('Mixeval' => $mixeval),
'courseId' => 0,
'userId' => 1,
'evaluateeCount' => 2,
'fullName' => User::get('full_name'),
'members' => 0,
'enrol' => 1,
'self' => null,
'preview' => true,
);
}
}
10 changes: 3 additions & 7 deletions app/models/evaluation_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function getBelongingOrPublic($user_id)

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


Expand Down Expand Up @@ -167,12 +167,8 @@ function formatPenaltyArray($groupMembers, $eventId, $groupId)
$event_due = strtotime($event['Event']['due_date']);
// assign penalty to groupMember if they submitted late or never submitted by release_date_end
$submissions = $this->EvaluationSubmission->find('all', array(
'conditions' => array('submitter_id' => $memberIds, 'EvaluationSubmission.event_id' => $eventId),
'contain' => array(
'GroupEvent' => array(
'conditions' => array('GroupEvent.group_id' => $groupId, 'GroupEvent.event_id' => $eventId),
),
)
'conditions' => array('submitter_id' => $memberIds, 'EvaluationSubmission.event_id' => $eventId,
'GroupEvent.group_id' => $groupId),
));

foreach ($submissions as $submission) {
Expand Down
Loading

0 comments on commit 0e6ed3d

Please sign in to comment.