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
f2423ca1
Commit
f2423ca1
authored
Jun 07, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a local system with a mako render function for testing problems
parent
684be8d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
common/lib/capa/checker.py
+20
-2
No files found.
common/lib/capa/checker.py
View file @
f2423ca1
...
@@ -6,17 +6,33 @@ from __future__ import unicode_literals
...
@@ -6,17 +6,33 @@ from __future__ import unicode_literals
import
argparse
import
argparse
import
logging
import
logging
import
os.path
import
sys
import
sys
from
path
import
path
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
from
collections
import
defaultdict
from
calc
import
UndefinedVariable
from
calc
import
UndefinedVariable
from
capa_problem
import
LoncapaProblem
from
capa_problem
import
LoncapaProblem
from
mako.lookup
import
TemplateLookup
logging
.
basicConfig
(
format
=
"
%(levelname)
s
%(message)
s"
)
logging
.
basicConfig
(
format
=
"
%(levelname)
s
%(message)
s"
)
log
=
logging
.
getLogger
(
'capa.checker'
)
log
=
logging
.
getLogger
(
'capa.checker'
)
class
DemoSystem
(
object
):
def
__init__
(
self
):
self
.
lookup
=
TemplateLookup
(
directories
=
[
path
(
__file__
)
.
dirname
()
/
'templates'
])
def
render_template
(
self
,
template_filename
,
dictionary
,
context
=
None
):
if
context
is
None
:
context
=
{}
context_dict
=
{}
context_dict
.
update
(
dictionary
)
context_dict
.
update
(
context
)
return
self
.
lookup
.
get_template
(
template_filename
)
.
render
(
**
context_dict
)
def
main
():
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Check Problem Files'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'Check Problem Files'
)
parser
.
add_argument
(
"command"
,
choices
=
[
'test'
,
'show'
])
# Watch? Render? Open?
parser
.
add_argument
(
"command"
,
choices
=
[
'test'
,
'show'
])
# Watch? Render? Open?
...
@@ -29,11 +45,13 @@ def main():
...
@@ -29,11 +45,13 @@ def main():
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
log
.
setLevel
(
args
.
log_level
.
upper
())
log
.
setLevel
(
args
.
log_level
.
upper
())
system
=
DemoSystem
()
for
problem_file
in
args
.
files
:
for
problem_file
in
args
.
files
:
log
.
info
(
"Opening {0}"
.
format
(
problem_file
.
name
))
log
.
info
(
"Opening {0}"
.
format
(
problem_file
.
name
))
try
:
try
:
problem
=
LoncapaProblem
(
problem_file
,
"fakeid"
,
seed
=
args
.
seed
)
problem
=
LoncapaProblem
(
problem_file
,
"fakeid"
,
seed
=
args
.
seed
,
system
=
system
)
except
Exception
as
ex
:
except
Exception
as
ex
:
log
.
error
(
"Could not parse file {0}"
.
format
(
problem_file
.
name
))
log
.
error
(
"Could not parse file {0}"
.
format
(
problem_file
.
name
))
log
.
exception
(
ex
)
log
.
exception
(
ex
)
...
...
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