From 32d445e06d09a2d2aa5ba927f9e57e73999b9853 Mon Sep 17 00:00:00 2001 From: cahrens Date: Tue, 6 Jun 2017 18:03:11 -0400 Subject: [PATCH] Fix radio button layout issues. EDUCATOR-557 --- .../instructor/views/instructor_dashboard.py | 89 +++++++++---------- .../views/discussions.js | 24 +++-- .../sass/course/instructor/_instructor_2.scss | 4 +- .../discussions_management.html | 1 - 4 files changed, 57 insertions(+), 61 deletions(-) diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 9688458b5c..25572167d2 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -2,61 +2,61 @@ Instructor Dashboard Views """ -import logging import datetime -from opaque_keys import InvalidKeyError -from opaque_keys.edx.keys import CourseKey +import logging import uuid -import pytz -from django.contrib.auth.decorators import login_required -from django.views.decorators.http import require_POST -from django.utils.translation import ugettext as _, ugettext_noop -from django.views.decorators.csrf import ensure_csrf_cookie -from django.views.decorators.cache import cache_control -from edxmako.shortcuts import render_to_response -from django.core.urlresolvers import reverse -from django.utils.html import escape -from django.http import Http404, HttpResponseServerError -from django.conf import settings -from util.json_request import JsonResponse from mock import patch -from openedx.core.lib.xblock_utils import wrap_xblock +import pytz +from bulk_email.models import BulkEmailFlag +from certificates import api as certs_api +from certificates.models import ( + CertificateGenerationConfiguration, + CertificateGenerationHistory, + CertificateInvalidation, + CertificateStatuses, + CertificateWhitelist, + GeneratedCertificate +) +from class_dashboard.dashboard_data import get_array_section_has_problem, get_section_display_name +from course_modes.models import CourseMode, CourseModesArchive +from courseware.access import has_access +from courseware.courses import get_course_by_id, get_studio_url +from django.conf import settings +from django.contrib.auth.decorators import login_required +from django.core.urlresolvers import reverse +from django.http import Http404, HttpResponseServerError +from django.utils.html import escape +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_noop +from django.views.decorators.cache import cache_control +from django.views.decorators.csrf import ensure_csrf_cookie +from django.views.decorators.http import require_POST +from django_comment_client.utils import available_division_schemes, has_forum_access +from django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, CourseDiscussionSettings +from edxmako.shortcuts import render_to_response +from lms.djangoapps.courseware.module_render import get_module_by_usage_id +from opaque_keys import InvalidKeyError +from opaque_keys.edx.keys import CourseKey +from opaque_keys.edx.locations import SlashSeparatedCourseKey +from openedx.core.djangoapps.course_groups.cohorts import DEFAULT_COHORT_NAME, get_course_cohorts, is_course_cohorted +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers +from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse +from openedx.core.djangolib.markup import HTML, Text from openedx.core.lib.url_utils import quote_slashes +from openedx.core.lib.xblock_utils import wrap_xblock +from shoppingcart.models import Coupon, CourseRegCodeItem, PaidCourseRegistration +from student.models import CourseEnrollment +from student.roles import CourseFinanceAdminRole, CourseSalesAdminRole +from util.json_request import JsonResponse +from xblock.field_data import DictFieldData +from xblock.fields import ScopeIds from xmodule.html_module import HtmlDescriptor from xmodule.modulestore.django import modulestore from xmodule.tabs import CourseTab -from xblock.field_data import DictFieldData -from xblock.fields import ScopeIds -from courseware.access import has_access -from courseware.courses import get_course_by_id, get_studio_url -from django_comment_client.utils import has_forum_access, available_division_schemes, enrollment_track_group_count -from django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, CourseDiscussionSettings -from openedx.core.djangoapps.course_groups.cohorts import get_course_cohorts, is_course_cohorted, DEFAULT_COHORT_NAME -from student.models import CourseEnrollment -from shoppingcart.models import Coupon, PaidCourseRegistration, CourseRegCodeItem -from course_modes.models import CourseMode, CourseModesArchive -from student.roles import CourseFinanceAdminRole, CourseSalesAdminRole -from lms.djangoapps.courseware.module_render import get_module_by_usage_id -from certificates.models import ( - CertificateGenerationConfiguration, - CertificateWhitelist, - GeneratedCertificate, - CertificateStatuses, - CertificateGenerationHistory, - CertificateInvalidation, -) -from certificates import api as certs_api -from bulk_email.models import BulkEmailFlag -from class_dashboard.dashboard_data import get_section_display_name, get_array_section_has_problem from .tools import get_units_with_due_date, title_or_url -from opaque_keys.edx.locations import SlashSeparatedCourseKey -from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers -from openedx.core.djangoapps.verified_track_content.models import VerifiedTrackCohortedCourse - -from openedx.core.djangolib.markup import HTML, Text log = logging.getLogger(__name__) @@ -530,7 +530,6 @@ def _section_discussions_management(course, access): 'section_display_name': _('Discussions'), 'is_hidden': (not is_course_cohorted(course_key) and CourseDiscussionSettings.ENROLLMENT_TRACK not in enrollment_track_schemes), - 'enrollment_track_count': enrollment_track_group_count(course_key), 'discussion_topics_url': reverse('discussion_topics', kwargs={'course_key_string': unicode(course_key)}), 'course_discussion_settings': reverse( 'course_discussions_settings', diff --git a/lms/static/js/discussions_management/views/discussions.js b/lms/static/js/discussions_management/views/discussions.js index 956e68c01b..e4c12417a0 100644 --- a/lms/static/js/discussions_management/views/discussions.js +++ b/lms/static/js/discussions_management/views/discussions.js @@ -39,7 +39,7 @@ var numberAvailableSchemes = this.discussionSettings.attributes.available_division_schemes.length; HtmlUtils.setHtml(this.$el, this.template({ availableSchemes: this.getDivisionSchemeData(this.discussionSettings.attributes.division_scheme), // eslint-disable-line max-len - layoutClass: numberAvailableSchemes === 1 ? 'two-column-layout' : 'three-column-layout' + layoutClass: numberAvailableSchemes === 2 ? THREE_COLUMN_CLASS : TWO_COLUMN_CLASS })); this.updateTopicVisibility(this.getSelectedScheme(), this.getTopicNav()); this.renderTopics(); @@ -88,9 +88,10 @@ }, cohortStateUpdate: function(state) { - if ($('.discussions-management').data('enrollment-track-count') <= 1) { + if (!this.isSchemeAvailable(ENROLLMENT_TRACK)) { this.showDiscussionManagement(state.is_cohorted); - } if (this.getSelectedScheme() !== COHORT) { + } + if (this.getSelectedScheme() !== COHORT) { this.showCohortSchemeControl(state.is_cohorted); } }, @@ -108,18 +109,15 @@ showCohortSchemeControl: function(show) { if (!show) { $('.division-scheme-item.cohort').addClass(HIDDEN_CLASS); - this.updateSchemeSelectionLayout(2); - } else { - $('.division-scheme-item.cohort').removeClass(HIDDEN_CLASS); - this.updateSchemeSelectionLayout(3); - } - }, - - updateSchemeSelectionLayout: function(columns) { - if (columns === 2) { + // Since we are removing the cohort scheme, we can have at most 2 columns. $('.division-scheme-item').removeClass(THREE_COLUMN_CLASS).addClass(TWO_COLUMN_CLASS); } else { - $('.division-scheme-item').removeClass(TWO_COLUMN_CLASS).addClass(THREE_COLUMN_CLASS); + $('.division-scheme-item.cohort').removeClass(HIDDEN_CLASS); + if (this.isSchemeAvailable(ENROLLMENT_TRACK)) { + $('.division-scheme-item').removeClass(TWO_COLUMN_CLASS).addClass(THREE_COLUMN_CLASS); + } else { + $('.division-scheme-item').removeClass(THREE_COLUMN_CLASS).addClass(TWO_COLUMN_CLASS); + } } }, diff --git a/lms/static/sass/course/instructor/_instructor_2.scss b/lms/static/sass/course/instructor/_instructor_2.scss index 1439e0d95f..ccbd8ed5df 100644 --- a/lms/static/sass/course/instructor/_instructor_2.scss +++ b/lms/static/sass/course/instructor/_instructor_2.scss @@ -1258,11 +1258,11 @@ } .three-column-layout { - max-width: 33%; + max-width: 30%; } .two-column-layout { - max-width: 50%; + max-width: 47%; } .field-message { diff --git a/lms/templates/instructor/instructor_dashboard_2/discussions_management.html b/lms/templates/instructor/instructor_dashboard_2/discussions_management.html index 0700a09063..326bd8ea8c 100644 --- a/lms/templates/instructor/instructor_dashboard_2/discussions_management.html +++ b/lms/templates/instructor/instructor_dashboard_2/discussions_management.html @@ -12,7 +12,6 @@ from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_