Skip to content

Commit

Permalink
Merge pull request #730 from SlateFoundation/develop
Browse files Browse the repository at this point in the history
Release: v3.8.4
  • Loading branch information
themightychris authored Nov 8, 2022
2 parents d2a92d7 + 1b5ebc0 commit 67e714d
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 34 deletions.
103 changes: 103 additions & 0 deletions cypress/integration/cbl/admin/tasks-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ describe('CBL / Admin / Tasks Manager', () => {
cy.extGet('slate-window')
.should('not.have.class', 'x-hidden-clip')
.within(() => {

cy.root()
.contains('.x-title-text', 'Edit Task');

Expand Down Expand Up @@ -164,4 +165,106 @@ describe('CBL / Admin / Tasks Manager', () => {
});
});

it('Verify grid filtering for shared and unshared tasks', () => {

// open student demonstrations dashboard
cy.visit('/cbl/dashboards/tasks/manager');

// verify app loaded
cy.extGet('slate-tasks-manager')
.should('exist')
.contains('.slate-apptitle', 'Task Library');

// wait for data load
cy.wait('@tasksData');

// verify that shared task is present
cy.extGet('slate-tasks-manager')
.should('exist')
.contains('.x-grid-cell-inner', 'A Shared Task')
.should('exist');

// verify that the unshared task is not present
cy.extGet('slate-tasks-manager')
.should('exist')
.contains('.x-grid-cell-inner', 'An Unshared Task')
.should('not.exist');

// open options menu
cy.extGet('slate-tasks-manager-grid button[action=settings]')
.should('exist')
.click();

// check 'include unshared' option
cy.extGet('slate-tasks-manager-grid menucheckitem[name=include-unshared]')
.should('exist')
.click();

// wait for data load after option change
cy.wait('@tasksData');

// verify that shared task is present
cy.extGet('slate-tasks-manager')
.should('exist')
.contains('.x-grid-cell-inner', 'A Shared Task')
.should('exist');

// verify that the unshared task is present
cy.extGet('slate-tasks-manager')
.should('exist')
.contains('.x-grid-cell-inner', 'An Unshared Task')
.should('exist');
});

it('Verify shared/unshared filtering in clone field', () => {

// open student demonstrations dashboard
cy.visit('/cbl/dashboards/tasks/manager');

// verify app loaded
cy.extGet('slate-tasks-manager')
.should('exist')
.contains('.slate-apptitle', 'Task Library');

// wait for data load
cy.wait('@tasksData');

// click create button
cy.extGet('slate-tasks-manager-appheader button[action=create]')
.click();

// wait for window to transition open
cy.extGet('slate-window')
.should('not.have.class', 'x-hidden-clip')
.within(() => {

// click cloned task selector
cy.extGet('slate-cbl-taskselector[name=ClonedTaskID]')
.should('exist')
.within(() => {

cy.root()
.get('.x-form-arrow-trigger')
.click()

});

// wait for options to load
cy.wait('@tasksData');

// verify shared task exists in picker dropdown
cy.extGet('slate-cbl-taskselector[name=ClonedTaskID]', { component: true })
.then(selector => selector.getPicker().el.dom)
.contains('.x-boundlist-item', 'A Shared Task')
.should('exist');

// verify unshared task does not exist in picker dropdown
cy.extGet('slate-cbl-taskselector[name=ClonedTaskID]', { component: true })
.then(selector => selector.getPicker().el.dom)
.contains('.x-boundlist-item', 'An UnShared Task')
.should('not.exist');
});

});

});
118 changes: 87 additions & 31 deletions cypress/integration/cbl/tasks/student-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,27 @@ dayjs.extend(isBetween);

// load sample database before tests
before(() => {
cy.resetDatabase();

// create time relative tasks
cy.loginAs('teacher');

// create some relatively due tasks
cy.request('POST', `/cbl/tasks/save?format=json`, {
data: [{
_loadTaskData([{
Title: 'Test Task (Due Today)',
DueDate: today.format('YYYY-MM--DD'),
SectionID: 2,
Assignees: {
'student': true
}
DueDate: today.format('MM/DD/YYYY'),
}, {
Title: 'Test Task (Due This Week)',
DueDate: today.add(5, 'day').format('YYYY-MM--DD'),
SectionID: 2,
Assignees: {
'student': true
}
DueDate: today.add(5, 'day').format('MM/DD/YYYY'),
}, {
Title: 'Test Task (Due Recently)',
DueDate: today.subtract(9, 'day').format('YYYY-MM--DD'),
SectionID: 2,
Assignees: {
'student': true
}
DueDate: today.subtract(9, 'day').format('MM/DD/YYYY'),
}, {
Title: 'Test Task (Due Next Week)',
DueDate: today.add(8, 'day').format('YYYY-MM--DD'),
SectionID: 2,
Assignees: {
'student': true
}
DueDate: today.add(8, 'day').format('MM/DD/YYYY'),
}, {
Title: 'Test Task (No Due Date)',
SectionID: 2,
Assignees: {
'student': true
}
}, {
}]);

// create an archived task
cy.request('POST', `/cbl/tasks/save?format=json`, {
data: [{
Title: 'Test Task (Archived)',
SectionID: 2,
Status: 'archived',
Expand All @@ -69,6 +48,80 @@ beforeEach(() => {
cy.intercept('POST', '/cbl/student-tasks/save?(\\?*)').as('studentTasksSave');
});

function _loadTaskData(taskData) {
cy.resetDatabase();

cy.intercept('GET', '/cbl/student-tasks?(\\?*)').as('studentTasksData');
cy.intercept('POST', '/cbl/tasks/save?(\\?*)').as('taskSave');

// create time relative tasks
cy.loginAs('teacher');

// open student demonstrations dashboard
cy.visit('/cbl/dashboards/tasks/teacher#ELA-001/all');

// wait for data load
cy.wait('@studentTasksData');

for (var i = 0; i < taskData.length; i++) {

let task = taskData[i];

// click create button
cy.extGet('slate-tasks-teacher-dashboard button[action=create]')
.click();

// wait for window to transition open
cy.extGet('slate-window')
.should('not.have.class', 'x-hidden-clip')
.within(() => {
cy.root()
.contains('.x-title-text', 'Create Task');

cy.root()
.contains('.x-form-item-label-text', 'Title');

cy.root()
.get('.x-form-field[name="Title"]')
.click();

cy.focused()
.should('have.attr', 'name', 'Title')
.type(task['Title']);

if (task['DueDate']) {
cy.root()
.get('.x-form-field[name="DueDate"]')
.click();

cy.focused()
.should('have.attr', 'name', 'DueDate')
.type(task['DueDate']);
}

cy.extGet('slate-cbl-assigneesfield')
.find('.x-form-arrow-trigger')
.click({ force: true}) // force click if element isn't visible

cy.extGet('slate-cbl-assigneesfield', { component: true })
.then(selector => selector.getPicker().el.dom)
.contains('.x-boundlist-item', 'Student Slate')
.click({ force: true});

cy.root()
.get('.x-form-field[name="Instructions"]')
.click();

cy.extGet('button[action=submit]')
.click();

// wait for data save
cy.wait('@taskSave');

});
}
}

function _visitDashboardAsStudent(student = 'student') {
cy.loginAs(`${student}`);
cy.visit(`/cbl/dashboards/tasks/student`);
Expand Down Expand Up @@ -461,6 +514,9 @@ describe('CBL / Tasks / Student Dashboard: Timeline Filters', () => {
.find('.slate-tasktree-item')
.each($task => {
const date = dayjs($task.find('.slate-tasktree-date').text(), 'MMM, DD YYYY');
console.log('first date below should be after second one');
console.log(date);
console.log(endOfThisWeek);
const isAfter = date.isAfter(endOfThisWeek);
expect(isAfter, 'Due date after this week').to.be.true;
});
Expand Down
56 changes: 56 additions & 0 deletions cypress/integration/cbl/tasks/teacher-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('CBL / Tasks / Teacher Dashboard', () => {
// authenticate as 'teacher' user
beforeEach(() => {
cy.intercept('GET', '/cbl/tasks/!(\\*)*?(\\?*)').as('taskData');
cy.intercept('GET', '/cbl/tasks?(\\?*)').as('tasksData');
cy.intercept('GET', '/cbl/student-tasks?(\\?*)').as('studentTasksData');
cy.intercept('POST', '/cbl/tasks/save?(\\?*)').as('taskSave');
cy.intercept('GET', '/cbl/dashboards/tasks/teacher/bootstrap').as('getBootstrapData');
Expand Down Expand Up @@ -207,4 +208,59 @@ describe('CBL / Tasks / Teacher Dashboard', () => {
expect(taskOne.length, 'only one "ELA Task One"').to.eq(1);
});
});

it('Verify options in task form clone field', () => {

// open teacher task dashboard
cy.visit('/cbl/dashboards/tasks/teacher#ELA-001/all');

// wait for data to load
cy.wait('@getBootstrapData');
cy.get('@getBootstrapData.all').should('have.length', 1);

// verify student tasks load
cy.wait('@studentTasksData').then(({ response }) => {
expect(response.body.success).to.eq(true);
expect(response.statusCode).to.eq(200);
});
cy.get('@studentTasksData.all').should('have.length', 1);

// click create button
cy.extGet('slate-tasks-teacher-dashboard button[action=create]')
.click();

// wait for window to transition open
cy.extGet('slate-window')
.should('not.have.class', 'x-hidden-clip')
.within(() => {

// click cloned task selector
cy.extGet('slate-cbl-taskselector[name=ClonedTaskID]')
.should('exist')
.within(() => {

cy.root()
.get('.x-form-arrow-trigger')
.click()

});

// wait for options to load
cy.wait('@tasksData');

// verify shared task exists in picker dropdown
cy.extGet('slate-cbl-taskselector[name=ClonedTaskID]', { component: true })
.then(selector => selector.getPicker().el.dom)
.contains('.x-boundlist-item', 'A Shared Task')
.should('exist');

// verify unshared task does not exist in picker dropdown
cy.extGet('slate-cbl-taskselector[name=ClonedTaskID]', { component: true })
.then(selector => selector.getPicker().el.dom)
.contains('.x-boundlist-item', 'An UnShared Task')
.should('not.exist');
});
});


});
2 changes: 2 additions & 0 deletions fixtures/cbl_student_tasks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ INSERT INTO `cbl_student_tasks` VALUES (208,'Slate\\CBL\\Tasks\\StudentTask','20
INSERT INTO `cbl_student_tasks` VALUES (209,'Slate\\CBL\\Tasks\\StudentTask','2022-08-09 21:20:13',3,'2022-08-09 21:23:48',3,12,10,'completed',228,NULL,NULL);
INSERT INTO `cbl_student_tasks` VALUES (210,'Slate\\CBL\\Tasks\\StudentTask','2022-08-09 21:20:21',3,NULL,NULL,13,10,'assigned',NULL,NULL,NULL);
INSERT INTO `cbl_student_tasks` VALUES (211,'Slate\\CBL\\Tasks\\StudentTask','2022-08-09 21:22:53',3,NULL,NULL,14,10,'assigned',NULL,NULL,NULL);
INSERT INTO `cbl_student_tasks` VALUES (212,'Slate\\CBL\\Tasks\\StudentTask','2022-10-28 16:16:28',3,NULL,NULL,47,4,'assigned',NULL,NULL,NULL);
INSERT INTO `cbl_student_tasks` VALUES (213,'Slate\\CBL\\Tasks\\StudentTask','2022-10-28 16:16:28',3,NULL,NULL,47,6,'assigned',NULL,NULL,NULL);


CREATE TABLE `history_cbl_student_tasks` (
Expand Down
4 changes: 4 additions & 0 deletions fixtures/cbl_task_skills.sql
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ INSERT INTO `cbl_task_skills` VALUES (113,'Slate\\CBL\\Tasks\\TaskSkill','2021-0
INSERT INTO `cbl_task_skills` VALUES (114,'Slate\\CBL\\Tasks\\TaskSkill','2021-05-29 14:14:45',5,NULL,NULL,45,38);
INSERT INTO `cbl_task_skills` VALUES (115,'Slate\\CBL\\Tasks\\TaskSkill','2021-05-29 14:14:45',5,NULL,NULL,45,39);
INSERT INTO `cbl_task_skills` VALUES (116,'Slate\\CBL\\Tasks\\TaskSkill','2021-05-29 14:14:45',5,NULL,NULL,45,119);
INSERT INTO `cbl_task_skills` VALUES (117,'Slate\\CBL\\Tasks\\TaskSkill','2022-10-28 16:16:28',3,NULL,NULL,47,61);
INSERT INTO `cbl_task_skills` VALUES (118,'Slate\\CBL\\Tasks\\TaskSkill','2022-10-28 16:16:28',3,NULL,NULL,47,62);
INSERT INTO `cbl_task_skills` VALUES (119,'Slate\\CBL\\Tasks\\TaskSkill','2022-10-28 16:17:07',3,NULL,NULL,46,61);
INSERT INTO `cbl_task_skills` VALUES (120,'Slate\\CBL\\Tasks\\TaskSkill','2022-10-28 16:17:07',3,NULL,NULL,46,62);


CREATE TABLE `history_cbl_task_skills` (
Expand Down
2 changes: 2 additions & 0 deletions fixtures/cbl_tasks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ INSERT INTO `cbl_tasks` VALUES (42,'Slate\\CBL\\Tasks\\ExperienceTask','2021-05-
INSERT INTO `cbl_tasks` VALUES (43,'Slate\\CBL\\Tasks\\ExperienceTask','2021-05-29 14:11:20',5,NULL,NULL,7,'M.6 Step.4: Formal Style','m.6_step.4--formal_style',39,NULL,NULL,'shared','Complete and submit the assessment.',NULL,NULL,'Studio');
INSERT INTO `cbl_tasks` VALUES (44,'Slate\\CBL\\Tasks\\ExperienceTask','2021-05-29 14:12:54',5,NULL,NULL,7,'M.6 Step.5: Conclusion','m.6_step.5--conclusion',39,NULL,NULL,'shared','Complete and submit the assessment.',NULL,NULL,'Studio');
INSERT INTO `cbl_tasks` VALUES (45,'Slate\\CBL\\Tasks\\ExperienceTask','2021-05-29 14:14:45',5,NULL,NULL,7,'Reflection: Who Gets a Vote','reflection--who_gets_a_vote',NULL,21,NULL,'shared','Complete the reflection google form.',NULL,NULL,'Studio');
INSERT INTO `cbl_tasks` VALUES (46,'Slate\\CBL\\Tasks\\ExperienceTask','2022-10-28 16:13:22',3,'2022-10-28 16:17:07',3,0,'A Shared Task','a_shared_task',NULL,NULL,NULL,'shared','A shared task that will be used to test the filtering of shared and unshared tasks',NULL,NULL,'Studio');
INSERT INTO `cbl_tasks` VALUES (47,'Slate\\CBL\\Tasks\\ExperienceTask','2022-10-28 16:16:28',3,NULL,NULL,1,'An Unshared Task','an_unshared_task',NULL,NULL,NULL,'private','An unshared task that will be used to test the filtering of shared and unshared tasks',NULL,NULL,'Studio');


CREATE TABLE `history_cbl_tasks` (
Expand Down
6 changes: 6 additions & 0 deletions php-classes/Slate/CBL/Tasks/TasksRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ protected static function buildBrowseConditions(array $conditions = array(), arr
if ($archivedConditions != false) {
$conditions[] = $archivedConditions;
}

$includeUnshared = isset($_REQUEST['include_unshared']) && ($_REQUEST['include_unshared']=='true');

if (!$includeUnshared) {
$conditions['Status'] = 'shared';
}
}

return $conditions;
Expand Down
Loading

0 comments on commit 67e714d

Please sign in to comment.