From 7cf1c8f4b6c65128cd1ffa06714bfc6fa9bffdd5 Mon Sep 17 00:00:00 2001 From: Michael Tang Date: Fri, 17 Jan 2014 14:05:37 -0800 Subject: [PATCH 01/23] fixed the inability to view students' survey Previously if you are an administrator and have access to the course, the system still returns an error message that it is an invalid id when you are trying to access a survey. The reason is the system only checks whether you are an instructor of the course or not. To fix this problem, I have changed it to check whether the logged in user has access to the course if they are trying to access the surveys not as a student. Conflicts: app/controllers/evaluations_controller.php --- app/controllers/evaluations_controller.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/evaluations_controller.php b/app/controllers/evaluations_controller.php index fa23df663..cda4be2ad 100644 --- a/app/controllers/evaluations_controller.php +++ b/app/controllers/evaluations_controller.php @@ -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'); From 038cc226abce2f8e9f3e8faff168d8a2970b7c0a Mon Sep 17 00:00:00 2001 From: Michael Tang Date: Mon, 20 Jan 2014 15:15:08 -0800 Subject: [PATCH 02/23] Fixed problem with exporting evaluation results to csv I have discovered that when we export all results from evaluation events that do not have the self evaluation option turned on, we still receive rows of empty result for self evaluation. For example, if we have no self-evaluation event and we exported all the results we still get a row that have no results (as expected) for Ed Student from Ed Student. Conflicts: app/controllers/components/export_base_new.php --- .../components/export_base_new.php | 27 ++++++++++++++----- app/controllers/evaluations_controller.php | 2 +- app/views/evaluations/export.ctp | 4 +++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/controllers/components/export_base_new.php b/app/controllers/components/export_base_new.php index 7c64ca4a2..ac0a126f5 100644 --- a/app/controllers/components/export_base_new.php +++ b/app/controllers/components/export_base_new.php @@ -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'); @@ -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']); @@ -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; } @@ -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; diff --git a/app/controllers/evaluations_controller.php b/app/controllers/evaluations_controller.php index cda4be2ad..65a35326e 100644 --- a/app/controllers/evaluations_controller.php +++ b/app/controllers/evaluations_controller.php @@ -1005,7 +1005,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)); } } diff --git a/app/views/evaluations/export.ctp b/app/views/evaluations/export.ctp index 43445a0d5..9c8f01e0d 100644 --- a/app/views/evaluations/export.ctp +++ b/app/views/evaluations/export.ctp @@ -22,6 +22,10 @@ $evaluations = ($fromEvent) ? array($selectedEvent['Event']['id'] => $selectedEv echo $this->Form->input('event_id', array( 'name' => 'event_id', 'options' => $evaluations, 'label' => 'Event Name' )); +echo $this->Form->input('export_all', array( + 'type' => 'checkbox', 'name' => 'include[export_all]', 'checked' => true, + 'label' => __('Include All Evaluations', true) +)); ?>

Date: Fri, 31 Jan 2014 17:11:38 -0800 Subject: [PATCH 03/23] Fix API return 404 when no department is setup When no department is setup, the return value should be empty array [], instead of 404. --- app/controllers/v1_controller.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/v1_controller.php b/app/controllers/v1_controller.php index d9bbf84a1..c9a97b55f 100644 --- a/app/controllers/v1_controller.php +++ b/app/controllers/v1_controller.php @@ -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), From cac01f820ae496fa75fe48421bb66c762f6693f8 Mon Sep 17 00:00:00 2001 From: Compass Date: Tue, 4 Feb 2014 09:56:26 -0800 Subject: [PATCH 04/23] Fix missing Content-length in response of API call When the Content-length header is missing from the response, web server will treat response as dynamic length response and will insert the "Transfer-Encoding: chunked" in response header and may insert extra numbers in the beginning and ending of the response body. If the client couldn't handle chunked transfer encoding (http://en.wikipedia.org/wiki/Chunked_transfer_encoding), the parsing will fail. --- app/views/v1/error.ctp | 6 ++++-- app/views/v1/json.ctp | 1 + app/views/v1/oauth_error.ctp | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/v1/error.ctp b/app/views/v1/error.ctp index 20150c643..bd05ee750 100644 --- a/app/views/v1/error.ctp +++ b/app/views/v1/error.ctp @@ -1,4 +1,6 @@ log(json_encode($error)); -echo json_encode($error); +$error_str = json_encode($error); +header("Content-length: ".strlen($error_str)); +$this->log($error_str); +echo $error_str; diff --git a/app/views/v1/json.ctp b/app/views/v1/json.ctp index 8862ace01..74ce16143 100644 --- a/app/views/v1/json.ctp +++ b/app/views/v1/json.ctp @@ -5,6 +5,7 @@ $result = array(); } $json = json_encode($result); + header("Content-length: ".strlen($json)); $this->log("Return: $json", 'api'); echo $json; diff --git a/app/views/v1/oauth_error.ctp b/app/views/v1/oauth_error.ctp index 898f73c1e..4568f885a 100644 --- a/app/views/v1/oauth_error.ctp +++ b/app/views/v1/oauth_error.ctp @@ -2,5 +2,7 @@ header('HTTP/1.1 400 Bad Request '); $error = array('code' => 100, "message" => 'OAuth error: '.$oauthError); -echo json_encode($error); -?> +$error_str = json_encode($error); +header("Content-length: ".strlen($error_str)); +$this->log($error_str); +echo $error_str; From 14a417184f0af62530d19b6920097b243ac116f3 Mon Sep 17 00:00:00 2001 From: Compass Date: Tue, 18 Feb 2014 23:56:14 -0800 Subject: [PATCH 05/23] Remove the orphan entries in mixeval_question_descs --- app/config/sql/delta_6b.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/config/sql/delta_6b.sql b/app/config/sql/delta_6b.sql index f68733859..03d9b4acd 100644 --- a/app/config/sql/delta_6b.sql +++ b/app/config/sql/delta_6b.sql @@ -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`); From f14f4107014837168c725cf5eaa4a21d7f34aec7 Mon Sep 17 00:00:00 2001 From: Compass Date: Fri, 21 Feb 2014 13:01:16 -0800 Subject: [PATCH 06/23] Fix #543 remove the criteria hint text from rubric Removed "Level of Mastery" from the rubric form as it is not relevant to students. --- app/views/elements/rubrics/ajax_rubric_view.ctp | 4 ++-- app/views/rubrics/edit.ctp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/elements/rubrics/ajax_rubric_view.ctp b/app/views/elements/rubrics/ajax_rubric_view.ctp index 43dc34354..ff7f9e489 100644 --- a/app/views/elements/rubrics/ajax_rubric_view.ctp +++ b/app/views/elements/rubrics/ajax_rubric_view.ctp @@ -14,7 +14,7 @@ $reqCom = isset($event) && $event['Event']['com_req'] ? '
( - :
+ @@ -80,4 +80,4 @@ jQuery().ready(function() { return saveButtonVal(userId); }); }); - \ No newline at end of file + diff --git a/app/views/rubrics/edit.ctp b/app/views/rubrics/edit.ctp index f0566c453..5ba42dae0 100644 --- a/app/views/rubrics/edit.ctp +++ b/app/views/rubrics/edit.ctp @@ -16,7 +16,7 @@ $url = $this->action == 'copy' ? 'add' : $this->action; Form->input('lom_max', array('id' => 'LOM', 'options' => array_combine(range(2,10), range(2,10)), 'default' => 5, - 'label' => __('Level of Mastery:', true), + 'label' => __('Level of Mastery', true), 'style'=>'width:50px;', 'disabled' => $readonly));?>
From c90c6ee09628a6b4a44323315852e87012723ddf Mon Sep 17 00:00:00 2001 From: Compass Date: Fri, 21 Feb 2014 13:45:53 -0800 Subject: [PATCH 07/23] Fix #556, use relative URL for css background image If use absolute URL, it will cause problem when the site is not on root of the web server, e.g. image missing --- app/webroot/css/ipeer.css | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/webroot/css/ipeer.css b/app/webroot/css/ipeer.css index 0b7a5ad2b..07bd1a149 100644 --- a/app/webroot/css/ipeer.css +++ b/app/webroot/css/ipeer.css @@ -1288,24 +1288,24 @@ i { } .surveyquestions .top-button { - background:url('/img/icons/top.gif') center left no-repeat; + background:url('../img/icons/top.gif') center left no-repeat; padding: 0 0.5em 0 1.5em; white-space:nowrap; } .surveyquestions .up-button { - background:url('/img/icons/up.gif') center left no-repeat; + background:url('../img/icons/up.gif') center left no-repeat; padding: 0 0.5em 0 1.5em; white-space:nowrap; } .surveyquestions .down-button { - background:url('/img/icons/down.gif') center left no-repeat; + background:url('../img/icons/down.gif') center left no-repeat; padding: 0 0.5em 0 1.5em; white-space:nowrap; } .surveyquestions .bottom-button { - background:url('/img/icons/bottom.gif') center left no-repeat; + background:url('../img/icons/bottom.gif') center left no-repeat; padding: 0 0.5em 0 1.5em; white-space:nowrap; } @@ -1730,42 +1730,42 @@ table.content-table { .add-button { - background:url('/img/icons/add.gif') center left no-repeat; + background:url('../img/icons/add.gif') center left no-repeat; padding: 0 0 0 20px; white-space:nowrap; font-size: 0.9em; } .delete-button { - background:url('/img/icons/delete.gif') center left no-repeat; + background:url('../img/icons/delete.gif') center left no-repeat; padding: 0 0 0 20px; white-space:nowrap; font-size: 0.9em; } .edit-button { - background:url('/img/icons/edit.gif') center left no-repeat; + background:url('../img/icons/edit.gif') center left no-repeat; padding: 0 0 0 20px; white-space:nowrap; font-size: 0.9em; } .merge-button { - background:url('/img/icons/merge.png') center left no-repeat; + background:url('../img/icons/merge.png') center left no-repeat; padding: 0 0 0 20px; white-space:nowrap; font-size: 0.9em; } .export-excel-button { - background:url('/img/icons/export_excel.gif') center left no-repeat; + background:url('../img/icons/export_excel.gif') center left no-repeat; padding: 0 0 0 20px; white-space:nowrap; font-size: 0.9em; } .instruction-icon { - background:url('/img/icons/instructions.gif') center left no-repeat; + background:url('../img/icons/instructions.gif') center left no-repeat; padding: 0 0 0 20px; white-space:nowrap; font-size: 0.9em; @@ -1934,7 +1934,7 @@ form div.help-text { } .ipeer-icon { - background:url('/img/layout/icon_ipeer_logo.gif') center left no-repeat; + background:url('../img/layout/icon_ipeer_logo.gif') center left no-repeat; padding: 0 0.5em 0 1.5em; white-space:nowrap; } From b440289eb0c576d4811c783918a5f09fa5e3bbd0 Mon Sep 17 00:00:00 2001 From: Compass Date: Fri, 21 Feb 2014 15:59:41 -0800 Subject: [PATCH 08/23] Fix #554, confirm button on upgrade page on firefox --- app/controllers/upgrade_controller.php | 7 +++---- app/views/upgrade/index.ctp | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/upgrade_controller.php b/app/controllers/upgrade_controller.php index 95bb7ceb7..5bb384bd9 100644 --- a/app/controllers/upgrade_controller.php +++ b/app/controllers/upgrade_controller.php @@ -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()); diff --git a/app/views/upgrade/index.ctp b/app/views/upgrade/index.ctp index f106e6d6f..c5ada51a1 100644 --- a/app/views/upgrade/index.ctp +++ b/app/views/upgrade/index.ctp @@ -1,9 +1,9 @@ -

Current Version:

+

Current iPeer Version:

Current Database Version:

You are about to upgrade your iPeer instance. Please make sure you have BACKED UP your database and files before proceeding!

Upgrade may take some time. Please be patient.

-

+

Your instance does not need to be upgraded.

From 5267c72098872c16260eff810e52c9db83a9ddb7 Mon Sep 17 00:00:00 2001 From: Compass Date: Fri, 21 Feb 2014 16:15:49 -0800 Subject: [PATCH 09/23] Fix #555, merge user search failed when installed on subdirectory --- app/views/users/merge.ctp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/views/users/merge.ctp b/app/views/users/merge.ctp index 818f2eaa3..1044cfab7 100644 --- a/app/views/users/merge.ctp +++ b/app/views/users/merge.ctp @@ -7,7 +7,7 @@

-Form->create('User', +Form->create('User', array('onsubmit' => 'return confirm("Are you sure you want to merge the two users? The merger cannot be undone.");')); ?> element('users/merge_search', array('account' => 'secondary', 'searchValue' => $searchValue)); ?> @@ -37,7 +37,7 @@ jQuery().ready(function() { }); jQuery('#UserPrimaryAccount').change(function() { var userId = jQuery('#UserPrimaryAccount option:selected').val(); - jQuery.getJSON('/users/ajax_merge', {action: 'data', userId: userId}, + jQuery.getJSON('ajax_merge', {action: 'data', userId: userId}, function(field) { jQuery.each(field, function(index, value) { jQuery('td#primary' + index).html(value); @@ -46,7 +46,7 @@ jQuery().ready(function() { }); jQuery('#UserSecondaryAccount').change(function() { var userId = jQuery('#UserSecondaryAccount option:selected').val(); - jQuery.getJSON('/users/ajax_merge', {action: 'data', userId: userId}, + jQuery.getJSON('ajax_merge', {action: 'data', userId: userId}, function(field) { jQuery.each(field, function(index, value) { jQuery('td#secondary' + index).html(value); @@ -87,11 +87,11 @@ function primarySearch() { var field = jQuery('#UserPrimarySearch option:selected').val(); var value = jQuery('#UserPrimarySearchValue').val(); jQuery('#UserPrimaryAccount').attr('disabled', 'disabled'); - jQuery.getJSON('/users/ajax_merge', {action: 'account', field: field, value: value}, + jQuery.getJSON('ajax_merge', {action: 'account', field: field, value: value}, function(users) { populate(users, '#UserPrimaryAccount', 'primary'); }); - jQuery.getJSON('/users/ajax_merge', {action: 'data', userId: ''}, + jQuery.getJSON('ajax_merge', {action: 'data', userId: ''}, function(field) { jQuery.each(field, function(index, value) { jQuery('td#primary' + index).html(value); @@ -105,11 +105,11 @@ function secondarySearch() { var field = jQuery('#UserSecondarySearch option:selected').val(); var value = jQuery('#UserSecondarySearchValue').val(); jQuery('#UserSecondaryAccount').attr('disabled', 'disabled'); - jQuery.getJSON('/users/ajax_merge', {action: 'account', field: field, value: value}, + jQuery.getJSON('ajax_merge', {action: 'account', field: field, value: value}, function(users) { populate(users, '#UserSecondaryAccount', 'secondary'); }); - jQuery.getJSON('/users/ajax_merge', {action: 'data', userId: ''}, + jQuery.getJSON('ajax_merge', {action: 'data', userId: ''}, function(field) { jQuery.each(field, function(index, value) { jQuery('td#secondary' + index).html(value); @@ -128,6 +128,3 @@ function disableSelection(account) { } - - - From 01b8a74db562922bab2d13080bfaf7c93f2a5246 Mon Sep 17 00:00:00 2001 From: Compass Date: Sat, 22 Feb 2014 17:55:30 -0800 Subject: [PATCH 10/23] Refactor rubric form to show header in view page --- app/controllers/evaluations_controller.php | 3 +- app/libs/toolkit.php | 113 ++++++++++++ .../cases/system/student_simple.test.php | 148 ++++++++-------- .../elements/evaluations/rubric_eval_form.ctp | 163 ++++++++++++++++++ .../elements/evaluations/simple_eval_form.ctp | 34 ++-- app/views/evaluations/rubric_eval_form.ctp | 156 +---------------- app/views/rubrics/edit.ctp | 12 +- app/views/simple_evaluations/view.ctp | 49 +----- 8 files changed, 379 insertions(+), 299 deletions(-) create mode 100644 app/views/elements/evaluations/rubric_eval_form.ctp diff --git a/app/controllers/evaluations_controller.php b/app/controllers/evaluations_controller.php index 65a35326e..a859b0d64 100644 --- a/app/controllers/evaluations_controller.php +++ b/app/controllers/evaluations_controller.php @@ -722,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 { diff --git a/app/libs/toolkit.php b/app/libs/toolkit.php index cdce0d328..dc8630eb1 100644 --- a/app/libs/toolkit.php +++ b/app/libs/toolkit.php @@ -148,5 +148,118 @@ 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' => 0, + '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($data) + { + 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' => 0, + 'evaluateeCount' => 2, + 'fullName' => User::get('full_name'), + 'remaining' => $data['SimpleEvaluation']['point_per_member'] * 3, + 'preview' => true, + ); + } + /* }}} */ } diff --git a/app/tests/cases/system/student_simple.test.php b/app/tests/cases/system/student_simple.test.php index b15d8f4f4..481f85664 100644 --- a/app/tests/cases/system/student_simple.test.php +++ b/app/tests/cases/system/student_simple.test.php @@ -4,7 +4,7 @@ class studentSimple extends SystemBaseTestCase { protected $eventId = 0; - + public function startCase() { $this->getUrl(); @@ -13,19 +13,19 @@ public function startCase() $this->web_driver = new SystemWebDriver($wd_host); $this->session = $this->web_driver->session('firefox'); $this->session->open($this->url); - + $w = new PHPWebDriver_WebDriverWait($this->session); $this->session->deleteAllCookies(); $login = PageFactory::initElements($this->session, 'Login'); $home = $login->login('root', 'ipeeripeer'); } - + public function endCase() { $this->session->deleteAllCookies(); $this->session->close(); } - + public function testCreateEvent() { $this->session->open($this->url.'events/add/1'); @@ -47,11 +47,11 @@ public function testCreateEvent() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateEnd')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '28')->click(); - + // add penalty $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Penalty')->click();; $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="Penalty0PercentPenalty"] option[value="10"]')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="GroupGroup"] option[value="1"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="GroupGroup"] option[value="2"]')->click(); @@ -65,34 +65,34 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Add event successful!'); } - + public function testStudent() { $this->waitForLogoutLogin('redshirt0001'); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Home'); - + $pending = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'div[class="eventSummary pending"]')->text(); // check that there is at least one pending event $this->assertEqual(substr($pending, -22), 'Pending Event(s) Total'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); - + // check the submit button is disabled $submit = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[value="Submit Evaluation"]'); $this->assertTrue($submit->attribute('disabled')); // check the instructions for comments $comment = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'font[color="red"]'); - $this->assertEqual($comment->text(), '(Must)'); + $this->assertEqual($comment->text(), '(Required)'); // check penalty note $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '( Show/Hide late penalty policy )')->click(); $penalty = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'penalty')->text(); $this->assertEqual($penalty, "1 day late: 10% deduction.\n10% is deducted afterwards."); - + // move the sliders $this->handleOffset('handle6', 24); $this->handleOffset('handle7', -25); - + // wait for distribution to finish $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'distr_button')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -107,18 +107,18 @@ function($session) { $matt = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'point7')->attribute('value'); $this->assertEqual($alex, 140); $this->assertEqual($matt, 60); - + $warning = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'statusMsg')->text(); $this->assertEqual($warning, "All points are allocated.\nThere are still 2 comments to be filled."); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'comment6')->sendKeys('A very great group member'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'comment7')->sendKeys('Very responsible.'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'comment6')->click(); - + $warning = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'statusMsg')->text(); $this->assertEqual($warning, "All points are allocated.\nAll comments are filled."); - - $submit->click(); + + $submit->click(); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); @@ -127,7 +127,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Your Evaluation was submitted successfully.'); } - + public function testReSubmit() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); @@ -147,7 +147,7 @@ function($session) { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'point7')->sendKeys($delete->key.$delete->key.'80'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'comment7')->click(); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit0')->click(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit0')->click(); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); @@ -155,13 +155,13 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Your Evaluation was submitted successfully.'); - + // test negative points $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'point6')->sendKeys($delete->key.$delete->key.$delete->key.'-100'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'point7')->sendKeys($delete->key.$delete->key.'300'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'comment7')->click(); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit0')->click(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit0')->click(); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, "flashMessage")); @@ -169,20 +169,20 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'flashMessage')->text(); $this->assertEqual($msg, 'One or more of your group members have negative points. Please use positive numbers.'); - + $this->secondStudent(); $this->tutor(); } - + public function testCheckResult() { $this->waitForLogoutLogin('root'); $this->removeFromGroup(); - + $this->session->open($this->url.'events/index/1'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); $this->eventId = end(explode('/', $this->session->url())); - + // edit event's release date end to test final penalty // edit event's result release date begin to test student view of the results $this->session->open($this->url.'events/edit/'.$this->eventId); @@ -191,21 +191,21 @@ public function testCheckResult() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateBegin')->clear(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateBegin')->sendKeys(date('Y-m-d H:i:s')); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[value="Submit"]')->click(); - $w = new PHPWebDriver_WebDriverWait($this->session); + $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->session->open($this->url.'evaluations/view/'.$this->eventId); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'MECH 328 - Mechanical Engineering Design Project > Simple Evaluation > Results'); - + //auto-release results message $msg = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, 'autoRelease_msg'); $this->assertTrue(!empty($msg)); - + // check lates $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '3 Late')->click(); $ed = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td[4]'); @@ -216,7 +216,7 @@ function($session) { $this->assertEqual($matt->text(), '(not submitted)'); $matt = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[4]/td[4]'); $this->assertEqual($matt->text(), '---'); - + // view evaluation results $this->session->open($this->url.'evaluations/viewEvaluationResults/'.$this->eventId.'/1'); // check members that are not enrolled and have not completed @@ -228,13 +228,13 @@ function($session) { $this->assertEqual($left, 'Left the group, but had submitted or were evaluated'); $left = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[2]/td')->text(); $this->assertEqual($left, 'Tutor 1 (TA)'); - + // auto-release results messages $msg = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, 'autoRelease_msg'); $this->assertTrue(!empty($msg)); $msg = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'li[class="green"]'); $this->assertTrue(!empty($msg)); - + // check summary table // colour coding names $matt = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[2]/th[3]'); @@ -248,39 +248,39 @@ function($session) { $this->assertEqual($matt->attribute('class'), 'red'); $tutor1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="evalForm2"]/h3[3]'); $this->assertEqual($tutor1->attribute('class'), 'blue'); - + // check that the individual marks given are correct for Ed $mark1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[3]/td[1]')->text(); - $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[3]/td[2]')->text(); + $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[3]/td[2]')->text(); $mark3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[3]/td[3]')->text(); $this->assertEqual($mark1, '-'); $this->assertEqual($mark2, '120.00'); $this->assertEqual($mark3, '80.00'); - + // check that the individual marks given are correct for Alex $mark1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[4]/td[1]')->text(); - $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[4]/td[2]')->text(); + $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[4]/td[2]')->text(); $mark3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[4]/td[3]')->text(); $this->assertEqual($mark1, '95.00'); $this->assertEqual($mark2, '-'); $this->assertEqual($mark3, '105.00'); - + // check that the individual marks given are correct for Matt $mark1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[5]/td[1]')->text(); - $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[5]/td[2]')->text(); + $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[5]/td[2]')->text(); $mark3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[5]/td[3]')->text(); $this->assertEqual($mark1, '-'); $this->assertEqual($mark2, '-'); $this->assertEqual($mark3, '-'); - + // check that the individual marks given are correct for Tutor 1 $mark1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[6]/td[1]')->text(); - $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[6]/td[2]')->text(); + $mark2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[6]/td[2]')->text(); $mark3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[6]/td[3]')->text(); $this->assertEqual($mark1, '100.00'); $this->assertEqual($mark2, '100.00'); $this->assertEqual($mark3, '100.00'); - + // total $total1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[8]/td[1]')->text(); $total2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[8]/td[2]')->text(); @@ -288,7 +288,7 @@ function($session) { $this->assertEqual($total1, '195.00'); $this->assertEqual($total2, '220.00'); $this->assertEqual($total3, '285.00'); - + // penalty $penalty1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[9]/td[1]')->text(); $penalty2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[9]/td[2]')->text(); @@ -296,7 +296,7 @@ function($session) { $this->assertEqual($penalty1, '19.50 (10%)'); $this->assertEqual($penalty2, '22.00 (10%)'); $this->assertEqual($penalty3, '28.50 (10%)'); - + // final mark $final1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[10]/td[1]')->text(); $final2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[10]/td[2]')->text(); @@ -304,7 +304,7 @@ function($session) { $this->assertEqual($final1, '175.50'); $this->assertEqual($final2, '198.00'); $this->assertEqual($final3, '256.50'); - + // num $num1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[11]/td[1]')->text(); $num2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[11]/td[2]')->text(); @@ -312,7 +312,7 @@ function($session) { $this->assertEqual($num1, '2'); $this->assertEqual($num2, '2'); $this->assertEqual($num3, '3'); - + // average $avg1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[12]/td[1]')->text(); $avg2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[12]/td[2]')->text(); @@ -320,7 +320,7 @@ function($session) { $this->assertEqual($avg1, '87.75'); $this->assertEqual($avg2, '99.00'); $this->assertEqual($avg3, '85.5'); - + // check the comments are correct $com1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="evalForm2"]/table[1]/tbody/tr[2]/td[2]')->text(); $com2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="evalForm2"]/table[1]/tbody/tr[3]/td[2]')->text(); @@ -336,12 +336,12 @@ function($session) { $this->assertEqual($com5, 'Does his fair share of work'); $this->assertEqual($com6, 'Knows what he is doing'); $this->assertEqual($com7, 'Does his work efficiently'); - + // colour coding for Tutor in comments section $tutor = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="evalForm2"]/h3[3]'); $this->assertEqual($tutor->attribute('class'), 'blue'); } - + public function testStudentViewResults() { $this->waitForLogoutLogin('redshirt0003'); @@ -356,16 +356,16 @@ public function testStudentViewResults() sort($comments); $this->assertEqual($comments[0], 'A great leader'); $this->assertEqual($comments[1], 'Does his work efficiently'); - $this->assertEqual($comments[2], 'Very responsible.'); + $this->assertEqual($comments[2], 'Very responsible.'); } - + public function testNoDetails() { $this->waitForLogoutLogin('root'); $this->session->open($this->url.'events/edit/'.$this->eventId); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventEnableDetails0')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[value="Submit"]')->click(); - $w = new PHPWebDriver_WebDriverWait($this->session); + $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); @@ -380,7 +380,7 @@ function($session) { $comments = $this->session->elements(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]'); $this->assertTrue(empty($comments)); } - + public function testTutorInInstructorView() { $this->waitForLogoutLogin('root'); @@ -396,20 +396,20 @@ public function testTutorInInstructorView() $tutor = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="evalForm2"]/h3[3]'); $this->assertFalse($tutor->attribute('class')); } - + public function testRelease() { $this->session->open($this->url.'events/edit/'.$this->eventId); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventAutoRelease0')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventEnableDetails1')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[value="Submit"]')->click(); - $w = new PHPWebDriver_WebDriverWait($this->session); + $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + // release Ed's grades $this->session->open($this->url.'evaluations/viewEvaluationResults/'.$this->eventId.'/1'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[13]/td[2]/button')->click(); @@ -436,7 +436,7 @@ function($session) { $this->session->open($this->url.'evaluations/view/'.$this->eventId); $review = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="ajaxListDiv"]/div/table/tbody/tr[2]/td[6]/div'); $this->assertEqual($review->text(), 'Reviewed'); - + // check Ed's results $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); @@ -448,7 +448,7 @@ function($session) { $this->assertTrue(empty($comment)); $comment = $this->session->elements(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[2]/td'); $this->assertTrue(empty($comment)); - + // check Alex's results $this->waitForLogoutLogin('redshirt0002'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); @@ -460,7 +460,7 @@ function($session) { $this->assertEqual($comment->text(), 'A very great group member'); $comment = $this->session->elements(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[3]/td'); $this->assertTrue(empty($comment)); - + // check Matt's results $this->waitForLogoutLogin('redshirt0003'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); @@ -473,13 +473,13 @@ function($session) { $comment = $this->session->elements(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[2]/td'); $this->assertTrue(empty($comment)); } - + public function testReleaseAllComments() { $this->waitForLogoutLogin('root'); $this->session->open($this->url.'evaluations/viewEvaluationResults/'.$this->eventId.'/1'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[value="Release All"]')->click(); - + $this->waitForLogoutLogin('redshirt0003'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[3]/tbody/tr[2]/td[1]'); @@ -492,15 +492,15 @@ public function testReleaseAllComments() sort($comments); $this->assertEqual($comments[0], 'A great leader'); $this->assertEqual($comments[1], 'Does his work efficiently'); - $this->assertEqual($comments[2], 'Very responsible.'); + $this->assertEqual($comments[2], 'Very responsible.'); } - + public function testUnreleaseAllComments() { $this->waitForLogoutLogin('root'); $this->session->open($this->url.'evaluations/viewEvaluationResults/'.$this->eventId.'/1'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[value="Unrelease All"]')->click(); - + $this->waitForLogoutLogin('redshirt0003'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[3]/tbody/tr[2]/td[1]'); @@ -512,7 +512,7 @@ public function testUnreleaseAllComments() $comment = $this->session->elements(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[2]/td'); $this->assertTrue(empty($comment)); } - + public function testSubmissionsAfterEvalReleased() { // when a submission is made after grades and comments have been released @@ -559,7 +559,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + // check Ed Student's results - grades not released (Matt's not released) // comments (only two comments are released) $this->waitForLogoutLogin('redshirt0001'); @@ -576,7 +576,7 @@ function($session) { // comment 'not show up' is not part of the list of comments $comm3 = $this->session->elements(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[4]/td'); $this->assertTrue(empty($comm3)); - + // Matt Student's grades are released $this->waitForLogoutLogin('redshirt0003'); $simple = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation'); @@ -593,7 +593,7 @@ function($session) { $this->assertEqual($comm1[1], 'Does his work efficiently'); $this->assertEqual($comm1[2], 'Very responsible.'); } - + public function testDeleteEvent() { $this->waitForLogoutLogin('root'); @@ -607,7 +607,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The event has been deleted successfully.'); } - + public function handleOffset($id, $offset) { $handle = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, $id); @@ -616,7 +616,7 @@ public function handleOffset($id, $offset) $this->session->moveto(array('xoffset' => $offset, 'yoffset' => 0)); $this->session->buttonup(); } - + public function secondStudent() { $this->waitForLogoutLogin('redshirt0002'); @@ -634,7 +634,7 @@ function($session) { } ); } - + public function tutor() { $this->waitForLogoutLogin('tutor1'); @@ -654,7 +654,7 @@ function($session) { } ); } - + public function removeFromGroup() { $this->session->open($this->url.'groups/edit/1'); @@ -670,7 +670,7 @@ function($session) { } ); } - + public function assignToGroup() { $this->session->open($this->url.'groups/edit/1'); @@ -684,4 +684,4 @@ function($session) { } ); } -} \ No newline at end of file +} diff --git a/app/views/elements/evaluations/rubric_eval_form.ctp b/app/views/elements/evaluations/rubric_eval_form.ctp new file mode 100644 index 000000000..ced163965 --- /dev/null +++ b/app/views/elements/evaluations/rubric_eval_form.ctp @@ -0,0 +1,163 @@ + +script('ricobase')?> +script('ricoeffects')?> +script('ricoanimation')?> +script('ricopanelcontainer')?> +script('ricoaccordion')?> +
+hidden('Evaluation/id'); ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
::
::
:
+ : +
    +
  • EACH of your peer\'s name to rate his/her performance.')?>
  • +
  • ('.__('Required', true).'' : __('Optional', true) ;?>).
  • +
  • +
  • +
  • NOTE: You can click the "Submit to Complete the Evaluation" button only AFTER all evaluations are completed.')?>
  • + '._t("Evaluation's release end date").'' : Toolkit::formatDate($event['Event']['release_date_end']); ?> +
  • +
+ + + +
+ + + + + +
+
+ + +
+
+ + + ( Saved ) + + - + +
+
+
+ 'rubrics', $viewData , 'evaluate'=>1, 'user'=>$user, 'event'=>$event); + echo $this->element('rubrics/ajax_rubric_view', $params); + ?> + + + + +
+ + submit(__('Save This Section', true), array('name' => $user['id'], 'div' => 'saveThisSection')); ?> + + submit(__('Save This Section', true), array('disabled' => true, 'div' => 'saveThisSection')); ?> +
+ +
likert'>
+
+
+
+
+ +
+
+
+ + +
+
+ + + + + + + + submit(__('Submit to Complete the Evaluation', true), array('div'=>'submitComplete')); + } else { + echo $form->submit(__('Submit to Complete the Evaluation', true), array('disabled'=>'true','div'=>'submitComplete')); echo "
"; + echo isset($preview) ? "
".__('This is a preview. All submissions are disabled.', true).'
' : ""; + echo !$allDone ? "
".__("Please complete the questions for all group members, pressing 'Save This Section' button for each one.", true).'
' : ""; + echo $comReq ? "
".__('Please enter all the comments for all the group members before submitting.', true).'
' : ""; + } + ?> +
+ diff --git a/app/views/elements/evaluations/simple_eval_form.ctp b/app/views/elements/evaluations/simple_eval_form.ctp index 7e1cd6b98..245626e10 100644 --- a/app/views/elements/evaluations/simple_eval_form.ctp +++ b/app/views/elements/evaluations/simple_eval_form.ctp @@ -142,7 +142,7 @@ - :  + : @@ -152,35 +152,31 @@
  • -
  • (Must) ' : '(Optional)' ;?> .
  • +
  • (Required) ' : '(Optional)' ;?> .
  • - '._t("Evaluation's release end date").'' : - date('l, F j, Y g:i a', strtotime($event['Event']['release_date_end'])); ?> + '._t("Evaluation's release end date").'' : Toolkit::formatDate($event['Event']['release_date_end']); ?>
  • + 1)?'s':''; + echo $day['Penalty']['days_late'].' day'.$mult.' late: '.$day['Penalty']['percent_penalty'].'% deduction.
    '; + } + echo $penaltyFinal['Penalty']['percent_penalty'].'% is deducted afterwards.'; + } else { + echo 'No penalty is specified for this evaluation.'; + } + ?> +
    +
    -
    diff --git a/app/views/evaluations/rubric_eval_form.ctp b/app/views/evaluations/rubric_eval_form.ctp index d38933b8b..5b25bfe25 100644 --- a/app/views/evaluations/rubric_eval_form.ctp +++ b/app/views/evaluations/rubric_eval_form.ctp @@ -1,154 +1,2 @@ - -script('ricobase')?> -script('ricoeffects')?> -script('ricoanimation')?> -script('ricopanelcontainer')?> -script('ricoaccordion')?> -hidden('Evaluation/id'); ?> - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - -
    - : -
      -
    • EACH of your peer\'s name to rate his/her performance.')?>
    • -
    • ('.__('Required', true).'' : __('Optional', true) ;?>).
    • -
    • -
    • -
    • NOTE: You can click the "Submit to Complete the Evaluation" button only AFTER all evaluations are completed.')?>
    • - -
    • -
    - - - -
    - - - - - -
    -
    - - -
    -
    - - - ( Saved ) - - - - -
    -
    -
    - 'rubrics', $viewData , 'evaluate'=>1, 'user'=>$user, 'event'=>$event); - echo $this->element('rubrics/ajax_rubric_view', $params); - ?> - - - -
    - submit('Save This Section', array('name'=>$user['id'], 'div'=>'saveThisSection')); - echo "
    ".__('Please complete all the questions marked red before saving.
    ', true).""; - echo __('Make sure you save this section before moving on to the other ones!', true)."

    "; - ?> -
    -
    -
    - -
    -
    - - - -
    -
    - - - - - - - - submit(__('Submit to Complete the Evaluation', true), array('div'=>'submitComplete')); - } else { - echo $form->submit(__('Submit to Complete the Evaluation', true), array('disabled'=>'true','div'=>'submitComplete')); echo "
    "; - echo !$allDone ? "
    ".__("Please complete the questions for all group members, pressing 'Save This Section' button for each one.
    ", true) : ""; - echo $comReq ? "
    ".__('Please enter all the comments for all the group members before submitting.
    ', true) : ""; - } - ?> -
    - +element('evaluations/rubric_eval_form'); diff --git a/app/views/rubrics/edit.ctp b/app/views/rubrics/edit.ctp index 5ba42dae0..d2a18071b 100644 --- a/app/views/rubrics/edit.ctp +++ b/app/views/rubrics/edit.ctp @@ -24,7 +24,7 @@ $url = $this->action == 'copy' ? 'add' : $this->action; Form->input('criteria', array('id' => 'criteria', 'options' => array_combine(range(1,25), range(1,25)), 'default' => 3, - 'label' => __('Number of Criteria:', true), + 'label' => __('Number of Criteria', true), 'style'=>'width:50px;', 'disabled' => $readonly));?>
    @@ -62,11 +62,15 @@ $url = $this->action == 'copy' ? 'add' : $this->action;

    - +

    -
    ' : 'style="display: block; background: #FFF;"'; ?>> -element('rubrics/ajax_rubric_'.($this->action == 'view' ? 'view' : 'edit'), array('data' => $data, 'readonly' => $readonly, 'evaluate' => $evaluate)); ?> +
    + + element('rubrics/ajax_rubric_edit', array('data' => $data, 'readonly' => $readonly, 'evaluate' => $evaluate)); ?> + + element('evaluations/rubric_eval_form', Toolkit::getRubricEvalDemoData($data));?> +
    diff --git a/app/views/simple_evaluations/view.ctp b/app/views/simple_evaluations/view.ctp index 47794a664..d3d036a35 100644 --- a/app/views/simple_evaluations/view.ctp +++ b/app/views/simple_evaluations/view.ctp @@ -39,50 +39,5 @@
    -element('evaluations/simple_eval_form', 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' => 0, - 'evaluateeCount' => 2, - 'fullName' => User::get('full_name'), - 'remaining' => $data['SimpleEvaluation']['point_per_member'] * 3, - 'preview' => true, -)); -?> -
    \ No newline at end of file + element('evaluations/simple_eval_form', Toolkit::getSimpleEvalDemoData($data['SimpleEvaluation']['point_per_member'] * 3));?> +
    From 9955db94854b4d03ebd93f06c0a05dcf54215c9a Mon Sep 17 00:00:00 2001 From: Compass Date: Sun, 23 Feb 2014 15:16:21 -0800 Subject: [PATCH 11/23] Refactor mixeval to use unified preview The preview section shows the same as what student sees --- app/controllers/evaluations_controller.php | 1 + app/libs/toolkit.php | 76 ++++++++- app/tests/cases/system/add_mixeval.test.php | 144 ++++++++-------- .../evaluations/mixeval_eval_form.ctp | 157 ++++++++++++++++++ .../mixevals/view_mixeval_details.ctp | 2 +- app/views/evaluations/mixeval_eval_form.ctp | 154 +---------------- app/views/mixevals/view.ctp | 32 +--- 7 files changed, 313 insertions(+), 253 deletions(-) create mode 100644 app/views/elements/evaluations/mixeval_eval_form.ctp diff --git a/app/controllers/evaluations_controller.php b/app/controllers/evaluations_controller.php index a859b0d64..52c7fc1bd 100644 --- a/app/controllers/evaluations_controller.php +++ b/app/controllers/evaluations_controller.php @@ -936,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 { diff --git a/app/libs/toolkit.php b/app/libs/toolkit.php index dc8630eb1..a22feb1d4 100644 --- a/app/libs/toolkit.php +++ b/app/libs/toolkit.php @@ -197,7 +197,7 @@ static function getSimpleEvalDemoData($points) ), ), 'courseId' => 0, - 'userId' => 0, + 'userId' => 1, 'evaluateeCount' => 2, 'fullName' => User::get('full_name'), 'remaining' => $points, @@ -214,7 +214,7 @@ static function getSimpleEvalDemoData($points) * @access public * @return array demo data */ - static function getRubricEvalDemoData($data) + static function getRubricEvalDemoData() { return array( 'event' => array( @@ -254,12 +254,78 @@ static function getRubricEvalDemoData($data) ), ), 'courseId' => 0, - 'userId' => 0, + 'userId' => 1, 'evaluateeCount' => 2, 'fullName' => User::get('full_name'), - 'remaining' => $data['SimpleEvaluation']['point_per_member'] * 3, '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, + ); + } } diff --git a/app/tests/cases/system/add_mixeval.test.php b/app/tests/cases/system/add_mixeval.test.php index d2f62886e..1e6091b2f 100644 --- a/app/tests/cases/system/add_mixeval.test.php +++ b/app/tests/cases/system/add_mixeval.test.php @@ -2,7 +2,7 @@ require_once('system_base.php'); class AddMixEvalTestCase extends SystemBaseTestCase -{ +{ protected $mixeval = ''; @@ -14,24 +14,24 @@ public function startCase() $this->web_driver = new SystemWebDriver($wd_host); $this->session = $this->web_driver->session('firefox'); $this->session->open($this->url); - + $w = new PHPWebDriver_WebDriverWait($this->session); $this->session->deleteAllCookies(); $login = PageFactory::initElements($this->session, 'Login'); $home = $login->login('root', 'ipeeripeer'); } - + public function endCase() { $this->session->deleteAllCookies(); $this->session->close(); } - + public function testAddMixEval() { $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Home'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Evaluation')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Evaluation Tools'); @@ -39,32 +39,32 @@ public function testAddMixEval() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluations')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Mixed Evaluations'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Mixed Evaluation')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Mixed Evaluations > Add'); - + // template info $name = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalName'); $name->sendKeys('Final Project Evaluation'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalAvailabilityPublic')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalZeroMark')->click(); } - - public function testAddLikert() + + public function testAddLikert() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[type="button"]')->click(); - + $question = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion0Title'); $question->sendKeys('In your opinion, how is their work ethics?'); - + $instructions = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion0Instructions'); $instructions->sendKeys('Please be honest.'); - + $marks = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, "MixevalQuestion0Multiplier"); $marks->sendKeys('8'); - + $add = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="addDesc(0);"]'); for ($i=0; $i<5; $i++) { $add->click(); @@ -81,33 +81,33 @@ function($session) { $desc->sendKeys($mark.' marks'); } } - + public function testAddSentence() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="MixevalMixevalQuestionTypePeer"] option[value="3"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="insertQ(false);"]')->click(); - + $question = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion1Title'); $question->sendKeys('Which part of the project was their greatest contribution?'); - + $instructions = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion1Instructions'); $instructions->sendKeys('Choose one of the following: Research, Report, Presentation.'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion1Required')->click(); } - + public function testAddParagraph() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="MixevalMixevalQuestionTypePeer"] option[value="2"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="insertQ(false);"]')->click(); - + $question = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion2Title'); $question->sendKeys('What have they done well? How can they improve?'); - + $instructions = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion2Instructions'); $instructions->sendKeys('Please give constructive comments.'); } - + public function testAddScoreDropdown() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="MixevalMixevalQuestionTypePeer"] option[value="4"]')->click(); @@ -115,13 +115,13 @@ public function testAddScoreDropdown() $question = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion3Title'); $question->sendKeys('Distributed Marks'); - + $instructions = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion3Instructions'); $instructions->sendKeys('Distribute the marks among your members.'); } - + public function testSubmitAndError() - { + { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[type="submit"]')->click(); // wait for creation of template to finish $w = new PHPWebDriver_WebDriverWait($this->session); @@ -130,7 +130,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The mixed evaluation was saved successfully.'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Default Mix Evaluation')->click(); @@ -141,11 +141,11 @@ function($session) { $this->session->open(str_replace('view', 'edit', $this->mixeval)); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'flashMessage')->text(); $this->assertEqual($msg, 'Default Mix Evaluation cannot be edited now that submissions have been made. Please make a copy.'); - + $this->session->open($this->url.'evaltools'); $eval = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Final Project Evaluation'); $this->assertTrue(!empty($eval)); - + $this->waitForLogoutLogin('instructor1'); $this->session->open($this->url.'mixevals/index'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Final Project Evaluation')->click(); @@ -174,7 +174,7 @@ public function testCopyTemplate() $this->assertNull($zero->attribute('checked')); $zero = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalZeroMark'); $this->assertTrue($zero->attribute('checked')); - + // 1st question - Likert $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion0Title'); $this->assertEqual($title->attribute('value'), 'In your opinion, how is their work ethics?'); @@ -194,7 +194,7 @@ public function testCopyTemplate() $this->assertEqual($desc4->attribute('value'), '6 marks'); $desc5 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestionDesc4Descriptor'); $this->assertEqual($desc5->attribute('value'), '8 marks'); - + // 2nd question - Sentence $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion1Title'); $this->assertEqual($title->attribute('value'), 'Which part of the project was their greatest contribution?'); @@ -202,7 +202,7 @@ public function testCopyTemplate() $this->assertEqual($instr->text(), 'Choose one of the following: Research, Report, Presentation.'); $req = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion1Required'); $this->assertNull($req->attribute('checked')); - + // 3rd question - Paragraph $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion2Title'); $this->assertEqual($title->attribute('value'), 'What have they done well? How can they improve?'); @@ -210,7 +210,7 @@ public function testCopyTemplate() $this->assertEqual($instr->text(), 'Please give constructive comments.'); $req = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion2Required'); $this->assertTrue($req->attribute('checked')); - + // save $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[type="submit"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -221,18 +221,18 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The mixed evaluation was saved successfully.'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Copy of Final Project Evaluation')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Mixed Evaluations > View > Copy of Final Project Evaluation'); - + // delete $this->session->open(str_replace('view', 'delete', $this->session->url())); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The Mixed Evaluation was removed successfully.'); $this->waitForLogoutLogin('root'); } - + public function testViewTemplate() { $this->session->open($this->mixeval); @@ -241,17 +241,17 @@ public function testViewTemplate() $zero = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, "html/body/div[1]/div[3]/dl/dd[4]")->text(); $this->assertEqual($zero, 'On'); $req = count($this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'span[class="required orangered floatright"]')); - $this->assertEqual($req, 3); - $total = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CLASS_NAME, 'marks')->text(); - $this->assertEqual($total, 'Total Marks: 18'); + $this->assertEqual($req, 9); + //$total = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CLASS_NAME, 'marks')->text(); + //$this->assertEqual($total, 'Total Marks: 18'); } - + public function testEditTemplate() { $this->session->open(str_replace('view', 'edit', $this->mixeval)); // delete the score dropdown question $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[onclick="removeQ(3, 0); return false;"]')->click(); - + // moving questions // move up the first question $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[onclick="upQ(0, 0); return false;"]')->click(); @@ -292,7 +292,7 @@ function($session) { ); $quesNum = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'questionIndex1')->text(); $this->assertEqual($quesNum, '1.'); - + // adding question $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="MixevalMixevalQuestionTypePeer"] option[value="3"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="insertQ(false);"]')->click(); @@ -309,13 +309,13 @@ function($session) { return empty($ques); } ); - + // adding question $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="MixevalMixevalQuestionTypePeer"] option[value="2"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="insertQ(false);"]')->click(); $quesNum = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'questionIndex5')->text(); $this->assertEqual($quesNum, '1.'); - + // create template with one question $this->session->open($this->url.'mixevals/add'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="MixevalMixevalQuestionTypePeer"] option[value="2"]')->click(); @@ -339,22 +339,22 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The Mixed Evaluation was removed successfully.'); } - + public function testDeleteTemplate() { - $this->session->open($this->url.'mixevals/index'); + $this->session->open($this->url.'mixevals/index'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Final Project Evaluation')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Mixed Evaluations > View > Final Project Evaluation'); - + $templateId = end(explode('/', $this->session->url())); $this->session->open($this->url.'mixevals/delete/'.$templateId); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The Mixed Evaluation was removed successfully.'); } - + public function testSelfEvaluation() { $this->session->open($this->url.'mixevals/add'); @@ -363,7 +363,7 @@ public function testSelfEvaluation() $selfType = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalMixevalQuestionTypeSelf'); $this->assertTrue(!empty($selfType)); } - + public function testAddPeerQuestions() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="insertQ(false);"]')->click(); @@ -373,7 +373,7 @@ public function testAddPeerQuestions() $this->assertEqual($ques1, '1.'); $ques2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'questionIndex1')->text(); $this->assertEqual($ques2, '2.'); - + // question titles $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion0Title')->sendKeys('Peer optional'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion1Title')->sendKeys('Peer required'); @@ -388,7 +388,7 @@ public function testAddPeerQuestions() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="addDesc(1);"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="addDesc(1);"]')->click(); } - + public function testAddSelfQuestions() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="insertQ(true);"]')->click(); @@ -423,7 +423,7 @@ function($session) { } ); } - + public function testViewSelfEvaluation() { $peer = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="ajaxListDiv"]/div/table/tbody/tr[3]/td[4]/div'); @@ -432,7 +432,7 @@ public function testViewSelfEvaluation() $this->assertEqual($self->text(), '3'); $total = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="ajaxListDiv"]/div/table/tbody/tr[3]/td[6]/div'); $this->assertEqual($total->text(), '4'); - + // view evaluation $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'With Self-Evaluation')->click(); $this->mixeval = $this->session->url(); @@ -440,26 +440,26 @@ public function testViewSelfEvaluation() $self = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/dl/dd[6]'); $this->assertEqual($self->text(), 'On'); // check section headings - $peer = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/h2[2]'); + $peer = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'peer-title'); $this->assertEqual($peer->text(), 'Peer Evaluation Questions'); - $self = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/h2[3]'); + $self = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'self-title'); $this->assertEqual($self->text(), 'Self-Evaluation Questions'); - // check questions' order & numbering - $peer1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[1]/h3'); + // check questions' order & numbering, question id = q_USERID_QUESTION# + $peer1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_1'); $this->assertEqual($peer1->text(), '1. Peer optional'); - $peer2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[2]/h3'); + $peer2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_2'); $this->assertEqual($peer2->text(), "2. Peer required\n*"); - $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[3]/h3'); + $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_3'); $this->assertEqual($self1->text(), "1. Self 1\n*"); - $self2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[4]/h3'); + $self2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_4'); $this->assertEqual($self2->text(), "2. Self 2\n*"); - $self3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[5]/h3'); + $self3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_5'); $this->assertEqual($self3->text(), "3. Self 3\n*"); // check total marks - should only include required peer evaluation questions - $mark = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CLASS_NAME, 'marks'); - $this->assertEqual($mark->text(), 'Total Marks: 4'); + //$mark = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CLASS_NAME, 'marks'); + //$this->assertEqual($mark->text(), 'Total Marks: 4'); } - + public function testEditSelfEvaluation() { $this->session->open(str_replace('view', 'edit', $this->mixeval)); @@ -477,7 +477,7 @@ public function testEditSelfEvaluation() $self3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion4Title'); $this->assertEqual($self3->attribute('value'), 'Self 3'); } - + public function testEditReorderSelfEvaluation() { // test first peer evaluation question going up @@ -496,7 +496,7 @@ public function testEditReorderSelfEvaluation() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[onclick="downQ(4, 1); return false;"]')->click(); $num = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'questionIndex4')->text(); $this->assertEqual($num, '3.'); - + // test moving questions around $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[onclick="downQ(0, 0); return false;"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -527,17 +527,17 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->session->open($this->mixeval); - $peer1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[1]/h3'); + $peer1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_1'); $this->assertEqual($peer1->text(), "1. Peer required\n*"); - $peer2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[2]/h3'); + $peer2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_2'); $this->assertEqual($peer2->text(), "2. Peer optional"); - $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[3]/h3'); + $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_3'); $this->assertEqual($self1->text(), "1. Self 2\n*"); - $self2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[4]/h3'); + $self2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_4'); $this->assertEqual($self2->text(), "2. Self 3\n*"); - $self3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/div[5]/h3'); + $self3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'q_1_5'); $this->assertEqual($self3->text(), "3. Self 1\n*"); // delete mixeval @@ -545,4 +545,4 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The Mixed Evaluation was removed successfully.'); } -} \ No newline at end of file +} diff --git a/app/views/elements/evaluations/mixeval_eval_form.ctp b/app/views/elements/evaluations/mixeval_eval_form.ctp new file mode 100644 index 000000000..7cc511212 --- /dev/null +++ b/app/views/elements/evaluations/mixeval_eval_form.ctp @@ -0,0 +1,157 @@ +
    +

    + +

    +
    + +

    +
      + +
    • +
    • + +
    • +
    • tag('span', '*', array('class' => 'required orangered'))._t(' marks required questions.')?>
    • +
    • + + +
    • +
    + + + + + +
    + Form->create('EvaluationMixeval', array( + 'url' => $html->url('makeEvaluation') . '/'.$event['Event']['id'].'/'.$event['Group']['id']));?> + + + + + + + +

    + + 0 ) { + foreach($groupMembers as $row): $user = $row['User']; ?> +

    + 'mixevals', + 'zero_mark' => $mixeval['Mixeval']['zero_mark'], + 'questions' => $questions, + 'event' => $event, + 'user' => $user, + 'evaluatee_count' => $evaluatee_count, + 'self_eval' => 0, + 'eval' => 'Evaluation' + ); + echo $this->element('mixevals/view_mixeval_details', $params); + ?>
    + + + 0 && $enrol > 0) { ?> +

    + + $userId); + $params['self'] = $self; + echo $this->element('mixevals/view_mixeval_details', $params); + } + ?>
    +
    submit(__('Submit the Evaluation', true), array('div' => 'editSection', 'id' => 'submit', 'disabled' => isset($preview) ? 'true':'false')); ?>
    + end(); ?> +
    + + + + + + + + + + +
    diff --git a/app/views/elements/mixevals/view_mixeval_details.ctp b/app/views/elements/mixevals/view_mixeval_details.ctp index fd3edf508..f94386a7c 100644 --- a/app/views/elements/mixevals/view_mixeval_details.ctp +++ b/app/views/elements/mixevals/view_mixeval_details.ctp @@ -20,7 +20,7 @@ foreach ($questions as $ques) { $required = (!$ques['MixevalQuestion']['required']) ? '' : $html->tag('span', '*', array('class' => 'required orangered floatright')); $title = $ques['MixevalQuestion']['title']; - $title = $html->tag('h3', "$peerNum. $title $required"); + $title = $html->tag('h3', "$peerNum. $title $required", array('class' => 'question-title', 'id' => 'q_'.$user['id'].'_'.$num)); $class = $ques['MixevalQuestion']['required'] ? 'must' : ''; $peerNum++; diff --git a/app/views/evaluations/mixeval_eval_form.ctp b/app/views/evaluations/mixeval_eval_form.ctp index 352087f96..148cc8bd7 100644 --- a/app/views/evaluations/mixeval_eval_form.ctp +++ b/app/views/evaluations/mixeval_eval_form.ctp @@ -1,152 +1,2 @@ -
    -

    - -

    -
    - -

    -
      - -
    • -
    • - -
    • -
    • tag('span', '*', array('class' => 'required orangered'))._t(' marks required questions.')?>
    • -
    • - - -
    • -
    - - - - - -
    - Form->create('EvaluationMixeval', array( - 'url' => $html->url('makeEvaluation') . '/'.$event['Event']['id'].'/'.$event['Group']['id']));?> - "; ?> - "; ?> - "; ?> - "; ?> - "; ?> - - 0 ) { - foreach($groupMembers as $row): $user = $row['User']; ?> -

    - 'mixevals', - 'zero_mark' => $mixeval['Mixeval']['zero_mark'], - 'questions' => $questions, - 'event' => $event, - 'user' => $user, - 'evaluatee_count' => $evaluatee_count, - 'self_eval' => 0, - 'eval' => 'Evaluation' - ); - echo $this->element('mixevals/view_mixeval_details', $params); - ?>
    - - 0 && $enrol > 0) { ?> -

    - User::get('id')); - $params['self'] = $self; - echo $this->element('mixevals/view_mixeval_details', $params); - } - ?>
    -
    submit(__('Submit the Evaluation', true), array('div' => 'editSection', 'id' => 'submit')); ?>
    - end(); ?> -
    - - - - - - - - - - -
    \ No newline at end of file +element('evaluations/mixeval_eval_form'); diff --git a/app/views/mixevals/view.ctp b/app/views/mixevals/view.ctp index 1a8b2526d..86a6e989a 100644 --- a/app/views/mixevals/view.ctp +++ b/app/views/mixevals/view.ctp @@ -1,5 +1,4 @@
    -

    Info

    @@ -37,7 +36,7 @@ $totalMarks = $mixeval['total_marks']; $id = array('id' => 0); $event = array('Event' => $id, 'GroupEvent' => $id, 'Group' => $id); - + $params = array('controller' => 'mixevals', 'zero_mark' => $mixeval['zero_mark'], 'questions' => $questions, @@ -47,25 +46,12 @@ $params = array('controller' => 'mixevals', 'eval' => 'Evaluation', 'self_eval' => 0); ?> - 0) { - echo '

    Peer Evaluation Questions

    '; - echo $this->element('mixevals/view_mixeval_details', $params); -} -?> - - 0) { - echo '

    Self-Evaluation Questions

    '; - echo $this->element('mixevals/view_mixeval_details', $params); -} - -$required = $html->tag('span', '*', array('class' => 'required orangered')); -echo $html->para('note', $required . ' ' . _t('Indicates response required.')); -echo $html->para('marks', _t('Total Marks') . ": $totalMarks"); - -?> + 0): ?> +

    + +

    +
    + element('evaluations/mixeval_eval_form', Toolkit::getMixEvalDemoData($mixeval))?> +
    +
    From 3be893622ad695fb72498bad72fee2e5ed8f193c Mon Sep 17 00:00:00 2001 From: Compass Date: Mon, 24 Feb 2014 13:21:15 -0800 Subject: [PATCH 12/23] Fix #558, 404 when student submitting evaluation This only happens when iPeer is installed under a sub directory. --- app/views/elements/evaluations/mixeval_eval_form.ctp | 2 +- app/views/groups/import.ctp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/elements/evaluations/mixeval_eval_form.ctp b/app/views/elements/evaluations/mixeval_eval_form.ctp index 7cc511212..714d6bf56 100644 --- a/app/views/elements/evaluations/mixeval_eval_form.ctp +++ b/app/views/elements/evaluations/mixeval_eval_form.ctp @@ -33,7 +33,7 @@ Form->create('EvaluationMixeval', array( - 'url' => $html->url('makeEvaluation') . '/'.$event['Event']['id'].'/'.$event['Group']['id']));?> + 'url' => '/evaluations/makeEvaluation' . '/'.$event['Event']['id'].'/'.$event['Group']['id']));?> diff --git a/app/views/groups/import.ctp b/app/views/groups/import.ctp index 68a71c83d..9becca4e2 100644 --- a/app/views/groups/import.ctp +++ b/app/views/groups/import.ctp @@ -20,11 +20,11 @@ 29978043,
    29978051, - +

    Form->create(null, array('type' => 'file', 'url' => 'import/'.$courseId)); +echo $this->Form->create(null, array('type' => 'file', 'url' => '/import/'.$courseId)); echo $this->Form->input('file', array('type' => 'file', 'name' => 'file')); echo $this->Form->input('identifiers', array( 'type' => 'radio', @@ -41,4 +41,4 @@ echo $this->Form->input('update_groups', echo $this->Form->submit(__('Import', true)); echo $this->Form->end(); ?> - \ No newline at end of file + From c8434e377a7570dd239e847b33d586b129927ccb Mon Sep 17 00:00:00 2001 From: Compass Date: Wed, 26 Feb 2014 15:20:14 -0800 Subject: [PATCH 13/23] Revert a change made by previous commit that failed the tests --- app/views/groups/import.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/groups/import.ctp b/app/views/groups/import.ctp index 9becca4e2..7007d2711 100644 --- a/app/views/groups/import.ctp +++ b/app/views/groups/import.ctp @@ -24,7 +24,7 @@

    Form->create(null, array('type' => 'file', 'url' => '/import/'.$courseId)); +echo $this->Form->create(null, array('type' => 'file', 'url' => 'import/'.$courseId)); echo $this->Form->input('file', array('type' => 'file', 'name' => 'file')); echo $this->Form->input('identifiers', array( 'type' => 'radio', From 37b904494766cf7b9cdef0c8ba634d9d7b77bcf4 Mon Sep 17 00:00:00 2001 From: Compass Date: Wed, 26 Feb 2014 15:19:12 -0800 Subject: [PATCH 14/23] Fix mixeval result rendering error The radio value result was rendered off by 1 on mixeval result rendering page. e.g. 4 was rendered as 3 --- app/views/elements/evaluations/mixeval_details.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/elements/evaluations/mixeval_details.ctp b/app/views/elements/evaluations/mixeval_details.ctp index 7bd7daa9c..e1fee11f0 100644 --- a/app/views/elements/evaluations/mixeval_details.ctp +++ b/app/views/elements/evaluations/mixeval_details.ctp @@ -51,7 +51,7 @@ if ($details) { 'type' => 'radio', 'options' => $options, 'disabled' => true, - 'default' => $sub['selected_lom'] - 1, + 'default' => $sub['selected_lom'], 'before' => '
  • '.$name, 'after' => $grade.'
  • ' )); From a5be83afbf475d840fae7b9896793de8acc462a7 Mon Sep 17 00:00:00 2001 From: Compass Date: Wed, 26 Feb 2014 22:32:32 -0800 Subject: [PATCH 15/23] Fix the previous commit, attempt 2 --- .../cases/system/student_mixeval.test.php | 226 +++++++++--------- .../elements/evaluations/mixeval_details.ctp | 5 +- 2 files changed, 116 insertions(+), 115 deletions(-) diff --git a/app/tests/cases/system/student_mixeval.test.php b/app/tests/cases/system/student_mixeval.test.php index 7baa6a48a..70ca90674 100644 --- a/app/tests/cases/system/student_mixeval.test.php +++ b/app/tests/cases/system/student_mixeval.test.php @@ -5,7 +5,7 @@ class studentMixeval extends SystemBaseTestCase { protected $eventId = 0; protected $templateId = 0; - + public function startCase() { $this->getUrl(); @@ -14,19 +14,19 @@ public function startCase() $this->web_driver = new SystemWebDriver($wd_host); $this->session = $this->web_driver->session('firefox'); $this->session->open($this->url); - + $w = new PHPWebDriver_WebDriverWait($this->session); $this->session->deleteAllCookies(); $login = PageFactory::initElements($this->session, 'Login'); $home = $login->login('root', 'ipeeripeer'); } - + public function endCase() { $this->session->deleteAllCookies(); $this->session->close(); } - + public function testCreateEvent() { $this->session->open($this->url.'events/add/1'); @@ -47,11 +47,11 @@ public function testCreateEvent() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateEnd')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '28')->click(); - + // add penalty $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Penalty')->click();; $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="Penalty0PercentPenalty"] option[value="10"]')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="GroupGroup"] option[value="1"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="GroupGroup"] option[value="2"]')->click(); @@ -65,17 +65,17 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Add event successful!'); } - + public function testStudent() { $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); - + // check penalty note $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Show/Hide Late Penalty Policy')->click(); $penalty = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'penalty')->text(); $this->assertEqual($penalty, "1 day late: 10% deduction.\n10% is deducted afterwards."); - + // help text $help = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[2]/p'); $this->assertEqual($help->text(), 'Please rate performance.'); @@ -89,7 +89,7 @@ public function testStudent() $help = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[12]/p'); $this->assertEqual($help->text(), 'Please give a paragraph answer.'); $this->assertEqual($help->attribute('class'), 'help green'); - + // required questions $star = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'span[class="required orangered floatright"]'); $this->assertEqual(count($star), 10); @@ -103,7 +103,7 @@ public function testStudent() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '66EvaluationMixeval4QuestionComment')->sendKeys('absolutely'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::NAME, 'data[6][EvaluationMixeval][5][question_comment]')->sendKeys('definitely'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '66EvaluationMixeval6QuestionComment')->sendKeys('very easy'); - + // Matt Student's evaluation // Likert questions $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[8]/table/tbody/tr[2]/td[5]/input')->click(); @@ -112,7 +112,7 @@ public function testStudent() // short and long answers $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '77EvaluationMixeval4QuestionComment')->sendKeys('absolutely'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '77EvaluationMixeval6QuestionComment')->sendKeys('very easy'); - + // submit $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -123,7 +123,7 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, "flashMessage")->text(); $this->assertEqual($msg, 'Your answers have been saved. Please answer all the required questions before it can be considered submitted.'); - + // answer the required question that was left unanswered $this->session->elementWithWait(PHPWebDriver_WebDriverBy::NAME, 'data[7][EvaluationMixeval][5][question_comment]')->sendKeys('definitely'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit')->click(); @@ -135,7 +135,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Your Evaluation was submitted successfully.'); } - + public function testReSubmit() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); @@ -161,12 +161,12 @@ function($session) { $this->secondStudent(); $this->tutor(); } - + public function testBasicResult() { $this->waitForLogoutLogin('root'); $this->removeFromGroup(); - + $this->session->open($this->url.'events/index/1'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $this->eventId = end(explode('/', $this->session->url())); @@ -179,7 +179,7 @@ public function testBasicResult() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateBegin')->clear(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateBegin')->sendKeys(date('Y-m-d H:i:s')); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[value="Submit"]')->click(); - $w = new PHPWebDriver_WebDriverWait($this->session); + $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); @@ -204,7 +204,7 @@ function($session) { $this->assertEqual($matt->text(), '(not submitted)'); $matt = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[4]/td[4]'); $this->assertEqual($matt->text(), '---'); - + // view summary table $this->session->open($this->url.'evaluations/viewEvaluationResults/'.$this->eventId.'/1'); $notSubmit = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[1]/th')->text(); @@ -215,7 +215,7 @@ function($session) { $this->assertEqual($left, 'Left the group, but had submitted or were evaluated'); $left = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[3]/tbody/tr[2]/td')->text(); $this->assertEqual($left, 'Tutor 1 (TA)'); - + $total = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[1]/th[2]')->text(); $this->assertEqual($total, 'Total:( /3.00)'); $ed = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[2]/td[2]')->text(); @@ -227,15 +227,15 @@ function($session) { $avg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[4]/tbody/tr[5]/td[2]')->text(); $this->assertEqual($avg, '2.12'); } - + public function testDetailResult() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Detail')->click(); - + // auto-release results messages $msg = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, 'autoRelease_msg'); $this->assertTrue(!empty($msg)); - + // view summary table $notSubmit = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[2]/tbody/tr[1]/th')->text(); $this->assertEqual($notSubmit, 'Have not submitted their evaluations'); @@ -245,7 +245,7 @@ public function testDetailResult() $this->assertEqual($left, 'Left the group, but had submitted or were evaluated'); $left = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[3]/tbody/tr[2]/td')->text(); $this->assertEqual($left, 'Tutor 1 (TA)'); - + $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[1]/th[2]')->text(); $this->assertEqual($header, '1 (/1.0)'); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[1]/th[3]')->text(); @@ -254,7 +254,7 @@ public function testDetailResult() $this->assertEqual($header, '3 (/1.0)'); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[1]/th[5]')->text(); $this->assertEqual($header, 'Total (/3.00)'); - + $ed = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[2]/td[2]')->text(); $this->assertEqual($ed, '0.90'); $ed = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[2]/td[3]')->text(); @@ -263,7 +263,7 @@ public function testDetailResult() $this->assertEqual($ed, '0.90'); $ed = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[2]/td[5]')->text(); $this->assertEqual($ed, '2.80 - 0.28 = 2.52 (84.00%)'); - + $alex = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[3]/td[2]')->text(); $this->assertEqual($alex, '0.80'); $alex = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[3]/td[3]')->text(); @@ -291,27 +291,27 @@ public function testDetailResult() $avg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[5]/td[5]')->text(); $this->assertEqual($avg, '2.12'); } - + public function testIndivDetailResults() { $final = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="panel1Content"]/b')->text(); $this->assertEqual($final, 'Final Total: 2.80 - 0.28 = 2.52 (84%) << Above Group Average >>'); $penalty = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="panel1Content"]/font')->text(); $this->assertEqual($penalty, '10%'); - + $required = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'span[class="required orangered"]'); $this->assertEqual(count($required), 15); $unEnrolled = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'label[class="blue"]'); $this->assertEqual(count($unEnrolled), 17); $this->assertEqual($unEnrolled[0]->text(), 'Tutor 1:'); - + $likerts = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[checked="checked"]'); - + $this->assertTrue($likerts[0]->attribute('disabled')); - $this->assertEqual($likerts[0]->attribute('value'), 3); + $this->assertEqual($likerts[0]->attribute('value'), 0.8); $ques1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[1]/li/label[7]'); $this->assertEqual($ques1->text(), 'Grade: 0.80 / 1'); - + $this->assertTrue($likerts[1]->attribute('disabled')); $this->assertTrue($likerts[1]->attribute('value'), 4); $ques2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[2]/li/label[7]'); @@ -332,19 +332,19 @@ public function testIndivDetailResults() $this->assertEqual($ques4->text(), 'Grade: 1.00 / 1'); $ques4 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[2]/li/label[8]'); $this->assertEqual($ques4->text(), '(Highest)'); - + $this->assertTrue($likerts[4]->attribute('disabled')); - $this->assertEqual($likerts[4]->attribute('value'), 3); + $this->assertEqual($likerts[4]->attribute('value'), 0.8); $ques5 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[1]/li/label[7]'); $this->assertEqual($ques5->text(), 'Grade: 0.80 / 1'); - + $this->assertTrue($likerts[5]->attribute('disabled')); $this->assertTrue($likerts[5]->attribute('value'), 4); $ques6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[2]/li/label[7]'); $this->assertEqual($ques6->text(), 'Grade: 1.00 / 1'); $ques6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[2]/li/label[8]'); $this->assertEqual($ques6->text(), '(Highest)'); - + $comm1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[4]/li[1]')->text(); $this->assertEqual(substr($comm1, -3), 'cat'); $comm2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[4]/li[2]')->text(); @@ -358,7 +358,7 @@ public function testIndivDetailResults() $comm6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[6]/li[2]')->text(); $this->assertEqual(substr($comm6, -5), 'green'); } - + public function testStudentResults() { $this->waitForLogoutLogin('redshirt0001'); @@ -368,12 +368,12 @@ public function testStudentResults() $required = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'span[class="required orangered"]'); $this->assertEqual(count($required), 5); - + $likerts = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[checked="checked"]'); $testShuffle = $this->shuffled($likerts->attribute('value')); $this->assertTrue($testShuffle); } - + public function shuffled($mark) { $likerts = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[checked="checked"]'); @@ -384,39 +384,39 @@ public function shuffled($mark) $this->assertTrue($likerts[4]->attribute('disabled')); $this->assertTrue($likerts[5]->attribute('disabled')); - if ($mark == '3') { - $this->assertEqual($likerts[0]->attribute('value'), 3); + if ($mark == '0.8') { + $this->assertEqual($likerts[0]->attribute('value'), 0.8); $ques1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[1]/li/label[6]'); $this->assertEqual($ques1->text(), 'Grade: 0.80 / 1'); - - $this->assertTrue($likerts[1]->attribute('value'), 4); + + $this->assertTrue($likerts[1]->attribute('value'), 1); $ques2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[2]/li/label[6]'); $this->assertEqual($ques2->text(), 'Grade: 1.00 / 1'); $ques2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[2]/li/label[7]'); $this->assertEqual($ques2->text(), '(Highest)'); - $this->assertTrue($likerts[2]->attribute('value'), 4); + $this->assertTrue($likerts[2]->attribute('value'), 1); $ques3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[1]/li/label[6]'); $this->assertEqual($ques3->text(), 'Grade: 1.00 / 1'); $ques3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[1]/li/label[7]'); $this->assertEqual($ques3->text(), '(Highest)'); - $this->assertTrue($likerts[3]->attribute('value'), 4); + $this->assertTrue($likerts[3]->attribute('value'), 1); $ques4 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[2]/li/label[6]'); $this->assertEqual($ques4->text(), 'Grade: 1.00 / 1'); $ques4 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[2]/li/label[7]'); $this->assertEqual($ques4->text(), '(Highest)'); - - $this->assertEqual($likerts[4]->attribute('value'), 3); + + $this->assertEqual($likerts[4]->attribute('value'), 0.8); $ques5 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[1]/li/label[6]'); $this->assertEqual($ques5->text(), 'Grade: 0.80 / 1'); - - $this->assertTrue($likerts[5]->attribute('value'), 4); + + $this->assertTrue($likerts[5]->attribute('value'), 1); $ques6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[2]/li/label[6]'); $this->assertEqual($ques6->text(), 'Grade: 1.00 / 1'); $ques6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[2]/li/label[7]'); $this->assertEqual($ques6->text(), '(Highest)'); - + $comm1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[4]/li[1]')->text(); $this->assertEqual($comm1, 'cat'); $comm2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[4]/li[2]')->text(); @@ -430,36 +430,36 @@ public function shuffled($mark) $comm6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[6]/li[2]')->text(); $this->assertEqual($comm6, 'green'); return true; - } else if ($mark == '4') { - $this->assertTrue($likerts[0]->attribute('value'), 4); + } else if ($mark == '1') { + $this->assertTrue($likerts[0]->attribute('value'), 1); $ques1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[1]/li/label[6]'); $this->assertEqual($ques1->text(), 'Grade: 1.00 / 1'); $ques1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[1]/li/label[7]'); $this->assertEqual($ques1->text(), '(Highest)'); - $this->assertEqual($likerts[1]->attribute('value'), 3); + $this->assertEqual($likerts[1]->attribute('value'), 0.8); $ques2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[1]/div[2]/li/label[6]'); $this->assertEqual($ques2->text(), 'Grade: 0.80 / 1'); - - $this->assertTrue($likerts[2]->attribute('value'), 4); + + $this->assertTrue($likerts[2]->attribute('value'), 1); $ques3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[1]/li/label[6]'); $this->assertEqual($ques3->text(), 'Grade: 1.00 / 1'); $ques3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[1]/li/label[7]'); $this->assertEqual($ques3->text(), '(Highest)'); - $this->assertTrue($likerts[3]->attribute('value'), 4); + $this->assertTrue($likerts[3]->attribute('value'), 1); $ques4 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[2]/li/label[6]'); $this->assertEqual($ques4->text(), 'Grade: 1.00 / 1'); $ques4 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/div[2]/li/label[7]'); $this->assertEqual($ques4->text(), '(Highest)'); - $this->assertTrue($likerts[4]->attribute('value'), 4); + $this->assertTrue($likerts[4]->attribute('value'), 1); $ques5 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[1]/li/label[6]'); $this->assertEqual($ques5->text(), 'Grade: 1.00 / 1'); $ques5 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[1]/li/label[7]'); $this->assertEqual($ques5->text(), '(Highest)'); - - $this->assertEqual($likerts[5]->attribute('value'), 3); + + $this->assertEqual($likerts[5]->attribute('value'), 0.8); $ques6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/div[2]/li/label[6]'); $this->assertEqual($ques6->text(), 'Grade: 0.80 / 1'); @@ -480,7 +480,7 @@ public function shuffled($mark) return false; } } - + public function testBasic() { $this->waitForLogoutLogin('root'); @@ -493,7 +493,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td'); @@ -510,11 +510,11 @@ function($session) { $this->assertEqual($ques3, '3. Submitted work on time *'); $avg3 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[3]/li')->text(); $this->assertEqual($avg3, 'Average: 0.90 / 1'); - + $required = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'span[class="required orangered"]'); $this->assertEqual(count($required), 3); } - + public function testNotReleased() { $this->waitForLogoutLogin('root'); @@ -528,7 +528,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td'); @@ -548,7 +548,7 @@ function($session) { $ques6 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[6]/li'); $this->assertEqual($ques6->text(), 'Comments Not Released Yet'); } - + public function testReviewed() { $this->waitForLogoutLogin('root'); @@ -565,7 +565,7 @@ function($session) { $review = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="ajaxListDiv"]/div/table/tbody/tr[2]/td[6]/div')->text(); $this->assertEqual($review, 'Reviewed'); } - + public function testIndivGrades() { $this->session->open($this->url.'evaluations/viewEvaluationResults/'.$this->eventId.'/1/Detail'); @@ -577,20 +577,20 @@ function($session) { return ($button->attribute('value') == 'Unrelease Grades'); } ); - + $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td')->text(); $this->assertEqual($rating, '2.80 - (0.28)* = 2.52 ( )* : 10% late penalty. (84%)'); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h2/font')->text(); $this->assertEqual($header, 'Comments Not Released Yet'); - + $this->waitForLogoutLogin('redshirt0002'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'font[color="red"]')->text(); $this->assertEqual($header, 'Comments/Grades Not Released Yet'); } - + public function testIndivComments() { $this->waitForLogoutLogin('root'); @@ -603,7 +603,7 @@ function($session) { return ($button->attribute('value') == 'Release Grades'); } ); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="panel1Content"]/input[2]')->click(); $w->until( function($session) { @@ -611,7 +611,7 @@ function($session) { return ($button->attribute('value') == 'Unrelease Comments'); } ); - + $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td')->text(); @@ -634,7 +634,7 @@ function($session) { } ); } - + public function testReleaseAllComments() { $this->session->open($this->url.'evaluations/view/'.$this->eventId); @@ -646,22 +646,22 @@ function($session) { return ($comments->text() == 'Some Released'); } ); - + $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h2/font'); $this->assertEqual($header->text(), 'Grades Not Released Yet'); - + $this->waitForLogoutLogin('redshirt0002'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h2/font'); $this->assertEqual($header->text(), 'Grades Not Released Yet'); - + $this->waitForLogoutLogin('redshirt0003'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h2/font'); $this->assertEqual($header->text(), 'Grades Not Released Yet'); - + $this->waitForLogoutLogin('root'); $this->session->open($this->url.'evaluations/view/'.$this->eventId); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Unrelease All Comments')->click(); @@ -672,7 +672,7 @@ function($session) { } ); } - + public function testReleaseAllGrades() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Release All Grades')->click(); @@ -690,21 +690,21 @@ function($session) { $this->assertEqual($rating->text(), '2.80 - (0.28)* = 2.52 ( )* : 10% late penalty. (84%)'); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h2/font'); $this->assertEqual($header->text(), 'Comments Not Released Yet'); - + $this->waitForLogoutLogin('redshirt0002'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td'); $this->assertEqual($rating->text(), '2.40 - (0.24)* = 2.16 ( )* : 10% late penalty. (72%)'); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h2/font'); $this->assertEqual($header->text(), 'Comments Not Released Yet'); - + $this->waitForLogoutLogin('redshirt0003'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td'); $this->assertEqual($rating->text(), '1.87 - (0.19)* = 1.68 ( )* : 10% late penalty. (56%)'); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h2/font'); $this->assertEqual($header->text(), 'Comments Not Released Yet'); - + $this->waitForLogoutLogin('root'); $this->session->open($this->url.'evaluations/view/'.$this->eventId); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Unrelease All Grades')->click(); @@ -715,7 +715,7 @@ function($session) { } ); } - + public function testSavedAnswersNotSubmitted() { // unsubmitted answers should not show up in student / instructor's results views @@ -748,7 +748,7 @@ function($session) { return $grades == 'Some Released'; } ); - + // Matt Student submits $this->waitForLogoutLogin('redshirt0003'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); @@ -775,14 +775,14 @@ function($session) { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td')->text(); $this->assertEqual($rating, '2.80 - (0.28)* = 2.52 ( )* : 10% late penalty. (84%)'); - + // Matt's evaluation for Ed is not counted yet - it's not submitted $this->waitForLogoutLogin('root'); $this->session->open($this->url.'evaluations/viewEvaluationResults/'.$this->eventId.'/1/Detail'); $mark = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[2]/td[5]')->text(); $this->assertEqual($mark, '2.80 - 0.28 = 2.52 (84.00%)'); } - + public function testSubmissionsAfterEvalReleased() { $this->waitForLogoutLogin('redshirt0003'); @@ -804,13 +804,13 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Your Evaluation was submitted successfully.'); - + // check Matt Student's results $mixevals = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation'); $mixevals[1]->click(); $rating = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td'); $this->assertEqual($rating->text(), '1.87 - (0.19)* = 1.68 ( )* : 10% late penalty. (56%)'); - + // Ed Student's grades and comments should not be released $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); @@ -819,7 +819,7 @@ function($session) { $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'font[color="red"]'); $this->assertEqual($header->text(), 'Comments/Grades Not Released Yet'); } - + public function testDeleteEvent() { $this->waitForLogoutLogin('root'); @@ -834,23 +834,23 @@ function($session) { $this->assertEqual($msg, 'The event has been deleted successfully.'); $this->assignToGroup(); } - + public function testScoreDropdown() { // TODO - put scoredropdown question into sample mixed eval template and // adjust tests accordingly - + // add template $this->session->open($this->url.'mixevals/add'); $name = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalName'); $name->sendKeys('Final Project Evaluation'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="MixevalMixevalQuestionTypePeer"] option[value="4"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[onclick="insertQ(false);"]')->click(); $question = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion0Title'); $question->sendKeys('Distributed Marks'); - + $instructions = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'MixevalQuestion0Instructions'); $instructions->sendKeys('Distribute the marks among your members.'); @@ -886,7 +886,7 @@ function($session) { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateEnd')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '28')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="GroupGroup"] option[value="1"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); @@ -895,7 +895,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + // do the evaluation $this->waitForLogoutLogin('tutor1'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); @@ -904,7 +904,7 @@ function($session) { $this->assertEqual(count($marks), 93); $selects = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select'); $this->assertEqual(count($selects), 3); - + // do the evaluation $this->waitForLogoutLogin('redshirt0001'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Mixed Evaluation')->click(); @@ -932,7 +932,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + // delete the event and template $this->waitForLogoutLogin('root'); $this->session->open($this->url.'events/index/1'); @@ -950,7 +950,7 @@ function($session) { } ); } - + public function testSelfEvaluation() { $this->session->open($this->url.'mixevals/add'); @@ -983,7 +983,7 @@ function($session) { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'With Self-Evaluation')->click(); $this->templateId = end(explode('/', $this->session->url())); } - + public function testSelfEvaluationEvent() { $this->session->open($this->url.'events/add/1'); @@ -1016,7 +1016,7 @@ function($session) { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Eval with Self-Eval')->click(); $this->eventId = end(explode('/', $this->session->url())); } - + public function testAnswerSelfEval() { $this->waitForLogoutLogin('redshirt0001'); @@ -1034,7 +1034,7 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Your Evaluation was submitted successfully.'); - + $this->waitForLogoutLogin('redshirt0002'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Eval with Self-Eval')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[2]/table/tbody/tr[2]/td[1]/input')->click(); @@ -1053,7 +1053,7 @@ function($session) { $text = $this->session->elements(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="3535EvaluationMixeval3QuestionComment"]'); $this->assertTrue(empty($text)); // no self-evaluation questions for tutors } - + public function testEvaluationResults() { $this->waitForLogoutLogin('root'); @@ -1072,7 +1072,7 @@ public function testEvaluationResults() $this->assertEqual($matt->text(), '4.17 (83.30%)'); $avg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[5]/tbody/tr[5]/td[2]'); $this->assertEqual($avg->text(), '3.61'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Detail')->click(); $peer1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[1]/th[2]'); $this->assertEqual($peer1->text(), '1 (/5.0)'); @@ -1084,14 +1084,14 @@ public function testEvaluationResults() $this->assertEqual($matt->text(), '4.17'); $avg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table[4]/tbody/tr[5]/td[2]'); $this->assertEqual($avg->text(), '3.61'); - + $selfPanel = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, 'panelSelf'); $this->assertTrue(!empty($selfPanel)); $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h3[1]'); $this->assertEqual($self1->text(), "1. self likert question *"); - $ed = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="Ques1001"]'); + $ed = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="Ques100700"]'); $this->assertTrue($ed->attribute('checked')); - $alex = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="Ques1100"]'); + $alex = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="Ques110350"]'); $this->assertTrue($alex->attribute('checked')); $self2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h3[2]'); $this->assertEqual($self2->text(), "2. self sentence question *"); @@ -1100,11 +1100,11 @@ public function testEvaluationResults() $alex = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/ul[2]/li[2]'); $this->assertEqual($alex->text(), "Alex Student:It was amazing."); } - + public function testStudentSelfEvaluationResult() { $this->session->open($this->url.'events/edit/'.$this->eventId); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateBegin')->clear(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateBegin')->clear(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateBegin')->sendKeys(date('Y-m-d H:i:s')); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -1120,7 +1120,7 @@ function($session) { $this->assertEqual($header->text(), 'Self-Evaluation'); $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h3[2]'); $this->assertEqual($self1->text(), "1. self likert question *"); - $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="Ques1051"]'); + $self1 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="Ques105700"]'); $this->assertTrue($self1->attribute('checked')); $self2 = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="mixeval_result"]/h3[3]'); $this->assertEqual($self2->text(), "2. self sentence question *"); @@ -1143,7 +1143,7 @@ function($session) { } ); } - + public function secondStudent() { $this->waitForLogoutLogin('redshirt0002'); @@ -1156,7 +1156,7 @@ public function secondStudent() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '55EvaluationMixeval4QuestionComment')->sendKeys('cat'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::NAME, 'data[5][EvaluationMixeval][5][question_comment]')->sendKeys('dog'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EvaluationMixeval5EvaluationMixeval6QuestionComment')->sendKeys('gerbil'); - + // Likert questions $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[8]/table/tbody/tr[2]/td[3]/input')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[9]/table/tbody/tr[2]/td[3]/input')->click(); @@ -1175,7 +1175,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Your Evaluation was submitted successfully.'); } - + public function tutor() { $this->waitForLogoutLogin('tutor1'); @@ -1196,7 +1196,7 @@ public function tutor() // short and long answers $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '66EvaluationMixeval4QuestionComment')->sendKeys('one'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::NAME, 'data[6][EvaluationMixeval][5][question_comment]')->sendKeys('two'); - + // Likert questions $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[14]/table/tbody/tr[2]/td[2]/input')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/div[3]/table/tbody/tr/td/form/div[15]/table/tbody/tr[2]/td[2]/input')->click(); @@ -1205,7 +1205,7 @@ public function tutor() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '77EvaluationMixeval4QuestionComment')->sendKeys('right'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::NAME, 'data[7][EvaluationMixeval][5][question_comment]')->sendKeys('left'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, '77EvaluationMixeval6QuestionComment')->sendKeys('forward'); - + // submit $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -1233,7 +1233,7 @@ function($session) { } ); } - + public function assignToGroup() { $this->session->open($this->url.'groups/edit/1'); @@ -1247,4 +1247,4 @@ function($session) { } ); } -} \ No newline at end of file +} diff --git a/app/views/elements/evaluations/mixeval_details.ctp b/app/views/elements/evaluations/mixeval_details.ctp index e1fee11f0..337a28f7b 100644 --- a/app/views/elements/evaluations/mixeval_details.ctp +++ b/app/views/elements/evaluations/mixeval_details.ctp @@ -41,8 +41,9 @@ if ($details) { if ($type == '1') { $step = $multiplier / ($scale - $zero_mark); $start = $zero_mark ? 0 : $step; - $options = array_map('number_format',range($start, $multiplier, $step), + $marks = array_map('number_format', range($start, $multiplier, $step), array_fill(0, $scale, 2)); + $options = array_combine($marks, $marks); $grade = ''; $grade .= (empty($descriptors[$sub['selected_lom']])) ? '' : @@ -51,7 +52,7 @@ if ($details) { 'type' => 'radio', 'options' => $options, 'disabled' => true, - 'default' => $sub['selected_lom'], + 'default' => $sub['grade'], 'before' => '
  • '.$name, 'after' => $grade.'
  • ' )); From 0b8c6caa4328b78f464f02d3a4e3cbff35547e5d Mon Sep 17 00:00:00 2001 From: Compass Date: Wed, 26 Feb 2014 22:35:55 -0800 Subject: [PATCH 16/23] Catch the exception with more information printed Default element WaitTimeOut exception doesn't give much information about the element. It was very difficult to debug after the exception is thrown. Now it's printing the element search method and value. --- .../cases/system/SystemWebDriverSession.php | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/app/tests/cases/system/SystemWebDriverSession.php b/app/tests/cases/system/SystemWebDriverSession.php index ec7ffe1b5..49fb91d46 100644 --- a/app/tests/cases/system/SystemWebDriverSession.php +++ b/app/tests/cases/system/SystemWebDriverSession.php @@ -7,22 +7,32 @@ class SystemWebDriverSession extends PHPWebDriver_WebDriverSession { public function elementWithWait($using, $value) { $selector = array('selector' => $using, 'value' => $value); $w = new PHPWebDriver_WebDriverWait($this, 30, 0.5, $selector); - $w->until( - function($session, $selector) { - return $session->element($selector['selector'], $selector['value']); - } - ); + try { + $w->until( + function($session, $selector) { + return $session->element($selector['selector'], $selector['value']); + } + ); + } catch (Exception $e) { + throw new Exception('Failed to wait for element '.$value. ' using '.$using.'.', 0, $e); + } + return $this->element($using, $value); } public function elementsWithWait($using, $value) { $selector = array('selector' => $using, 'value' => $value); $w = new PHPWebDriver_WebDriverWait($this, 30, 0.5, $selector); - $w->until( - function($session, $selector) { - return count($session->elements($selector['selector'], $selector['value'])); - } - ); + try { + $w->until( + function($session, $selector) { + return count($session->elements($selector['selector'], $selector['value'])); + } + ); + } catch (Exception $e) { + throw new Exception('Failed to wait for element '.$value. ' using '.$using.'.', 0, $e); + } + return $this->elements($using, $value); } -} \ No newline at end of file +} From 2cf686f62dc8b2440ec0e0c2ccb070206716321b Mon Sep 17 00:00:00 2001 From: Compass Date: Wed, 26 Feb 2014 22:38:18 -0800 Subject: [PATCH 17/23] Update guard plugin --- app/plugins/guard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/plugins/guard b/app/plugins/guard index e18195a20..329960c13 160000 --- a/app/plugins/guard +++ b/app/plugins/guard @@ -1 +1 @@ -Subproject commit e18195a20e71fa617606364f9829581c47fd3adc +Subproject commit 329960c13761bdfbd591251871aea5fb1c5bc540 From 0201c34794bd6f8f14ba015283880a94b88bae36 Mon Sep 17 00:00:00 2001 From: Michael Tang Date: Fri, 28 Feb 2014 16:29:18 -0800 Subject: [PATCH 18/23] Fix #542 The bug was in the conditions used in the find function. --- app/models/evaluation_base.php | 8 ++------ app/models/mixeval.php | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/models/evaluation_base.php b/app/models/evaluation_base.php index 403911baa..08eebfd99 100644 --- a/app/models/evaluation_base.php +++ b/app/models/evaluation_base.php @@ -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) { diff --git a/app/models/mixeval.php b/app/models/mixeval.php index 8ea44d852..c23d30602 100644 --- a/app/models/mixeval.php +++ b/app/models/mixeval.php @@ -220,12 +220,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) { From 0009b6c93a1fab7b32c9359fae16dfd4203a58c9 Mon Sep 17 00:00:00 2001 From: Compass Date: Mon, 3 Mar 2014 15:18:04 -0800 Subject: [PATCH 19/23] Fix #557, filters are failed on lists on dreamhost mysql_real_escape_string was used to escape the filters. However, it seems making a connection to db when it's called. On dreamhost, the default connection seems broken (to socket file /No-MySQL-hostname-was-specified, happens only on some hosting servers) So remove the escape function for now. The values are already escaped by cake. --- app/controllers/components/ajax_list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/components/ajax_list.php b/app/controllers/components/ajax_list.php index d8084c8d1..e15630b55 100644 --- a/app/controllers/components/ajax_list.php +++ b/app/controllers/components/ajax_list.php @@ -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; } } } @@ -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); } } } @@ -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 From 423f7fb2d5ca5fd7461bd0f3688ecfed9bd3f6db Mon Sep 17 00:00:00 2001 From: Michael Tang Date: Mon, 3 Mar 2014 13:51:58 -0800 Subject: [PATCH 20/23] Modified build script to run in Vagrant and Ticket #548 I have modified the build script to use sh command so that it can also be run in the Vagrant environment. The exact same modification has already been made in the dev branch. I have also implemented the minor enhancement of Ticket #458 to have the event template list in the events add/edit page to be sorted, so that users can find their desired template more easily. --- app/models/evaluation_base.php | 2 +- app/models/mixeval.php | 2 +- build.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/evaluation_base.php b/app/models/evaluation_base.php index 08eebfd99..e9b8e1b65 100644 --- a/app/models/evaluation_base.php +++ b/app/models/evaluation_base.php @@ -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')); } diff --git a/app/models/mixeval.php b/app/models/mixeval.php index c23d30602..6d31a0250 100644 --- a/app/models/mixeval.php +++ b/app/models/mixeval.php @@ -183,7 +183,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')); } /** diff --git a/build.xml b/build.xml index 8f1b1dd6e..5cad5f42a 100644 --- a/build.xml +++ b/build.xml @@ -212,8 +212,8 @@ - - + + From cf290a61e28adc180c9b97830f204cba89e55443 Mon Sep 17 00:00:00 2001 From: Compass Date: Mon, 3 Mar 2014 16:33:46 -0800 Subject: [PATCH 21/23] Fix mixeval scale was incorrect rendered when upgrade 3.1 scale_level in mixeval_question_descs are set to 0 in 3.0.x version. So the preview was rendered incorrectly. --- app/views/elements/mixevals/view_mixeval_details.ctp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/elements/mixevals/view_mixeval_details.ctp b/app/views/elements/mixevals/view_mixeval_details.ctp index f94386a7c..abe971702 100644 --- a/app/views/elements/mixevals/view_mixeval_details.ctp +++ b/app/views/elements/mixevals/view_mixeval_details.ctp @@ -48,15 +48,20 @@ foreach ($questions as $ques) { $options = array(); $descs = array(); $marks = array(); - $markLabel = "Mark: "; + $markLabel = __("Mark", true).": "; $subIf0 = 0; if ($zero_mark) { $subIf0 = 1; $scale -= $subIf0; } - foreach ($ques['MixevalQuestionDesc'] as $desc) { + foreach ($ques['MixevalQuestionDesc'] as $key => $desc) { $descs[] = $desc['descriptor']; - $desc['scale_level'] -= $subIf0; + if ($desc['scale_level'] == 0) { + // upgraded from pre 3.1, scale_levels are set to 0. So use $key as level + $desc['scale_level'] = $subIf0 ? $key : $key + 1; + } else { + $desc['scale_level'] -= $subIf0; + } $mark = $highestMark * ($desc['scale_level'] / $scale); $checked = ''; if (isset($details[$num])) { From b155a3510f870050397109825bd3c6b37f3d4ce3 Mon Sep 17 00:00:00 2001 From: Compass Date: Tue, 4 Mar 2014 21:17:13 -0800 Subject: [PATCH 22/23] Fix failed tests by last change --- app/tests/cases/system/add_event.test.php | 105 ++++++++++--------- app/tests/cases/system/mass_move.test.php | 103 +++++++++--------- app/tests/cases/system/move_student.test.php | 87 +++++++-------- 3 files changed, 150 insertions(+), 145 deletions(-) diff --git a/app/tests/cases/system/add_event.test.php b/app/tests/cases/system/add_event.test.php index 28aa26fbf..aabe1245b 100644 --- a/app/tests/cases/system/add_event.test.php +++ b/app/tests/cases/system/add_event.test.php @@ -2,7 +2,7 @@ require_once('system_base.php'); class addEventTestCase extends SystemBaseTestCase -{ +{ public function startCase() { $this->getUrl(); @@ -11,19 +11,19 @@ public function startCase() $this->web_driver = new SystemWebDriver($wd_host); $this->session = $this->web_driver->session('firefox'); $this->session->open($this->url); - + $w = new PHPWebDriver_WebDriverWait($this->session); $this->session->deleteAllCookies(); $login = PageFactory::initElements($this->session, 'Login'); $home = $login->login('instructor1', 'ipeeripeer'); } - + public function endCase() { $this->session->deleteAllCookies(); $this->session->close(); } - + public function testAddEvent() { $this->session->open($this->url.'events/add/1'); @@ -34,7 +34,7 @@ public function testAddEvent() $eventId = end(explode('/', $this->session->url())); $this->session->open($this->url.'events/edit/'.$eventId); $this->eventsEdit(); - + // search that all the email schedules have been created $this->session->open($this->url.'emailer'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'searchInputField')->sendKeys('mech'); @@ -60,9 +60,9 @@ function($session) { } ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); - $this->assertEqual($msg, 'The Email was canceled successfully.'); + $this->assertEqual($msg, 'The Email was canceled successfully.'); } - + // delete the event $this->session->open($this->url.'events/delete/'.$eventId); $w->until( @@ -73,13 +73,13 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The event has been deleted successfully.'); } - + public function eventsFormError() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'flashMessage')->text(); $this->assertEqual($msg, 'Add event failed.'); - + $validate = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CLASS_NAME, 'error-message'); $this->assertEqual($validate[0]->text(), 'Title is required.'); $this->assertEqual($validate[1]->text(), 'Must be in Year-Month-Day Hour:Minute:Second format.'); @@ -87,10 +87,10 @@ public function eventsFormError() $this->assertEqual($validate[3]->text(), 'Must be in Year-Month-Day Hour:Minute:Second format.'); $this->assertEqual($validate[4]->text(), 'Must be in Year-Month-Day Hour:Minute:Second format.'); $this->assertEqual($validate[5]->text(), 'Must be in Year-Month-Day Hour:Minute:Second format.'); - + $courseId = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventCourseId"] option'); $this->assertEqual($courseId[0]->attribute('value'), 1); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->sendKeys('simple evaluation 2'); $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( @@ -100,11 +100,11 @@ function($session) { } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->clear(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEventTemplateTypeId"] option[value="3"]')->click(); $preview = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'prevV')->attribute('href');; - $this->assertTrue(strpos($preview, 'surveys/view/1')); - + $this->assertTrue(strpos($preview, 'surveys/view')); + // check dates toggle $date = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate'); $this->assertTrue(!empty($date)); @@ -116,7 +116,7 @@ function($session) { $this->assertTrue(empty($date)); $date = $this->session->elements(PHPWebDriver_WebDriverBy::ID, 'ResultReleaseDateEndDiv'); $this->assertTrue(empty($date)); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEventTemplateTypeId"] option[value="2"]')->click(); // check boolean options $boolean = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[checked="checked"]'); @@ -136,7 +136,7 @@ function($session) { $this->assertTrue(!empty($date)); $date = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::ID, 'ResultReleaseEndDiv'); $this->assertTrue(!empty($date)); - + // penalty $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Penalty')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Penalty')->click(); @@ -149,7 +149,7 @@ function($session) { $this->assertEqual($dayThree, 3); $percent = count($this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="Penalty1PercentPenalty"] option')); $this->assertEqual($percent, 100); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[onclick="rmPenaltyInputs(0); return false;"]')->click(); $penalties = count($this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'div[id="penaltyInputs"] div[class="penaltyInput"]')); $this->assertEqual($penalties, 2); @@ -161,17 +161,17 @@ function($session) { $dayFive = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'Penalty4DaysLate')->attribute('value'); $this->assertEqual($dayFive, 5); } - + public function fillInEventAddForm() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->sendKeys('Final Project Peer Evaluation'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDescription')->sendKeys('Peer evaluation for the final project'); - + // set email reminder frequency to 2 days $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option[value="2"]')->click(); // select all groups $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[id="selectAll"]')->click(); - + // fill in the dates $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); @@ -188,7 +188,7 @@ public function fillInEventAddForm() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateEnd')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '28')->click(); - + // submit form $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -198,14 +198,14 @@ function($session) { } ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); - $this->assertEqual($msg, 'Add event successful!'); + $this->assertEqual($msg, 'Add event successful!'); } - + public function eventsEdit() { $courseId = $this->session->elements(PHPWebDriver_WebDriverBy::ID, 'EventCourseId'); $this->assertTrue(empty($courseId)); - + // test that email frequency is 2 days $email = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option[selected="selected"]'); $this->assertEqual($email->attribute('value'), 2); @@ -213,7 +213,7 @@ public function eventsEdit() $eventId = end(explode('/', $this->session->url())); $groups = count($this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="GroupGroup"] option[selected="selected"]')); $this->assertEqual($groups, 2); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'unselectAll')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); @@ -225,7 +225,7 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Edit event successful!'); - + $this->session->open($this->url.'events/edit/'.$eventId); $groups = count($this->session->elements(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="GroupGroup"] option[selected="selected"]')); $this->assertEqual($groups, 0); @@ -237,7 +237,7 @@ public function testEmailRemindersForEvals() $this->session->open($this->url.'events/add/1'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->sendKeys('Simple Evaluation with Reminders'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDescription')->sendKeys('w/ reminders'); - + // fill in the dates $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); @@ -252,15 +252,15 @@ public function testEmailRemindersForEvals() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventResultReleaseDateEnd')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '28')->click(); - + $dueDate = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->attribute('value'); $releaseEnd = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventReleaseDateEnd')->attribute('value'); - + // set email reminder frequency to 5 days $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option[value="5"]')->click(); // select all groups $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'button[id="selectAll"]')->click(); - + // submit form $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); @@ -271,10 +271,10 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Add event successful!'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation with Reminders')->click(); $eventId = end(explode('/', $this->session->url())); - + // Alex Student completes the evaluations $this->waitForLogoutLogin('redshirt0002'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Simple Evaluation with Reminders')->click(); @@ -290,7 +290,7 @@ function($session) { $this->removeFromGroup(); // send emails exec('cd '.dirname(__FILE__).'/../../../ && ../cake/console/cake send_emails'); - + // check recipients list $this->session->open($this->url.'emailer'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'MECH 328 - iPeer Evaluation Reminder')->click(); @@ -331,19 +331,19 @@ function($session) { $scheduled++; //includes the one that was sent and can't be deleted; test that all unsent emails are deleted $this->assertEqual(count($emails), $scheduled); - + // delete unsent emails - by disabling email reminders $this->session->open($this->url.'events/edit/'.$eventId); $frequency = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option[selected="selected"]'); $this->assertEqual($frequency->attribute('value'), 4); // the frequency was updated - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option')->click(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->session->open($this->url.'emailer'); $emails = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'MECH 328 - iPeer Evaluation Reminder'); $this->assertEqual(count($emails), 1); @@ -357,7 +357,7 @@ function($session) { ); $message = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'flashMessage'); $this->assertEqual($message->text(), 'Cannot cancel: Email is already sent.'); - + $this->session->open($this->url.'events/delete/'.$eventId); $w->until( function($session) { @@ -373,7 +373,8 @@ public function testEmailRemindersForSurveys() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->sendKeys('Survey with Email Reminders'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDescription')->sendKeys('Email Reminders are included'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEventTemplateTypeId"] option[value="3"]')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventSurvey"] option[value="1"]')->click(); + // fill in the dates $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); @@ -382,7 +383,7 @@ public function testEmailRemindersForSurveys() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventReleaseDateEnd')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, '13')->click(); - + // set email reminder frequency to 5 days $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option[value="5"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); @@ -396,7 +397,7 @@ function($session) { $this->assertEqual($msg, 'Add event successful!'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Survey with Email Reminders')->click(); $eventId = end(explode('/', $this->session->url())); - + // Alex Student completes the survey $this->waitForLogoutLogin('redshirt0002'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Survey with Email Reminders')->click(); @@ -410,20 +411,20 @@ function($session) { ); // send emails exec('cd '.dirname(__FILE__).'/../../../ && ../cake/console/cake send_emails'); // send emails - - // check recipients list + + // check recipients list $this->waitForLogoutLogin('root'); $this->session->open($this->url.'emailer'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'MECH 328 - iPeer Survey Reminder')->click(); $alex = $this->session->elements(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Alex Student'); $this->assertTrue(empty($alex)); // Alex is not listed because he has submitted already - + // frequency calculations $this->session->open($this->url.'events/edit/'.$eventId); $frequency = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option[selected="selected"]'); $this->assertEqual($frequency->attribute('value'), 5); - + // update frequency $dueDate = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->attribute('value'); $scheduled = ceil((strtotime($dueDate) - time()) / (60*60*24*4)); // number of emails scheduled @@ -446,14 +447,14 @@ function($session) { $this->session->open($this->url.'events/edit/'.$eventId); $frequency = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option[selected="selected"]'); $this->assertEqual($frequency->attribute('value'), 4); // the frequency was updated - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option')->click(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEmailSchedule"] option')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->session->open($this->url.'emailer'); $emails = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'MECH 328 - iPeer Survey Reminder'); $this->assertEqual(count($emails), 1); @@ -467,7 +468,7 @@ function($session) { ); $message = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'flashMessage'); $this->assertEqual($message->text(), 'Cannot cancel: Email is already sent.'); - + $this->session->open($this->url.'events/delete/'.$eventId); $w->until( function($session) { @@ -475,7 +476,7 @@ function($session) { } ); } - + public function testCornerCasesForFrequencies() { // one reminder - interval too big - shows up as 7 days @@ -483,7 +484,7 @@ public function testCornerCasesForFrequencies() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->sendKeys('Survey with Email Reminders'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDescription')->sendKeys('Email Reminders are included'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEventTemplateTypeId"] option[value="3"]')->click(); - + // fill in the dates - interval is 2 days $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); @@ -503,7 +504,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Survey with Email Reminders')->click(); $eventId = end(explode('/', $this->session->url())); $this->session->open($this->url.'events/edit/'.$eventId); @@ -517,7 +518,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->session->open($this->url.'events/delete/'.$eventId); $w->until( function($session) { @@ -555,4 +556,4 @@ function($session) { } ); } -} \ No newline at end of file +} diff --git a/app/tests/cases/system/mass_move.test.php b/app/tests/cases/system/mass_move.test.php index ccc19efd3..7d00f5e8f 100644 --- a/app/tests/cases/system/mass_move.test.php +++ b/app/tests/cases/system/mass_move.test.php @@ -2,7 +2,7 @@ require_once('system_base.php'); class massMoveTestCase extends SystemBaseTestCase -{ +{ protected $courseId; protected $eventId; @@ -14,80 +14,80 @@ public function startCase() $this->web_driver = new SystemWebDriver($wd_host); $this->session = $this->web_driver->session('firefox'); $this->session->open($this->url); - + $w = new PHPWebDriver_WebDriverWait($this->session); $this->session->deleteAllCookies(); $login = PageFactory::initElements($this->session, 'Login'); $home = $login->login('root', 'ipeeripeer'); } - + public function endCase() { $this->session->deleteAllCookies(); $this->session->close(); } - + public function testImportUsers() { $this->courseId = $this->addCourse('TEST 101 101'); $this->session->open($this->url.'courses/import'); - + // check the submit button is disabled $submit = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit'); $this->assertTrue($submit->attribute('disabled')); - + $file = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseFile'); $file->sendKeys(dirname(__FILE__).'/files/massMove.csv'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseIdentifiersUsername')->click(); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceCourses"] option[value="1"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; } ); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option[value="4"]')->click(); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option')) - 1; } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option[value="'.$this->courseId.'"]')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseAction0')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); - - + + // enrolling the instructor and tutor (csv) will fail $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Back to Course')); + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Back to Course')); } ); $header = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'h3')->text(); $this->assertEqual($header, 'User(s) failed to transfer:'); - + // check that 7 students have been copied over to the new course $this->session->open($this->url.'users/goToClassList/'.$this->courseId); $classList = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'table_id_info')->text(); $this->assertEqual($classList, 'Showing 1 to 7 of 7 entries'); - + // check the event has been duplicated $this->session->open($this->url.'events/index/'.$this->courseId); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Team Creation Survey')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'TEST 101 101 - Demo Course > Team Creation Survey > View'); $this->eventId = end(explode('/', $this->session->url())); - + // check that the two submissions have been copied over $this->session->open($this->url.'evaluations/viewSurveySummary/'.$this->eventId); $submitted = count($this->session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Result')); $this->assertEqual($submitted, 2); } - + public function testMassMoveError() { @@ -95,19 +95,19 @@ public function testMassMoveError() $file = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseFile'); $file->sendKeys(dirname(__FILE__).'/files/docx.docx'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseIdentifiersUsername')->click(); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceCourses"] option[value="1"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; } ); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option[value="4"]')->click(); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option')) - 1; } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, @@ -123,7 +123,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'flashMessage')->text(); $this->assertEqual($msg, "extension is not allowed.\nFileUpload::processFile() - Unable to save temp file to file system."); } - + public function testImportByStudentNo() { $cId = $this->addCourse('TEST 201 101'); @@ -136,6 +136,7 @@ public function testImportByStudentNo() $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Event')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->sendKeys('Test Survey'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEventTemplateTypeId"] option[value="3"]')->click(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventSurvey"] option[value="1"]')->click(); //set due date and release date end to next month so that the event is opened. $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); @@ -152,7 +153,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + //fill in survey for one student $this->waitForLogoutLogin('redshirt0003'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Test Survey')->click(); @@ -165,26 +166,26 @@ function($session) { } ); $this->waitForLogoutLogin('root'); - + $this->session->open($this->url.'courses/import'); $file = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseFile'); $file->sendKeys(dirname(__FILE__).'/files/massMoveStudentNo.csv'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceCourses"] option[value="'.$this->courseId.'"]')->click(); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option[value="'.$this->eventId.'"]')->click(); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option')) - 1; } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option[value="'.$cId.'"]')->click(); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestSurveys"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestSurveys"] option')) - 1; } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseSurveyChoices0')->click(); //Existing Survey @@ -201,23 +202,23 @@ function($session) { $this->assertEqual($fail->text(), 'No student with student number 12345678 exists.'); $fail = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[1]/tbody/tr[3]/td[2]'); $this->assertEqual($fail->text(), 'No student with student number 87654321 exists.'); - + $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[2]/td[1]'); $this->assertEqual($success->text(), '65498451'); $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[3]/td[1]'); $this->assertEqual($success->text(), '65468188'); - + $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[4]/td[1]'); $this->assertEqual($success->text(), '98985481'); // successful, but survey responses will not be moved/copied because they have already submitted $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[4]/td[2]')->text(); $this->assertEqual(substr($success, 0, 46), 'Success. The student has already submitted to '); - + $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[5]/td[1]')->text(); $this->assertEqual($success, '84188465'); $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[5]/td[2]')->text(); $this->assertEqual($success, 'Success. However no student with student number 84188465 was enrolled in the source course.'); - + $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[6]/td[1]'); $this->assertEqual($success->text(), '48877031'); @@ -232,43 +233,43 @@ function($session) { $this->assertEqual($success->text(), '19524032'); $success = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table[2]/tbody/tr[10]/td[1]'); $this->assertEqual($success->text(), '10186039'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Back to Course')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'List Students')->click(); $total = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'table_id_info')->text(); $this->assertEqual($total, 'Showing 1 to 9 of 9 entries'); - + $this->session->open($this->url.'courses/home/'.$cId); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'List Evaluation Events')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Results')->click(); $results = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Result'); $this->assertEqual(count($results), 2); - + $this->session->open($this->url.'courses/home/'.$this->courseId); $students = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="CourseHome"]/table/tbody/tr[2]/td[4]'); $this->assertEqual($students->text(), '0 students'); $events = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="CourseHome"]/table/tbody/tr[2]/td[6]'); $this->assertEqual($events->text(), '1 events'); - + $this->session->open($this->url.'courses/delete/'.$cId); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The course was deleted successfully.'); } - + public function testDeleteCourse() { $this->session->open($this->url.'courses/delete/'.$this->courseId); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The course was deleted successfully.'); } - + public function testBlankFile() { $this->courseId = $this->addCourse('DEMO 101 101'); $this->session->open($this->url.'courses/import'); $file = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseFile'); $file->sendKeys(dirname(__FILE__).'/files/blank.csv'); - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "select[id='CourseSourceCourses'] option[value='".$this->courseId."']")->click(); // check that surveys fields are all disabled $w = new PHPWebDriver_WebDriverWait($this->session); @@ -300,7 +301,7 @@ function($session) { $students = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '//*[@id="CourseHome"]/table/tbody/tr[2]/td[4]'); $this->assertEqual($students->text(), '15 students'); } - + public function testWithoutSurvey() { $this->session->open($this->url.'courses/import'); @@ -338,7 +339,7 @@ function($session) { $note = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table/tbody/tr[4]/td[2]'); $this->assertEqual($note->text(), 'Success.'); } - + public function testDiffSuccessMsgs() { $this->session->open($this->url.'courses/import'); @@ -350,7 +351,7 @@ public function testDiffSuccessMsgs() $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( function($session) { - return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; + return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, @@ -375,14 +376,14 @@ function($session) { $this->assertEqual($user->text(),'redshirt0005'); $note = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::XPATH, '/html/body/div[1]/table/tbody/tr[4]/td[2]'); $this->assertEqual($note->text(), 'Success. However no student with username redshirt0005 was enrolled in the source course.'); - + $this->enrolStudent(1, 'redshirt0001'); // re-enrol redshirt0001 $this->assignToGroup(); $this->session->open($this->url.'courses/delete/'.$this->courseId); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The course was deleted successfully.'); } - + public function addCourse($name) { $this->session->open($this->url.'courses/add'); @@ -396,10 +397,10 @@ function($session) { } ); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, $name)->click(); - + return end(explode('/', $this->session->url())); } - + public function enrolStudent($cId, $username) { // enrol a student to test that an already enrolled student will still be imported "successfully" @@ -412,20 +413,20 @@ function($session) { return $session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'div[id="usernameErr"]')->text(); } ); - + $warning = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'div[id="usernameErr"]')->text(); $this->assertEqual(substr($warning, 0, 39), 'Username "'.$username.'" already exists.'); - + // click here to enrol $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'here')->click(); - + // wait for the student to be enrolled $w->until( function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'User is successfully enrolled.'); } @@ -443,4 +444,4 @@ function($session) { } ); } -} \ No newline at end of file +} diff --git a/app/tests/cases/system/move_student.test.php b/app/tests/cases/system/move_student.test.php index 707be360b..b13185e5e 100644 --- a/app/tests/cases/system/move_student.test.php +++ b/app/tests/cases/system/move_student.test.php @@ -4,7 +4,7 @@ class MoveStudentTestCase extends SystemBaseTestCase { protected $courseId; - + public function startCase() { $this->getUrl(); @@ -13,46 +13,48 @@ public function startCase() $this->web_driver = new SystemWebDriver($wd_host); $this->session = $this->web_driver->session('firefox'); $this->session->open($this->url); - + $w = new PHPWebDriver_WebDriverWait($this->session); $this->session->deleteAllCookies(); $login = PageFactory::initElements($this->session, 'Login'); $home = $login->login('admin1', 'ipeeripeer'); } - + public function endCase() { $this->session->deleteAllCookies(); $this->session->close(); } - + public function testAddSurveyEvent() { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Courses')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'Courses'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'APSC 201')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'APSC 201 - Technical Communication'); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Event')->click(); $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'APSC 201 - Technical Communication > Add Event'); - + $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle'); $title->sendKeys('Group Making Survey'); - + $desc = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDescription'); $desc->sendKeys('This survey is for creating groups.'); - - $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, + + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEventTemplateTypeId"] option[value="3"]')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, + 'select[id="EventSurvey"] option[value="1"]')->click(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventReleaseDateBegin')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventReleaseDateEnd')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $w = new PHPWebDriver_WebDriverWait($this->session); $w->until( @@ -61,16 +63,16 @@ function($session) { } ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); - $this->assertEqual($msg, 'Add event successful!'); + $this->assertEqual($msg, 'Add event successful!'); } - + public function testCopyStudent() { $this->session->open($this->url.'courses/move'); - + $submit = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit'); $this->assertTrue($submit->attribute('disabled')); - + $sourceCourse = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceCourses"] option[value="1"]'); $sourceCourse->click(); $this->assertEqual($sourceCourse->text(), 'MECH 328 - Mechanical Engineering Design Project'); @@ -81,7 +83,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option')) - 1; } ); - + $sourceSurvey = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceSurveys"] option[value="4"]'); $sourceSurvey->click(); $this->assertEqual($sourceSurvey->text(), 'Team Creation Survey'); @@ -90,7 +92,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSubmitters"] option')) - 1; } ); - + $submitter = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSubmitters"] option[value="31"]'); $submitter->click(); $this->assertEqual($submitter->text(), 'Hui Student'); @@ -99,7 +101,7 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option')) - 1; } ); - + $destCourse = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestCourses"] option'); $this->assertEqual($destCourse[0]->text(), '-- Pick a course --'); $this->assertEqual($destCourse[1]->text(), 'APSC 201 - Technical Communication'); @@ -109,16 +111,16 @@ function($session) { function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestSurveys"] option')) - 1; } - ); + ); $destSurvey = $this->session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestSurveys"] option'); $this->assertEqual($destSurvey[0]->text(), '-- Pick a survey --'); $this->assertEqual($destSurvey[1]->text(), 'Group Making Survey'); $eventId = $destSurvey[1]->attribute('value'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseDestSurveys"] option[value="'.$eventId.'"]')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseAction0')->click(); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[type="submit"]')->click(); $w->until( function($session) { @@ -127,10 +129,10 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Hui Student was successfully copied to APSC 201 - Technical Communication.'); - + $this->deleteEvent($eventId); } - + public function testMoveStudent() { $this->edgeCasesSetup(); @@ -145,7 +147,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Chris Student was successfully moved to EECE 375 101 - Project Course.'); } - + public function testAlreadySubmitted() { $this->session->open($this->url.'courses/move'); @@ -178,7 +180,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Student is successfully unenrolled!'); } - + public function testAlreadyEnrolled() { $this->session->open($this->url.'courses/move'); @@ -191,13 +193,13 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Travis Student was successfully moved to EECE 375 101 - Project Course.'); - + $this->session->open($this->url.'users/goToClassList/1'); $total = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'table_id_info')->text(); $this->assertEqual($total, 'Showing 1 to 10 of 13 entries'); $this->session->open($this->url.'courses/delete/'.$this->courseId); } - + public function deleteEvent($eventId) { $this->session->open($this->url.'evaluations/viewSurveySummary/'.$eventId); @@ -206,7 +208,7 @@ public function deleteEvent($eventId) $this->session->open($result->attribute('href')); // instead of trying to go to the new window or tab $title = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "h1.title")->text(); $this->assertEqual($title, 'APSC 201 - Technical Communication > Group Making Survey > Results'); - + // unenrol Hui Student $this->session->open($this->url.'users/goToClassList/2'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'input[aria-controls="table_id"]')->sendKeys('Hui'); @@ -227,7 +229,7 @@ function($session) { ); $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'Student is successfully unenrolled!'); - + // delete Group Making Survey Event $this->session->open($this->url.'events/delete/'.$eventId); $w->until( @@ -238,7 +240,7 @@ function($session) { $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'The event has been deleted successfully.'); } - + public function enrolStudent($username, $courseId) { $this->session->open($this->url.'users/add/'.$courseId); @@ -250,10 +252,10 @@ function($session) { return $session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'div[id="usernameErr"]')->text(); } ); - + $warning = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'div[id="usernameErr"]')->text(); $this->assertEqual(substr($warning, 0, 39), 'Username "'.$username.'" already exists.'); - + // click here to enrol $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'here')->click(); // wait for the student to be enrolled @@ -262,24 +264,24 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $msg = $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")->text(); $this->assertEqual($msg, 'User is successfully enrolled.'); } - + public function edgeCasesSetup() { $this->enrolStudent('redshirt0004', '1'); $this->enrolStudent('redshirt0005', '1'); $this->enrolStudent('redshirt0006', '1'); - + $this->waitForLogoutLogin('redshirt0004'); $this->fillInSurvey('1', '5', 'Team Creation Survey'); $this->waitForLogoutLogin('redshirt0005'); $this->fillInSurvey('1', '6', 'Team Creation Survey'); $this->waitForLogoutLogin('redshirt0006'); $this->fillInSurvey('2', '5', 'Team Creation Survey'); - + $this->waitForLogoutLogin('root'); $this->session->open($this->url.'courses/add'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'CourseCourse')->sendKeys('EECE 375 101'); @@ -291,12 +293,13 @@ function($session) { return count($session->elementsWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, "div[class='message good-message green']")); } ); - + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'EECE 375 101')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, 'Add Event')->click(); $this->courseId = end(explode('/', $this->session->url())); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventTitle')->sendKeys('Test Survey'); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventEventTemplateTypeId"] option[value="3"]')->click(); + $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="EventSurvey"] option[value="1"]')->click(); //set due date and release date end to next month so that the event is opened. $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'EventDueDate')->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'a[title="Next"]')->click(); @@ -309,12 +312,12 @@ function($session) { $this->enrolStudent('redshirt0005', $this->courseId); $this->enrolStudent('redshirt0006', $this->courseId); - + $this->waitForLogoutLogin('redshirt0005'); $this->fillInSurvey('1', '5', 'Test Survey'); $this->waitForLogoutLogin('root'); } - + public function fillInSurvey($first, $snd, $survey) { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::LINK_TEXT, $survey)->click(); @@ -328,7 +331,7 @@ function($session) { } ); } - + public function moveStudent($userId) { $this->session->elementWithWait(PHPWebDriver_WebDriverBy::CSS_SELECTOR, 'select[id="CourseSourceCourses"] option[value="1"]')->click(); @@ -360,4 +363,4 @@ function($session) { $surveys[1]->click(); $this->session->elementWithWait(PHPWebDriver_WebDriverBy::ID, 'submit')->click(); } -} \ No newline at end of file +} From 7a0d1eccb1f85358b0f3eb66028a5efcdaff44b4 Mon Sep 17 00:00:00 2001 From: Compass Date: Tue, 4 Mar 2014 21:24:54 -0800 Subject: [PATCH 23/23] Bump version to 3.1.1 --- app/config/core.php | 2 +- readme.md | 23 +++++++++++++++++++++++ version.txt | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/config/core.php b/app/config/core.php index 3d171a75c..6343cba60 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -342,7 +342,7 @@ $CWL['applicationID'] = ''; $CWL['applicationPassword'] = ''; - define('IPEER_VERSION', '3.1.0'); + define('IPEER_VERSION', '3.1.1'); /** diff --git a/readme.md b/readme.md index 53871d8c5..36f2fef54 100644 --- a/readme.md +++ b/readme.md @@ -14,6 +14,29 @@ Ruuning the tests: It is better not to touch the mouse or keyboard during the tests. +iPeer 3.1.1 +--------------------------- +This is a maintenance release. +* Fix mixeval scale was incorrect rendered when upgrade 3.1 +* Modified build script to run in Vagrant and Ticket #548 +* Fix #557, filters are failed on lists on dreamhost +* Fix #542 +* Update guard plugin +* Catch the exception with more information printed +* Fix mixeval result rendering error +* Fix #558, 404 when student submitting evaluation +* Refactor mixeval to use unified preview +* Refactor rubric form to show header in view page +* Fix #555, merge user search failed when installed on subdirectory +* Fix #554, confirm button on upgrade page on firefox +* Fix #556, use relative URL for css background image +* Fix #543 remove the criteria hint text from rubric +* Remove the orphan entries in mixeval_question_descs +* Fix missing Content-length in response of API call +* Fix API return 404 when no department is setup +* Fixed problem with exporting evaluation results to csv +* Fixed the inability to view students' survey + iPeer 3.1.0 --------------------------- This is a feature release that has a few exciting new features: diff --git a/version.txt b/version.txt index fd2a01863..94ff29cc4 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.1.0 +3.1.1