Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-mentoring
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
OpenEdx
xblock-mentoring
Commits
72575c36
Commit
72575c36
authored
Mar 31, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from FiloSottile/optimize_dataexport
Optimize mentoring-dataexport times by using a raw SQL cursor
parents
adcb490a
43aa3202
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
mentoring/dataexport.py
+7
-4
No files found.
mentoring/dataexport.py
View file @
72575c36
...
...
@@ -26,6 +26,7 @@
import
logging
from
itertools
import
groupby
from
operator
import
itemgetter
from
webob
import
Response
from
xblock.core
import
XBlock
from
xblock.fragment
import
Fragment
...
...
@@ -78,20 +79,22 @@ class MentoringDataExportBlock(XBlock):
# Header line
yield
list2csv
([
u'student_id'
]
+
list
(
answers_names
))
answers_list
=
answers
.
values_list
(
'name'
,
'student_id'
,
'student_input'
)
if
answers_names
:
for
k
,
student_answers
in
groupby
(
answers
,
lambda
x
:
x
.
student_id
):
for
k
,
student_answers
in
groupby
(
answers
_list
,
itemgetter
(
1
)
):
row
=
[]
next_answer_idx
=
0
for
answer
in
student_answers
:
if
not
row
:
row
=
[
answer
.
student_id
]
row
=
[
answer
[
1
]
]
while
answer
.
name
!=
answers_names
[
next_answer_idx
]:
while
answer
[
0
]
!=
answers_names
[
next_answer_idx
]:
# Still add answer row to CSV when they don't exist in DB
row
.
append
(
''
)
next_answer_idx
+=
1
row
.
append
(
answer
.
student_input
)
row
.
append
(
answer
[
2
]
)
next_answer_idx
+=
1
if
row
:
...
...
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