Commit 6d6b3a59 by Chris Dodge

violation fixes

parent d4536c65
...@@ -97,8 +97,7 @@ def update_course_updates(location, update, passed_id=None): ...@@ -97,8 +97,7 @@ def update_course_updates(location, update, passed_id=None):
if (len(new_html_parsed) == 1): if (len(new_html_parsed) == 1):
content = new_html_parsed[0].tail content = new_html_parsed[0].tail
else: else:
content = "\n".join([html.tostring(ele) content = "\n".join([html.tostring(ele) for ele in new_html_parsed[1:]])
for ele in new_html_parsed[1:]])
return {"id": passed_id, return {"id": passed_id,
"date": update['date'], "date": update['date'],
......
from static_replace import replace_static_urls from static_replace import replace_static_urls
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore import Location from xmodule.modulestore import Location
from django.http import Http404
def get_module_info(store, location, parent_location=None, rewrite_static_links=False): def get_module_info(store, location, parent_location=None, rewrite_static_links=False):
......
import logging
from django.conf import settings from django.conf import settings
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
...@@ -9,7 +8,7 @@ import copy ...@@ -9,7 +8,7 @@ import copy
DIRECT_ONLY_CATEGORIES = ['course', 'chapter', 'sequential', 'about', 'static_tab', 'course_info'] DIRECT_ONLY_CATEGORIES = ['course', 'chapter', 'sequential', 'about', 'static_tab', 'course_info']
#In order to instantiate an open ended tab automatically, need to have this data #In order to instantiate an open ended tab automatically, need to have this data
OPEN_ENDED_PANEL = {"name" : "Open Ended Panel", "type" : "open_ended"} OPEN_ENDED_PANEL = {"name": "Open Ended Panel", "type": "open_ended"}
def get_modulestore(location): def get_modulestore(location):
...@@ -87,11 +86,10 @@ def get_lms_link_for_item(location, preview=False, course_id=None): ...@@ -87,11 +86,10 @@ def get_lms_link_for_item(location, preview=False, course_id=None):
if settings.LMS_BASE is not None: if settings.LMS_BASE is not None:
if preview: if preview:
lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', 'preview.' + settings.LMS_BASE)
'preview.' + settings.LMS_BASE)
else: else:
lms_base = settings.LMS_BASE lms_base = settings.LMS_BASE
lms_link = "//{lms_base}/courses/{course_id}/jump_to/{location}".format( lms_link = "//{lms_base}/courses/{course_id}/jump_to/{location}".format(
lms_base=lms_base, lms_base=lms_base,
course_id=course_id, course_id=course_id,
...@@ -193,6 +191,7 @@ class CoursePageNames: ...@@ -193,6 +191,7 @@ class CoursePageNames:
CourseOutline = "course_index" CourseOutline = "course_index"
Checklists = "checklists" Checklists = "checklists"
def add_open_ended_panel_tab(course): def add_open_ended_panel_tab(course):
""" """
Used to add the open ended panel tab to a course if it does not exist. Used to add the open ended panel tab to a course if it does not exist.
...@@ -209,6 +208,7 @@ def add_open_ended_panel_tab(course): ...@@ -209,6 +208,7 @@ def add_open_ended_panel_tab(course):
changed = True changed = True
return changed, course_tabs return changed, course_tabs
def remove_open_ended_panel_tab(course): def remove_open_ended_panel_tab(course):
""" """
Used to remove the open ended panel tab from a course if it exists. Used to remove the open ended panel tab from a course if it exists.
...@@ -221,6 +221,6 @@ def remove_open_ended_panel_tab(course): ...@@ -221,6 +221,6 @@ def remove_open_ended_panel_tab(course):
#Check to see if open ended panel is defined in the course #Check to see if open ended panel is defined in the course
if OPEN_ENDED_PANEL in course_tabs: if OPEN_ENDED_PANEL in course_tabs:
#Add panel to the tabs if it is not defined #Add panel to the tabs if it is not defined
course_tabs = [ct for ct in course_tabs if ct!=OPEN_ENDED_PANEL] course_tabs = [ct for ct in course_tabs if ct != OPEN_ENDED_PANEL]
changed = True changed = True
return changed, course_tabs return changed, course_tabs
...@@ -174,7 +174,6 @@ class CourseDetails(object): ...@@ -174,7 +174,6 @@ class CourseDetails(object):
return result return result
# TODO move to a more general util? Is there a better way to do the isinstance model check? # TODO move to a more general util? Is there a better way to do the isinstance model check?
class CourseSettingsEncoder(json.JSONEncoder): class CourseSettingsEncoder(json.JSONEncoder):
def default(self, obj): def default(self, obj):
......
...@@ -45,14 +45,13 @@ class CourseGradingModel(object): ...@@ -45,14 +45,13 @@ class CourseGradingModel(object):
# return empty model # return empty model
else: else:
return { return {"id": index,
"id": index,
"type": "", "type": "",
"min_count": 0, "min_count": 0,
"drop_count": 0, "drop_count": 0,
"short_label": None, "short_label": None,
"weight": 0 "weight": 0
} }
@staticmethod @staticmethod
def fetch_cutoffs(course_location): def fetch_cutoffs(course_location):
...@@ -95,7 +94,6 @@ class CourseGradingModel(object): ...@@ -95,7 +94,6 @@ class CourseGradingModel(object):
return CourseGradingModel.fetch(course_location) return CourseGradingModel.fetch(course_location)
@staticmethod @staticmethod
def update_grader_from_json(course_location, grader): def update_grader_from_json(course_location, grader):
""" """
...@@ -137,7 +135,6 @@ class CourseGradingModel(object): ...@@ -137,7 +135,6 @@ class CourseGradingModel(object):
return cutoffs return cutoffs
@staticmethod @staticmethod
def update_grace_period_from_json(course_location, graceperiodjson): def update_grace_period_from_json(course_location, graceperiodjson):
""" """
...@@ -210,8 +207,7 @@ class CourseGradingModel(object): ...@@ -210,8 +207,7 @@ class CourseGradingModel(object):
location = Location(location) location = Location(location)
descriptor = get_modulestore(location).get_item(location) descriptor = get_modulestore(location).get_item(location)
return { return {"graderType": descriptor.lms.format if descriptor.lms.format is not None else 'Not Graded',
"graderType": descriptor.lms.format if descriptor.lms.format is not None else 'Not Graded',
"location": location, "location": location,
"id": 99 # just an arbitrary value to "id": 99 # just an arbitrary value to
} }
...@@ -231,7 +227,6 @@ class CourseGradingModel(object): ...@@ -231,7 +227,6 @@ class CourseGradingModel(object):
get_modulestore(location).update_metadata(location, descriptor._model_data._kvs._metadata) get_modulestore(location).update_metadata(location, descriptor._model_data._kvs._metadata)
@staticmethod @staticmethod
def convert_set_grace_period(descriptor): def convert_set_grace_period(descriptor):
# 5 hours 59 minutes 59 seconds => converted to iso format # 5 hours 59 minutes 59 seconds => converted to iso format
...@@ -262,13 +257,12 @@ class CourseGradingModel(object): ...@@ -262,13 +257,12 @@ class CourseGradingModel(object):
@staticmethod @staticmethod
def parse_grader(json_grader): def parse_grader(json_grader):
# manual to clear out kruft # manual to clear out kruft
result = { result = {"type": json_grader["type"],
"type": json_grader["type"], "min_count": int(json_grader.get('min_count', 0)),
"min_count": int(json_grader.get('min_count', 0)), "drop_count": int(json_grader.get('drop_count', 0)),
"drop_count": int(json_grader.get('drop_count', 0)), "short_label": json_grader.get('short_label', None),
"short_label": json_grader.get('short_label', None), "weight": float(json_grader.get('weight', 0)) / 100.0
"weight": float(json_grader.get('weight', 0)) / 100.0 }
}
return result return result
......
...@@ -6,6 +6,7 @@ from xblock.core import Scope ...@@ -6,6 +6,7 @@ from xblock.core import Scope
from xmodule.course_module import CourseDescriptor from xmodule.course_module import CourseDescriptor
import copy import copy
class CourseMetadata(object): class CourseMetadata(object):
''' '''
For CRUD operations on metadata fields which do not have specific editors For CRUD operations on metadata fields which do not have specific editors
...@@ -13,8 +14,13 @@ class CourseMetadata(object): ...@@ -13,8 +14,13 @@ class CourseMetadata(object):
The objects have no predefined attrs but instead are obj encodings of the The objects have no predefined attrs but instead are obj encodings of the
editable metadata. editable metadata.
''' '''
FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start',
'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod', 'checklists'] 'end',
'enrollment_start',
'enrollment_end',
'tabs',
'graceperiod',
'checklists']
@classmethod @classmethod
def fetch(cls, course_location): def fetch(cls, course_location):
...@@ -48,7 +54,7 @@ class CourseMetadata(object): ...@@ -48,7 +54,7 @@ class CourseMetadata(object):
descriptor = get_modulestore(course_location).get_item(course_location) descriptor = get_modulestore(course_location).get_item(course_location)
dirty = False dirty = False
#Copy the filtered list to avoid permanently changing the class attribute #Copy the filtered list to avoid permanently changing the class attribute
filtered_list = copy.copy(cls.FILTERED_LIST) filtered_list = copy.copy(cls.FILTERED_LIST)
#Don't filter on the tab attribute if filter_tabs is False #Don't filter on the tab attribute if filter_tabs is False
...@@ -71,7 +77,7 @@ class CourseMetadata(object): ...@@ -71,7 +77,7 @@ class CourseMetadata(object):
if dirty: if dirty:
get_modulestore(course_location).update_metadata(course_location, get_modulestore(course_location).update_metadata(course_location,
own_metadata(descriptor)) own_metadata(descriptor))
# Could just generate and return a course obj w/o doing any db reads, # Could just generate and return a course obj w/o doing any db reads,
# but I put the reads in as a means to confirm it persisted correctly # but I put the reads in as a means to confirm it persisted correctly
...@@ -92,6 +98,6 @@ class CourseMetadata(object): ...@@ -92,6 +98,6 @@ class CourseMetadata(object):
delattr(descriptor.lms, key) delattr(descriptor.lms, key)
get_modulestore(course_location).update_metadata(course_location, get_modulestore(course_location).update_metadata(course_location,
own_metadata(descriptor)) own_metadata(descriptor))
return cls.fetch(course_location) return cls.fetch(course_location)
...@@ -67,4 +67,4 @@ MODULESTORE = AUTH_TOKENS['MODULESTORE'] ...@@ -67,4 +67,4 @@ MODULESTORE = AUTH_TOKENS['MODULESTORE']
CONTENTSTORE = AUTH_TOKENS['CONTENTSTORE'] CONTENTSTORE = AUTH_TOKENS['CONTENTSTORE']
# Datadog for events! # Datadog for events!
DATADOG_API = AUTH_TOKENS.get("DATADOG_API") DATADOG_API = AUTH_TOKENS.get("DATADOG_API")
\ No newline at end of file
...@@ -167,7 +167,7 @@ STATICFILES_DIRS = [ ...@@ -167,7 +167,7 @@ STATICFILES_DIRS = [
PROJECT_ROOT / "static", PROJECT_ROOT / "static",
# This is how you would use the textbook images locally # This is how you would use the textbook images locally
# ("book", ENV_ROOT / "book_images") # ("book", ENV_ROOT / "book_images")
] ]
# Locale/Internationalization # Locale/Internationalization
......
...@@ -9,6 +9,7 @@ import StringIO ...@@ -9,6 +9,7 @@ import StringIO
from xmodule.modulestore import Location from xmodule.modulestore import Location
from .django import contentstore from .django import contentstore
# to install PIL on MacOSX: 'easy_install http://dist.repoze.org/PIL-1.1.6.tar.gz'
from PIL import Image from PIL import Image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment