@@ -2,11 +2,12 @@
|
||||
Admin site bindings for contentstore
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from config_models.admin import ConfigurationModelAdmin
|
||||
from django.contrib import admin
|
||||
|
||||
from contentstore.models import PushNotificationConfig, VideoUploadConfig
|
||||
|
||||
|
||||
admin.site.register(VideoUploadConfig, ConfigurationModelAdmin)
|
||||
admin.site.register(PushNotificationConfig, ConfigurationModelAdmin)
|
||||
|
||||
@@ -4,6 +4,8 @@ Contentstore Application Configuration
|
||||
Above-modulestore level signal handlers are connected here.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
"""
|
||||
Class for manipulating groups configuration on a course object.
|
||||
"""
|
||||
from collections import defaultdict
|
||||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ Current db representation:
|
||||
}
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
""" Upload file handler to help test progress bars in uploads. """
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import time
|
||||
|
||||
from django.core.files.uploadhandler import FileUploadHandler
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Models for contentstore
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from config_models.models import ConfigurationModel
|
||||
from django.db.models.fields import TextField
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
Code related to the handling of Proctored Exams in Studio
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from edx_proctoring.api import (
|
||||
create_exam,
|
||||
@@ -36,7 +39,7 @@ def register_special_exams(course_key):
|
||||
|
||||
course = modulestore().get_course(course_key)
|
||||
if course is None:
|
||||
raise ItemNotFoundError(u"Course {} does not exist", unicode(course_key))
|
||||
raise ItemNotFoundError(u"Course {} does not exist", six.text_type(course_key))
|
||||
|
||||
if not course.enable_proctored_exams and not course.enable_timed_exams:
|
||||
# likewise if course does not have these features turned on
|
||||
@@ -66,7 +69,7 @@ def register_special_exams(course_key):
|
||||
for timed_exam in timed_exams:
|
||||
msg = (
|
||||
u'Found {location} as a timed-exam in course structure. Inspecting...'.format(
|
||||
location=unicode(timed_exam.location)
|
||||
location=six.text_type(timed_exam.location)
|
||||
)
|
||||
)
|
||||
log.info(msg)
|
||||
@@ -84,7 +87,7 @@ def register_special_exams(course_key):
|
||||
}
|
||||
|
||||
try:
|
||||
exam = get_exam_by_content_id(unicode(course_key), unicode(timed_exam.location))
|
||||
exam = get_exam_by_content_id(six.text_type(course_key), six.text_type(timed_exam.location))
|
||||
# update case, make sure everything is synced
|
||||
exam_metadata['exam_id'] = exam['id']
|
||||
|
||||
@@ -93,8 +96,8 @@ def register_special_exams(course_key):
|
||||
log.info(msg)
|
||||
|
||||
except ProctoredExamNotFoundException:
|
||||
exam_metadata['course_id'] = unicode(course_key)
|
||||
exam_metadata['content_id'] = unicode(timed_exam.location)
|
||||
exam_metadata['course_id'] = six.text_type(course_key)
|
||||
exam_metadata['content_id'] = six.text_type(timed_exam.location)
|
||||
|
||||
exam_id = create_exam(**exam_metadata)
|
||||
msg = u'Created new timed exam {exam_id}'.format(exam_id=exam_id)
|
||||
@@ -132,7 +135,7 @@ def register_special_exams(course_key):
|
||||
|
||||
search = [
|
||||
timed_exam for timed_exam in timed_exams if
|
||||
unicode(timed_exam.location) == exam['content_id']
|
||||
six.text_type(timed_exam.location) == exam['content_id']
|
||||
]
|
||||
if not search:
|
||||
# This means it was turned off in Studio, we need to mark
|
||||
|
||||
@@ -2,17 +2,20 @@
|
||||
Helper methods for push notifications from Studio.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from logging import exception as log_exception
|
||||
from uuid import uuid4
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from parse_rest.connection import register
|
||||
from parse_rest.core import ParseError
|
||||
from parse_rest.installation import Push
|
||||
from six import text_type
|
||||
|
||||
from contentstore.models import PushNotificationConfig
|
||||
from contentstore.tasks import push_course_update_task
|
||||
from parse_rest.connection import register
|
||||
from parse_rest.core import ParseError
|
||||
from parse_rest.installation import Push
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
@@ -33,7 +36,7 @@ def enqueue_push_course_update(update, course_key):
|
||||
course = modulestore().get_course(course_key)
|
||||
if course:
|
||||
push_course_update_task.delay(
|
||||
unicode(course_key),
|
||||
six.text_type(course_key),
|
||||
course.clean_id(padding_char='_'),
|
||||
course.display_name
|
||||
)
|
||||
@@ -51,7 +54,7 @@ def send_push_course_update(course_key_string, course_subscription_id, course_di
|
||||
)
|
||||
push_payload = {
|
||||
"action": "course.announcement",
|
||||
"notification-id": unicode(uuid4()),
|
||||
"notification-id": six.text_type(uuid4()),
|
||||
|
||||
"course-id": course_key_string,
|
||||
"course-name": course_display_name,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"""
|
||||
Common utility functions useful throughout the contentstore
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
@@ -150,7 +151,7 @@ def get_lms_link_for_certificate_web_view(user_id, course_key, mode):
|
||||
return u"//{certificate_web_base}/certificates/user/{user_id}/course/{course_id}?preview={mode}".format(
|
||||
certificate_web_base=lms_base,
|
||||
user_id=user_id,
|
||||
course_id=unicode(course_key),
|
||||
course_id=six.text_type(course_key),
|
||||
mode=mode
|
||||
)
|
||||
|
||||
@@ -274,7 +275,7 @@ def reverse_url(handler_name, key_name=None, key_value=None, kwargs=None):
|
||||
Creates the URL for the given handler.
|
||||
The optional key_name and key_value are passed in as kwargs to the handler.
|
||||
"""
|
||||
kwargs_for_reverse = {key_name: unicode(key_value)} if key_name else None
|
||||
kwargs_for_reverse = {key_name: six.text_type(key_value)} if key_name else None
|
||||
if kwargs:
|
||||
kwargs_for_reverse.update(kwargs)
|
||||
return reverse(handler_name, kwargs=kwargs_for_reverse)
|
||||
@@ -427,7 +428,7 @@ def get_user_partition_info(xblock, schemes=None, course=None):
|
||||
# Put together the entire partition dictionary
|
||||
partitions.append({
|
||||
"id": p.id,
|
||||
"name": unicode(p.name), # Convert into a string in case ugettext_lazy was used
|
||||
"name": six.text_type(p.name), # Convert into a string in case ugettext_lazy was used
|
||||
"scheme": p.scheme.name,
|
||||
"groups": groups,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user