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
31226f58
Commit
31226f58
authored
Jun 21, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated dogfood to match latest xmodule mods in master
parent
93b8ad3e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
lms/lib/dogfood/check.py
+1
-1
lms/lib/dogfood/views.py
+32
-6
No files found.
lms/lib/dogfood/check.py
View file @
31226f58
...
@@ -24,7 +24,7 @@ def check_problem_code(ans,the_lcp,correct_answers,false_answers):
...
@@ -24,7 +24,7 @@ def check_problem_code(ans,the_lcp,correct_answers,false_answers):
pfn
+=
the_lcp
.
problem_id
.
replace
(
'filename'
,
''
)
# add problem ID to dogfood problem name
pfn
+=
the_lcp
.
problem_id
.
replace
(
'filename'
,
''
)
# add problem ID to dogfood problem name
update_problem
(
pfn
,
ans
,
filestore
=
the_lcp
.
system
.
filestore
)
update_problem
(
pfn
,
ans
,
filestore
=
the_lcp
.
system
.
filestore
)
msg
=
'<hr width="100
%
"/>'
msg
=
'<hr width="100
%
"/>'
msg
+=
'<iframe src="
%
s/dogfood/filename
%
s" width="95
%%
" frameborder="1">No iframe support!</iframe>'
%
(
settings
.
MITX_ROOT_URL
,
pfn
)
msg
+=
'<iframe src="
%
s/dogfood/filename
%
s" width="95
%%
"
height="400"
frameborder="1">No iframe support!</iframe>'
%
(
settings
.
MITX_ROOT_URL
,
pfn
)
msg
+=
'<hr width="100
%
"/>'
msg
+=
'<hr width="100
%
"/>'
endmsg
=
"""<p><font size="-1" color="purple">Note: if the code text box disappears after clicking on "Check",
endmsg
=
"""<p><font size="-1" color="purple">Note: if the code text box disappears after clicking on "Check",
...
...
lms/lib/dogfood/views.py
View file @
31226f58
...
@@ -25,7 +25,7 @@ import track.views
...
@@ -25,7 +25,7 @@ import track.views
from
lxml
import
etree
from
lxml
import
etree
from
courseware.module_render
import
make_track_function
,
I4xSystem
from
courseware.module_render
import
make_track_function
,
I4xSystem
,
get_module
from
courseware.models
import
StudentModule
from
courseware.models
import
StudentModule
from
multicourse
import
multicourse_settings
from
multicourse
import
multicourse_settings
from
student.models
import
UserProfile
from
student.models
import
UserProfile
...
@@ -55,6 +55,7 @@ def update_problem(pfn,pxml,coursename=None,overwrite=True,filestore=None):
...
@@ -55,6 +55,7 @@ def update_problem(pfn,pxml,coursename=None,overwrite=True,filestore=None):
else
:
else
:
pfn2
=
'problems/
%
s.xml'
%
pfn
pfn2
=
'problems/
%
s.xml'
%
pfn
fp
=
filestore
.
open
(
pfn2
,
'w'
)
fp
=
filestore
.
open
(
pfn2
,
'w'
)
log
.
debug
(
'[dogfood.update_problem] pfn2=
%
s'
%
pfn2
)
if
os
.
path
.
exists
(
pfn2
)
and
not
overwrite
:
return
# don't overwrite if already exists and overwrite=False
if
os
.
path
.
exists
(
pfn2
)
and
not
overwrite
:
return
# don't overwrite if already exists and overwrite=False
pxmls
=
pxml
if
type
(
pxml
)
in
[
str
,
unicode
]
else
etree
.
tostring
(
pxml
,
pretty_print
=
True
)
pxmls
=
pxml
if
type
(
pxml
)
in
[
str
,
unicode
]
else
etree
.
tostring
(
pxml
,
pretty_print
=
True
)
...
@@ -71,7 +72,7 @@ def df_capa_problem(request, id=None):
...
@@ -71,7 +72,7 @@ def df_capa_problem(request, id=None):
# "WARNING: UNDEPLOYABLE CODE. FOR DEV USE ONLY."
# "WARNING: UNDEPLOYABLE CODE. FOR DEV USE ONLY."
if
settings
.
DEBUG
:
if
settings
.
DEBUG
:
print
'[lib.dogfood.df_capa_problem] id=
%
s'
%
id
log
.
debug
(
'[lib.dogfood.df_capa_problem] id=
%
s'
%
id
)
if
not
'coursename'
in
request
.
session
:
if
not
'coursename'
in
request
.
session
:
coursename
=
DOGFOOD_COURSENAME
coursename
=
DOGFOOD_COURSENAME
...
@@ -86,7 +87,7 @@ def df_capa_problem(request, id=None):
...
@@ -86,7 +87,7 @@ def df_capa_problem(request, id=None):
try
:
try
:
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
except
Exception
,
err
:
except
Exception
,
err
:
print
"[lib.dogfood.df_capa_problem] error in calling content_parser:
%
s"
%
err
log
.
error
(
"[lib.dogfood.df_capa_problem] error in calling content_parser:
%
s"
%
err
)
xml
=
None
xml
=
None
# if problem of given ID does not exist, then create it
# if problem of given ID does not exist, then create it
...
@@ -96,7 +97,7 @@ def df_capa_problem(request, id=None):
...
@@ -96,7 +97,7 @@ def df_capa_problem(request, id=None):
if
not
m
:
if
not
m
:
raise
Exception
,
'[lib.dogfood.df_capa_problem] Illegal problem id
%
s'
%
id
raise
Exception
,
'[lib.dogfood.df_capa_problem] Illegal problem id
%
s'
%
id
pfn
=
m
.
group
(
1
)
pfn
=
m
.
group
(
1
)
print
'[lib.dogfood.df_capa_problem] creating new problem pfn=
%
s'
%
pfn
log
.
debug
(
'[lib.dogfood.df_capa_problem] creating new problem pfn=
%
s'
%
pfn
)
# add problem to course.xml
# add problem to course.xml
fn
=
settings
.
DATA_DIR
+
xp
+
'course.xml'
fn
=
settings
.
DATA_DIR
+
xp
+
'course.xml'
...
@@ -126,7 +127,7 @@ def df_capa_problem(request, id=None):
...
@@ -126,7 +127,7 @@ def df_capa_problem(request, id=None):
'groups'
:
groups
}
'groups'
:
groups
}
filename
=
xp
+
'course.xml'
filename
=
xp
+
'course.xml'
cache_key
=
filename
+
"_processed?dev_content:"
+
str
(
options
[
'dev_content'
])
+
"&groups:"
+
str
(
sorted
(
groups
))
cache_key
=
filename
+
"_processed?dev_content:"
+
str
(
options
[
'dev_content'
])
+
"&groups:"
+
str
(
sorted
(
groups
))
print
'[lib.dogfood.df_capa_problem] cache_key =
%
s'
%
cache_key
log
.
debug
(
'[lib.dogfood.df_capa_problem] cache_key =
%
s'
%
cache_key
)
#cache.delete(cache_key)
#cache.delete(cache_key)
tree
=
content_parser
.
course_xml_process
(
xml
)
# add ID tags
tree
=
content_parser
.
course_xml_process
(
xml
)
# add ID tags
cache
.
set
(
cache_key
,
etree
.
tostring
(
tree
),
60
)
cache
.
set
(
cache_key
,
etree
.
tostring
(
tree
),
60
)
...
@@ -134,7 +135,7 @@ def df_capa_problem(request, id=None):
...
@@ -134,7 +135,7 @@ def df_capa_problem(request, id=None):
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
if
not
xml
:
if
not
xml
:
print
"[lib.dogfood.df_capa_problem] problem xml not found!"
log
.
debug
(
"[lib.dogfood.df_capa_problem] problem xml not found!"
)
# add problem ID to list so that is_staff check can be bypassed
# add problem ID to list so that is_staff check can be bypassed
request
.
session
[
'dogfood_id'
]
=
id
request
.
session
[
'dogfood_id'
]
=
id
...
@@ -171,6 +172,31 @@ def quickedit(request, id=None, qetemplate='quickedit.html',coursename=None):
...
@@ -171,6 +172,31 @@ def quickedit(request, id=None, qetemplate='quickedit.html',coursename=None):
def
get_lcp
(
coursename
,
id
):
def
get_lcp
(
coursename
,
id
):
# Grab the XML corresponding to the request from course.xml
# Grab the XML corresponding to the request from course.xml
# create empty student state for this problem, if not previously existing
s
=
StudentModule
.
objects
.
filter
(
student
=
request
.
user
,
module_id
=
id
)
student_module_cache
=
list
(
s
)
if
s
is
not
None
else
[]
#if len(s) == 0 or s is None:
# smod=StudentModule(student=request.user,
# module_type = 'problem',
# module_id=id,
# state=instance.get_state())
# smod.save()
# student_module_cache = [smod]
module
=
'problem'
module_xml
=
etree
.
XML
(
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
))
module_id
=
module_xml
.
get
(
'id'
)
log
.
debug
(
"module_id =
%
s"
%
module_id
)
(
instance
,
smod
,
module_type
)
=
get_module
(
request
.
user
,
request
,
module_xml
,
student_module_cache
,
position
=
None
)
log
.
debug
(
'[dogfood.views] instance=
%
s'
%
instance
)
lcp
=
instance
.
lcp
log
.
debug
(
'[dogfood.views] lcp=
%
s'
%
lcp
)
pxml
=
lcp
.
tree
pxmls
=
etree
.
tostring
(
pxml
,
pretty_print
=
True
)
return
instance
,
pxmls
def
old_get_lcp
(
coursename
,
id
):
# Grab the XML corresponding to the request from course.xml
module
=
'problem'
module
=
'problem'
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
...
...
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