File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 88
99# Python stdlib imports
1010import typing as _typing
11+ try :
12+ # Python 3
13+ from urllib .parse import urljoin as _urljoin
14+ from urllib .parse import urlencode as _urlencode
15+ except ImportError : # pragma: no cover
16+ # Python 2
17+ from urlparse import urljoin as _urljoin
18+ from urllib import urlencode as _urlencode
1119
1220# External dependencies
1321import six as _six
@@ -58,4 +66,36 @@ class Submissions(
5866 _FIELDS_READ_ONLY = [ "dateEdited" , "grade" , "files" , 'tests' ]
5967 _FIELDS_REQUIRED = [ "assignment" , "students" ]
6068
69+ def list_view_history (self , id = None , return_all = False ):
70+ """
71+ Returns the list of view histories associated with the submission.
72+ """
73+ _class_type = type (self )
74+
75+ id = self ._get_id (id = id )
76+
77+ endpoint = "/submissions/{}/history" .format (id )
78+ endpoint_params = {}
79+
80+ if len (endpoint_params ) > 0 :
81+ endpoint += "?{}" .format (_urlencode (endpoint_params ))
82+
83+ ret = self ._requestor ._request (
84+ endpoint = endpoint ,
85+ method = "GET" ,
86+ )
87+ if ret .status_code == 200 :
88+ # Returns a list of all submission histories
89+ lst = ret .json
90+
91+ # This list tends to only contain one history (bug!)
92+ if return_all :
93+ return lst
94+
95+ if len (lst ) > 0 :
96+ # FIXME: sort to guarantee most recent view
97+ return lst [0 ]
98+
99+ return dict ()
100+
61101# =============================================================================
Original file line number Diff line number Diff line change 11# Version number
2- __version__ = "0.2.27 "
2+ __version__ = "0.2.28 "
You can’t perform that action at this time.
0 commit comments