Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
42c40718
Commit
42c40718
authored
Jan 06, 2015
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement better select handling and tests
parent
54a8a4fc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
57 deletions
+126
-57
common/test/acceptance/pages/lms/instructor_dashboard.py
+1
-1
lms/static/js/groups/views/cohort_form.js
+45
-25
lms/static/js/spec/groups/views/cohorts_spec.js
+76
-28
lms/templates/instructor/instructor_dashboard_2/cohort-form.underscore
+4
-3
No files found.
common/test/acceptance/pages/lms/instructor_dashboard.py
View file @
42c40718
...
@@ -210,7 +210,7 @@ class MembershipPageCohortManagementSection(PageObject):
...
@@ -210,7 +210,7 @@ class MembershipPageCohortManagementSection(PageObject):
"""
"""
selector_query
=
self
.
q
(
css
=
self
.
_bounded_selector
(
self
.
content_group_selector_css
))
selector_query
=
self
.
q
(
css
=
self
.
_bounded_selector
(
self
.
content_group_selector_css
))
return
[
return
[
option
.
text
for
option
in
get_options
(
selector_query
)
if
option
.
text
!=
""
option
.
text
for
option
in
get_options
(
selector_query
)
if
option
.
text
!=
"
Not selected
"
]
]
def
get_cohort_associated_content_group
(
self
):
def
get_cohort_associated_content_group
(
self
):
...
...
lms/static/js/groups/views/cohort_form.js
View file @
42c40718
...
@@ -55,10 +55,14 @@ var edx = edx || {};
...
@@ -55,10 +55,14 @@ var edx = edx || {};
this
.
$
(
'.input-cohort-group-association'
).
prop
(
'disabled'
,
!
groupsEnabled
);
this
.
$
(
'.input-cohort-group-association'
).
prop
(
'disabled'
,
!
groupsEnabled
);
},
},
hasAssociatedContentGroup
:
function
()
{
return
this
.
$
(
'.radio-yes'
).
prop
(
'checked'
);
},
getSelectedContentGroup
:
function
()
{
getSelectedContentGroup
:
function
()
{
var
selectValue
=
this
.
$
(
'.input-cohort-group-association'
).
val
(),
var
selectValue
=
this
.
$
(
'.input-cohort-group-association'
).
val
(),
ids
,
groupId
,
userPartitionId
,
i
,
contentGroup
;
ids
,
groupId
,
userPartitionId
,
i
,
contentGroup
;
if
(
!
this
.
$
(
'.radio-yes'
).
prop
(
'checked'
)
||
selectValue
===
'None'
)
{
if
(
!
this
.
hasAssociatedContentGroup
(
)
||
selectValue
===
'None'
)
{
return
null
;
return
null
;
}
}
ids
=
selectValue
.
split
(
':'
);
ids
=
selectValue
.
split
(
':'
);
...
@@ -78,45 +82,61 @@ var edx = edx || {};
...
@@ -78,45 +82,61 @@ var edx = edx || {};
return
cohortName
?
cohortName
.
trim
()
:
this
.
model
.
get
(
'name'
);
return
cohortName
?
cohortName
.
trim
()
:
this
.
model
.
get
(
'name'
);
},
},
showMessage
:
function
(
message
,
type
)
{
showMessage
:
function
(
message
,
type
,
details
)
{
this
.
showNotification
(
this
.
showNotification
(
{
type
:
type
||
'confirmation'
,
title
:
message
},
{
type
:
type
||
'confirmation'
,
title
:
message
,
details
:
details
},
this
.
$
(
'.form-fields'
)
this
.
$
(
'.form-fields'
)
);
);
},
},
validate
:
function
(
fieldData
)
{
var
errorMessages
;
errorMessages
=
[];
if
(
!
fieldData
.
name
)
{
errorMessages
.
push
(
gettext
(
'You must specify a name for the cohort group'
));
}
if
(
this
.
hasAssociatedContentGroup
()
&&
fieldData
.
group_id
===
null
)
{
if
(
this
.
$
(
'.input-cohort-group-association'
).
val
()
===
'None'
)
{
errorMessages
.
push
(
gettext
(
'You did not select a cohorted content group'
));
}
else
{
// If a value was selected, then it must be for a non-existent/deleted content group
errorMessages
.
push
(
gettext
(
'The selected cohorted content group does not exist'
));
}
}
return
errorMessages
;
},
saveForm
:
function
()
{
saveForm
:
function
()
{
var
self
=
this
,
var
self
=
this
,
cohort
=
this
.
model
,
cohort
=
this
.
model
,
saveOperation
=
$
.
Deferred
(),
saveOperation
=
$
.
Deferred
(),
isUpdate
=
this
.
model
.
id
!==
null
,
isUpdate
=
!
_
.
isUndefined
(
this
.
model
.
id
),
cohortName
,
selectedContentGroup
,
showErrorMessage
;
fieldData
,
selectedContentGroup
,
errorMessages
,
showErrorMessage
;
showErrorMessage
=
function
(
message
,
details
)
{
self
.
showMessage
(
message
,
'error'
,
details
);
};
this
.
removeNotification
();
this
.
removeNotification
();
showErrorMessage
=
function
(
message
)
{
selectedContentGroup
=
this
.
getSelectedContentGroup
();
self
.
showMessage
(
message
,
'error'
);
fieldData
=
{
name
:
this
.
getUpdatedCohortName
(),
group_id
:
selectedContentGroup
?
selectedContentGroup
.
id
:
null
,
user_partition_id
:
selectedContentGroup
?
selectedContentGroup
.
get
(
'user_partition_id'
)
:
null
};
};
cohortName
=
this
.
getUpdatedCohortName
();
errorMessages
=
this
.
validate
(
fieldData
);
if
(
cohortName
.
length
===
0
)
{
if
(
errorMessages
.
length
>
0
)
{
showErrorMessage
(
gettext
(
'Enter a name for your cohort group.'
));
showErrorMessage
(
isUpdate
?
gettext
(
"The cohort group cannot be saved"
)
:
gettext
(
"The cohort group cannot be added"
),
errorMessages
);
saveOperation
.
reject
();
saveOperation
.
reject
();
}
else
{
}
else
{
selectedContentGroup
=
this
.
getSelectedContentGroup
();
cohort
.
save
(
cohort
.
save
(
{
fieldData
,
{
patch
:
isUpdate
}
name
:
cohortName
,
group_id
:
selectedContentGroup
?
selectedContentGroup
.
id
:
null
,
user_partition_id
:
selectedContentGroup
?
selectedContentGroup
.
get
(
'user_partition_id'
)
:
null
},
{
patch
:
isUpdate
}
).
done
(
function
(
result
)
{
).
done
(
function
(
result
)
{
if
(
!
result
.
error
)
{
cohort
.
id
=
result
.
id
;
cohort
.
id
=
result
.
id
;
self
.
render
();
// re-render to remove any now invalid error messages
self
.
render
();
// re-render to remove any now invalid error messages
saveOperation
.
resolve
();
saveOperation
.
resolve
();
}
else
{
showErrorMessage
(
result
.
error
);
saveOperation
.
reject
();
}
}).
fail
(
function
(
result
)
{
}).
fail
(
function
(
result
)
{
var
errorMessage
=
null
;
var
errorMessage
=
null
;
try
{
try
{
...
...
lms/static/js/spec/groups/views/cohorts_spec.js
View file @
42c40718
This diff is collapsed.
Click to expand it.
lms/templates/instructor/instructor_dashboard_2/cohort-form.underscore
View file @
42c40718
...
@@ -27,13 +27,14 @@
...
@@ -27,13 +27,14 @@
<%
<%
var foundSelected = false;
var foundSelected = false;
var selectedContentGroupId = cohort.get('group_id');
var selectedContentGroupId = cohort.get('group_id');
var selectedUserPartitionId = cohort.get('user_partition_id');
var hasSelectedContentGroup = selectedContentGroupId != null;
var hasSelectedContentGroup = selectedContentGroupId != null;
var hasContentGroups = contentGroups.length > 0;
var hasContentGroups = contentGroups.length > 0;
%>
%>
<div class="form-field">
<div class="form-field">
<div class="cohort-management-details-association-course field field-radio">
<div class="cohort-management-details-association-course field field-radio">
<h4 class="form-label">
<h4 class="form-label">
<%- gettext('Associate
this cohort group with a content g
roup') %>
<%- gettext('Associate
d Cohorted Content G
roup') %>
</h4>
</h4>
<label><input type="radio" class="radio-no" name="cohort-association-course" value="no" <%- !hasSelectedContentGroup ? 'checked="checked"' : '' %>/> <%- gettext("No Content Group") %></label>
<label><input type="radio" class="radio-no" name="cohort-association-course" value="no" <%- !hasSelectedContentGroup ? 'checked="checked"' : '' %>/> <%- gettext("No Content Group") %></label>
<div class="input-group has-other-input-text">
<div class="input-group has-other-input-text">
...
@@ -42,7 +43,7 @@
...
@@ -42,7 +43,7 @@
<div class="input-group-other">
<div class="input-group-other">
<label class="sr" for="cohort-group-association"><%- gettext("Choose a content group to associate") %></label>
<label class="sr" for="cohort-group-association"><%- gettext("Choose a content group to associate") %></label>
<select name="cohort-group-association" class="input input-lg has-option-unavailable input-cohort-group-association" <%- !hasSelectedContentGroup ? 'disabled="disabled"' : '' %>>
<select name="cohort-group-association" class="input input-lg has-option-unavailable input-cohort-group-association" <%- !hasSelectedContentGroup ? 'disabled="disabled"' : '' %>>
<option value="None"></option>
<option value="None"
<%- !hasSelectedContentGroup ? 'selected="selected"' : '' %> disabled="disabled"><%- gettext("Not selected") %
></option>
<%
<%
var orderedContentGroups = _.sortBy(
var orderedContentGroups = _.sortBy(
...
@@ -64,7 +65,7 @@
...
@@ -64,7 +65,7 @@
%>
%>
<% if (hasSelectedContentGroup && !foundSelected) { %>
<% if (hasSelectedContentGroup && !foundSelected) { %>
<option value="<%-
contentGroupId %>:<%- contentGroup
UserPartitionId %>" class="option-unavailable" selected="selected"><%- gettext("Deleted Content Group") %></option>
<option value="<%-
selectedContentGroupId %>:<%- selected
UserPartitionId %>" class="option-unavailable" selected="selected"><%- gettext("Deleted Content Group") %></option>
<% } %>
<% } %>
</select>
</select>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment