Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
problem-builder
Commits
5ad49d93
Commit
5ad49d93
authored
Jun 02, 2015
by
Sven Marnach
Committed by
Jonathan Piacenti
Jun 19, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format times in the UI more nicely and consistently in UTC.
parent
8045e0f5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
problem_builder/public/js/data_export.js
+6
-4
problem_builder/tasks.py
+6
-5
No files found.
problem_builder/public/js/data_export.js
View file @
5ad49d93
...
@@ -33,7 +33,7 @@ function DataExportBlock(runtime, element) {
...
@@ -33,7 +33,7 @@ function DataExportBlock(runtime, element) {
);
);
}
}
function
updateView
()
{
function
updateView
()
{
var
$statusArea
=
$
(
'.data-export-status'
,
element
);
var
$statusArea
=
$
(
'.data-export-status'
,
element
)
,
startTime
;
$statusArea
.
empty
();
$statusArea
.
empty
();
$startButton
.
toggle
(
!
status
.
export_pending
).
prop
(
'disabled'
,
false
);
$startButton
.
toggle
(
!
status
.
export_pending
).
prop
(
'disabled'
,
false
);
$cancelButton
.
toggle
(
status
.
export_pending
).
prop
(
'disabled'
,
false
);
$cancelButton
.
toggle
(
status
.
export_pending
).
prop
(
'disabled'
,
false
);
...
@@ -45,12 +45,14 @@ function DataExportBlock(runtime, element) {
...
@@ -45,12 +45,14 @@ function DataExportBlock(runtime, element) {
'Data export failed. Reason: '
+
status
.
last_export_result
.
error
'Data export failed. Reason: '
+
status
.
last_export_result
.
error
));
));
}
else
{
}
else
{
startTime
=
new
Date
(
status
.
last_export_result
.
start_timestamp
*
1000
);
$statusArea
.
append
(
$
(
'<p>'
).
text
(
$statusArea
.
append
(
$
(
'<p>'
).
text
(
'
Date completed: '
+
status
.
last_export_result
.
report_date
'
A report is available for download.'
));
));
$statusArea
.
append
(
$
(
'<p>'
).
text
(
$statusArea
.
append
(
$
(
'<p>'
).
text
(
'The report took '
+
status
.
last_export_result
.
generation_time_s
+
'It was created at '
+
startTime
.
toUTCString
()
+
' seconds to generate.'
' and took '
+
status
.
last_export_result
.
generation_time_s
.
toFixed
(
1
)
+
' seconds to finish.'
));
));
}
}
}
else
{
}
else
{
...
...
problem_builder/tasks.py
View file @
5ad49d93
"""
"""
This file contains celery tasks for contentstore views
This file contains celery tasks for contentstore views
"""
"""
import
time
from
celery.task
import
task
from
celery.task
import
task
from
celery.utils.log
import
get_task_logger
from
celery.utils.log
import
get_task_logger
import
datetime
from
instructor_task.models
import
ReportStore
from
instructor_task.models
import
ReportStore
from
opaque_keys.edx.keys
import
UsageKey
from
opaque_keys.edx.keys
import
UsageKey
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
...
@@ -19,7 +20,7 @@ def export_data(source_block_id_str, user_id):
...
@@ -19,7 +20,7 @@ def export_data(source_block_id_str, user_id):
"""
"""
Reruns a course in a new celery task.
Reruns a course in a new celery task.
"""
"""
report_date
=
datetime
.
datetime
.
now
()
start_timestamp
=
time
.
time
()
logger
.
debug
(
"Beginning data export"
)
logger
.
debug
(
"Beginning data export"
)
...
@@ -71,16 +72,16 @@ def export_data(source_block_id_str, user_id):
...
@@ -71,16 +72,16 @@ def export_data(source_block_id_str, user_id):
del
student_submissions
[
student_id
]
del
student_submissions
[
student_id
]
# Generate the CSV:
# Generate the CSV:
filename
=
u"pb-data-export-{}.csv"
.
format
(
report_date
.
strftime
(
"
%
Y-
%
m-
%
d-
%
H
%
M
%
S"
))
filename
=
u"pb-data-export-{}.csv"
.
format
(
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
H
%
M
%
S"
,
time
.
gmtime
(
start_timestamp
)
))
report_store
=
ReportStore
.
from_config
(
config_name
=
'GRADES_DOWNLOAD'
)
report_store
=
ReportStore
.
from_config
(
config_name
=
'GRADES_DOWNLOAD'
)
report_store
.
store_rows
(
course_key
,
filename
,
rows
)
report_store
.
store_rows
(
course_key
,
filename
,
rows
)
generation_time_s
=
(
datetime
.
datetime
.
now
()
-
report_date
)
.
total_seconds
()
generation_time_s
=
time
.
time
()
-
start_timestamp
logger
.
debug
(
"Done data export - took {} seconds"
.
format
(
generation_time_s
))
logger
.
debug
(
"Done data export - took {} seconds"
.
format
(
generation_time_s
))
return
{
return
{
"error"
:
None
,
"error"
:
None
,
"report_filename"
:
filename
,
"report_filename"
:
filename
,
"
report_date"
:
report_date
.
isoformat
()
,
"
start_timestamp"
:
start_timestamp
,
"generation_time_s"
:
generation_time_s
,
"generation_time_s"
:
generation_time_s
,
}
}
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