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
a4f10bfd
Commit
a4f10bfd
authored
Mar 18, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small pylint cleanup
parent
27be7e15
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
4 deletions
+43
-4
cms/xmodule_namespace.py
+16
-0
lms/xmodule_namespace.py
+27
-4
No files found.
cms/xmodule_namespace.py
View file @
a4f10bfd
"""
Namespace defining common fields used by Studio for all blocks
"""
import
datetime
from
xblock.core
import
Namespace
,
Boolean
,
Scope
,
ModelType
,
String
class
StringyBoolean
(
Boolean
):
"""
Reads strings from JSON as booleans.
If the string is 'true' (case insensitive), then return True,
otherwise False.
JSON values that aren't strings are returned as is
"""
def
from_json
(
self
,
value
):
if
isinstance
(
value
,
basestring
):
return
value
.
lower
()
==
'true'
return
value
class
DateTuple
(
ModelType
):
"""
ModelType that stores datetime objects as time tuples
...
...
@@ -24,6 +37,9 @@ class DateTuple(ModelType):
class
CmsNamespace
(
Namespace
):
"""
Namespace with fields common to all blocks in Studio
"""
is_draft
=
Boolean
(
help
=
"Whether this module is a draft"
,
default
=
False
,
scope
=
Scope
.
settings
)
published_date
=
DateTuple
(
help
=
"Date when the module was published"
,
scope
=
Scope
.
settings
)
published_by
=
String
(
help
=
"Id of the user who published this module"
,
scope
=
Scope
.
settings
)
...
...
lms/xmodule_namespace.py
View file @
a4f10bfd
from
xblock.core
import
Namespace
,
Boolean
,
Scope
,
String
,
List
,
Float
"""
Namespace that defines fields common to all blocks used in the LMS
"""
from
xblock.core
import
Namespace
,
Boolean
,
Scope
,
String
,
Float
from
xmodule.fields
import
Date
,
Timedelta
class
StringyBoolean
(
Boolean
):
"""
Reads strings from JSON as booleans.
'true' (case insensitive) return True, other strings return False
Other types are returned unchanged
"""
def
from_json
(
self
,
value
):
if
isinstance
(
value
,
basestring
):
return
value
.
lower
()
==
'true'
return
value
class
StringyFloat
(
Float
):
"""
Reads values as floats. If the value parses as a float, returns
that, otherwise returns None
"""
def
from_json
(
self
,
value
):
try
:
return
float
(
value
)
...
...
@@ -17,6 +31,9 @@ class StringyFloat(Float):
class
LmsNamespace
(
Namespace
):
"""
Namespace that defines fields common to all blocks used in the LMS
"""
hide_from_toc
=
StringyBoolean
(
help
=
"Whether to display this module in the table of contents"
,
default
=
False
,
...
...
@@ -38,8 +55,14 @@ class LmsNamespace(Namespace):
source_file
=
String
(
help
=
"DO NOT USE"
,
scope
=
Scope
.
settings
)
xqa_key
=
String
(
help
=
"DO NOT USE"
,
scope
=
Scope
.
settings
)
ispublic
=
Boolean
(
help
=
"Whether this course is open to the public, or only to admins"
,
scope
=
Scope
.
settings
)
graceperiod
=
Timedelta
(
help
=
"Amount of time after the due date that submissions will be accepted"
,
scope
=
Scope
.
settings
)
graceperiod
=
Timedelta
(
help
=
"Amount of time after the due date that submissions will be accepted"
,
scope
=
Scope
.
settings
)
showanswer
=
String
(
help
=
"When to show the problem answer to the student"
,
scope
=
Scope
.
settings
,
default
=
"closed"
)
rerandomize
=
String
(
help
=
"When to rerandomize the problem"
,
default
=
"always"
,
scope
=
Scope
.
settings
)
days_early_for_beta
=
StringyFloat
(
help
=
"Number of days early to show content to beta users"
,
default
=
None
,
scope
=
Scope
.
settings
)
days_early_for_beta
=
StringyFloat
(
help
=
"Number of days early to show content to beta users"
,
default
=
None
,
scope
=
Scope
.
settings
)
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