Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api endpoint for list of student points in a course #1371

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion aplus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@
]
TIME_ZONE = 'EET'
USE_I18N = True
USE_L10N = True
USE_TZ = True
FORMAT_MODULE_PATH = 'aplus'
LOCALE_PATHS = (
Expand Down
6 changes: 4 additions & 2 deletions edit_course/operations/clone.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from datetime import datetime
from django.utils import timezone
from django.db import transaction
from django.contrib.auth.models import User
from course.models import CourseInstance
Expand Down Expand Up @@ -34,8 +36,8 @@ def set_sis(instance: CourseInstance, id: str, enroll: bool) -> None: # pylint:
return

if coursedata.get('starting_time') and coursedata.get('ending_time'):
instance.starting_time = coursedata['starting_time']
instance.ending_time = coursedata['ending_time']
instance.starting_time = timezone.make_aware(datetime.strptime(coursedata['starting_time'], '%Y-%m-%d'))
instance.ending_time = timezone.make_aware(datetime.strptime(coursedata['ending_time'], '%Y-%m-%d'))

instance.sis_id = id
instance.sis_enroll = enroll
Expand Down
4 changes: 1 addition & 3 deletions exercise/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,10 @@ class CoursePointsViewSet(ListSerializerMixin,
lookup_url_kwarg = 'user_id'
lookup_value_regex = REGEX_INT_ME
parent_lookup_map = {}
listserializer_class = StudentBriefSerializer
listserializer_class = UserPointsSerializer
serializer_class = UserPointsSerializer

def get_queryset(self):
if self.action == 'list':
return self.instance.students
return self.instance.course_staff_and_students


Expand Down
5 changes: 3 additions & 2 deletions external_services/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ def verify_oauth_body_hash_and_signature(request, req_body_hash, lti_exercise=No

# check the OAuth timestamp. Do not allow old requests in order to prevent replay attacks.
try:
timestamp = datetime.datetime.utcfromtimestamp(int(req_oauth_params_dict.get('oauth_timestamp')))
timestamp = datetime.datetime.fromtimestamp(int(req_oauth_params_dict.get('oauth_timestamp')),
datetime.timezone.utc)
# oauth_timestamp: seconds since January 1, 1970 00:00:00 GMT
except ValueError:
return False, 'oauth_timestamp is missing or has an invalid format'

now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc)
delta = datetime.timedelta(seconds=OAuthNonceCache.CACHE_TIMEOUT_SECONDS)
if not (now - delta < timestamp and timestamp < now + delta): # pylint: disable=chained-comparison
return False, 'oauth_timestamp has expired'
Expand Down
Loading