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
8c418c62
Commit
8c418c62
authored
May 17, 2016
by
Christina Roberts
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12033 from sigberto/submission-history-tz
Display correct timezone on timestamp for question submission
parents
7a43b570
6e0fb24d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
2 deletions
+40
-2
AUTHORS
+1
-0
lms/djangoapps/courseware/tests/test_views.py
+35
-0
lms/templates/courseware/submission_history.html
+4
-2
No files found.
AUTHORS
View file @
8c418c62
...
@@ -269,3 +269,4 @@ Florian Haas <florian@hastexo.com>
...
@@ -269,3 +269,4 @@ Florian Haas <florian@hastexo.com>
Leonardo Quiñonez <leonardo.quinonez@edunext.co>
Leonardo Quiñonez <leonardo.quinonez@edunext.co>
Dmitry Viskov <dmitry.viskov@webenterprise.ru>
Dmitry Viskov <dmitry.viskov@webenterprise.ru>
Brian Jacobel <bjacobel@edx.org>
Brian Jacobel <bjacobel@edx.org>
Sigberto Alarcon <salarcon@stanford.edu>
lms/djangoapps/courseware/tests/test_views.py
View file @
8c418c62
...
@@ -11,6 +11,7 @@ import unittest
...
@@ -11,6 +11,7 @@ import unittest
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
HTMLParser
import
HTMLParser
from
HTMLParser
import
HTMLParser
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
from
freezegun
import
freeze_time
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.models
import
AnonymousUser
from
django.contrib.auth.models
import
AnonymousUser
...
@@ -18,6 +19,7 @@ from django.core.urlresolvers import reverse
...
@@ -18,6 +19,7 @@ from django.core.urlresolvers import reverse
from
django.http
import
Http404
,
HttpResponseBadRequest
from
django.http
import
Http404
,
HttpResponseBadRequest
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
from
django.test.client
import
RequestFactory
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
mock
import
MagicMock
,
patch
,
create_autospec
,
Mock
from
mock
import
MagicMock
,
patch
,
create_autospec
,
Mock
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
...
@@ -614,6 +616,39 @@ class ViewsTestCase(ModuleStoreTestCase):
...
@@ -614,6 +616,39 @@ class ViewsTestCase(ModuleStoreTestCase):
self
.
assertIn
(
"Score: 3.0 / 3.0"
,
response_content
)
self
.
assertIn
(
"Score: 3.0 / 3.0"
,
response_content
)
self
.
assertIn
(
'#4'
,
response_content
)
self
.
assertIn
(
'#4'
,
response_content
)
@ddt.data
((
'America/New_York'
,
-
5
),
# UTC - 5
(
'Asia/Pyongyang'
,
9
),
# UTC + 9
(
'Europe/London'
,
0
),
# UTC
(
'Canada/Yukon'
,
-
8
),
# UTC - 8
(
'Europe/Moscow'
,
4
))
# UTC + 3 + 1 for daylight savings
@ddt.unpack
@freeze_time
(
'2012-01-01'
)
def
test_submission_history_timezone
(
self
,
timezone
,
hour_diff
):
with
(
override_settings
(
TIME_ZONE
=
timezone
)):
course
=
CourseFactory
.
create
()
course_key
=
course
.
id
client
=
Client
()
admin
=
AdminFactory
.
create
()
client
.
login
(
username
=
admin
.
username
,
password
=
'test'
)
state_client
=
DjangoXBlockUserStateClient
(
admin
)
usage_key
=
course_key
.
make_usage_key
(
'problem'
,
'test-history'
)
state_client
.
set
(
username
=
admin
.
username
,
block_key
=
usage_key
,
state
=
{
'field_a'
:
'x'
,
'field_b'
:
'y'
}
)
url
=
reverse
(
'submission_history'
,
kwargs
=
{
'course_id'
:
unicode
(
course_key
),
'student_username'
:
admin
.
username
,
'location'
:
unicode
(
usage_key
),
})
response
=
client
.
get
(
url
)
response_content
=
HTMLParser
()
.
unescape
(
response
.
content
)
expected_time
=
datetime
.
now
()
+
timedelta
(
hours
=
hour_diff
)
expected_tz
=
expected_time
.
strftime
(
'
%
Z'
)
self
.
assertIn
(
expected_tz
,
response_content
)
self
.
assertIn
(
str
(
expected_time
),
response_content
)
def
_email_opt_in_checkbox
(
self
,
response
,
org_name_string
=
None
):
def
_email_opt_in_checkbox
(
self
,
response
,
org_name_string
=
None
):
"""Check if the email opt-in checkbox appears in the response content."""
"""Check if the email opt-in checkbox appears in the response content."""
checkbox_html
=
'<input id="email-opt-in" type="checkbox" name="opt-in" class="email-opt-in" value="true" checked>'
checkbox_html
=
'<input id="email-opt-in" type="checkbox" name="opt-in" class="email-opt-in" value="true" checked>'
...
...
lms/templates/courseware/submission_history.html
View file @
8c418c62
<
%
page
expression_filter=
"h"
/>
<
%
page
expression_filter=
"h"
/>
<
%
import
json
%
>
<
%
import
json
,
pytz
%
>
<h3>
${username} > ${course_id} > ${location}
</h3>
<h3>
${username} > ${course_id} > ${location}
</h3>
% for i, (entry, score) in enumerate(zip(history_entries, scores)):
% for i, (entry, score) in enumerate(zip(history_entries, scores)):
<hr/>
<hr/>
<div>
<div>
<b>
#${len(history_entries) - i}
</b>
: ${entry.updated} UTC
</br>
<
%
timedate =
entry.updated.astimezone(pytz.timezone(settings.TIME_ZONE))%
>
<
%
timedate_str =
timedate.strftime('%Y-%m-%d
%
H:
%
M:
%
S
%
Z
')
%
>
<b>
#${len(history_entries) - i}
</b>
: ${timedate_str}
</br>
Score: ${score.grade} / ${score.max_grade}
Score: ${score.grade} / ${score.max_grade}
<pre>
<pre>
${json.dumps(entry.state, indent=2, sort_keys=True)}
${json.dumps(entry.state, indent=2, sort_keys=True)}
...
...
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