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
7a84bed9
Commit
7a84bed9
authored
Oct 26, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hackish EAD export support
parent
bbbd9766
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
165 additions
and
3 deletions
+165
-3
common/djangoapps/student/management/commands/pearson_export_cdd.py
+2
-3
common/djangoapps/student/management/commands/pearson_export_ead.py
+163
-0
No files found.
common/djangoapps/student/management/commands/pearson_export_cdd.py
View file @
7a84bed9
...
@@ -67,10 +67,9 @@ class Command(BaseCommand):
...
@@ -67,10 +67,9 @@ class Command(BaseCommand):
return
TestCenterUser
(
**
data
)
return
TestCenterUser
(
**
data
)
def
generate_id
():
def
generate_id
():
sub_uuid
=
str
(
uuid
.
uuid4
())
.
upper
()
return
"edX{:012}"
.
format
(
uuid
.
uuid4
()
.
int
%
(
10
**
12
))
return
sub_uuid
[
-
12
:
-
8
]
+
'-'
+
sub_uuid
[
-
8
:
-
4
]
+
'-'
+
sub_uuid
[
-
4
:]
TestCenterUser
.
objects
.
all
()
.
delete
()
#
TestCenterUser.objects.all().delete()
samples
=
[
samples
=
[
make_sample
(
make_sample
(
...
...
common/djangoapps/student/management/commands/pearson_export_ead.py
0 → 100644
View file @
7a84bed9
import
csv
import
uuid
from
collections
import
defaultdict
,
OrderedDict
from
datetime
import
datetime
from
django.core.management.base
import
BaseCommand
,
CommandError
from
student.models
import
TestCenterUser
def
generate_id
():
return
"{:012}"
.
format
(
uuid
.
uuid4
()
.
int
%
(
10
**
12
))
class
Command
(
BaseCommand
):
args
=
'<output_file>'
help
=
"""
Export user information from TestCenterUser model into a tab delimited
text file with a format that Pearson expects.
"""
FIELDS
=
[
'AuthorizationTransactionType'
,
'AuthorizationID'
,
'ClientAuthorizationID'
,
'ClientCandidateID'
,
'ExamAuthorizationCount'
,
'ExamSeriesCode'
,
'EligibilityApptDateFirst'
,
'EligibilityApptDateLast'
,
'LastUpdate'
,
]
def
handle
(
self
,
*
args
,
**
kwargs
):
if
len
(
args
)
<
1
:
print
Command
.
help
return
# self.reset_sample_data()
with
open
(
args
[
0
],
"wb"
)
as
outfile
:
writer
=
csv
.
DictWriter
(
outfile
,
Command
.
FIELDS
,
delimiter
=
"
\t
"
,
quoting
=
csv
.
QUOTE_MINIMAL
,
extrasaction
=
'ignore'
)
writer
.
writeheader
()
for
tcu
in
TestCenterUser
.
objects
.
order_by
(
'id'
)[:
5
]:
record
=
defaultdict
(
lambda
:
""
,
AuthorizationTransactionType
=
"Add"
,
ClientAuthorizationID
=
generate_id
(),
ClientCandidateID
=
tcu
.
client_candidate_id
,
ExamAuthorizationCount
=
"1"
,
ExamSeriesCode
=
"MIT 6.002-001"
,
EligibilityApptDateFirst
=
"2012/12/15"
,
EligibilityApptDateLast
=
"2012/12/30"
,
LastUpdate
=
datetime
.
utcnow
()
.
strftime
(
"
%
Y/
%
m/
%
d
%
H:
%
M:
%
S"
)
)
writer
.
writerow
(
record
)
def
reset_sample_data
(
self
):
def
make_sample
(
**
kwargs
):
data
=
dict
((
model_field
,
kwargs
.
get
(
model_field
,
""
))
for
model_field
in
Command
.
CSV_TO_MODEL_FIELDS
.
values
())
return
TestCenterUser
(
**
data
)
# TestCenterUser.objects.all().delete()
samples
=
[
make_sample
(
client_candidate_id
=
generate_id
(),
first_name
=
"Jack"
,
last_name
=
"Doe"
,
middle_name
=
"C"
,
address_1
=
"11 Cambridge Center"
,
address_2
=
"Suite 101"
,
city
=
"Cambridge"
,
state
=
"MA"
,
postal_code
=
"02140"
,
country
=
"USA"
,
phone
=
"(617)555-5555"
,
phone_country_code
=
"1"
,
user_updated_at
=
datetime
.
utcnow
()
),
make_sample
(
client_candidate_id
=
generate_id
(),
first_name
=
"Clyde"
,
last_name
=
"Smith"
,
middle_name
=
"J"
,
suffix
=
"Jr."
,
salutation
=
"Mr."
,
address_1
=
"1 Penny Lane"
,
city
=
"Honolulu"
,
state
=
"HI"
,
postal_code
=
"96792"
,
country
=
"USA"
,
phone
=
"555-555-5555"
,
phone_country_code
=
"1"
,
user_updated_at
=
datetime
.
utcnow
()
),
make_sample
(
client_candidate_id
=
generate_id
(),
first_name
=
"Patty"
,
last_name
=
"Lee"
,
salutation
=
"Dr."
,
address_1
=
"P.O. Box 555"
,
city
=
"Honolulu"
,
state
=
"HI"
,
postal_code
=
"96792"
,
country
=
"USA"
,
phone
=
"808-555-5555"
,
phone_country_code
=
"1"
,
user_updated_at
=
datetime
.
utcnow
()
),
make_sample
(
client_candidate_id
=
generate_id
(),
first_name
=
"Jimmy"
,
last_name
=
"James"
,
address_1
=
"2020 Palmer Blvd."
,
city
=
"Springfield"
,
state
=
"MA"
,
postal_code
=
"96792"
,
country
=
"USA"
,
phone
=
"917-555-5555"
,
phone_country_code
=
"1"
,
extension
=
"2039"
,
fax
=
"917-555-5556"
,
fax_country_code
=
"1"
,
company_name
=
"ACME Traps"
,
user_updated_at
=
datetime
.
utcnow
()
),
make_sample
(
client_candidate_id
=
generate_id
(),
first_name
=
"Yeong-Un"
,
last_name
=
"Seo"
,
address_1
=
"Duryu, Lotte 101"
,
address_2
=
"Apt 55"
,
city
=
"Daegu"
,
country
=
"KOR"
,
phone
=
"917-555-5555"
,
phone_country_code
=
"011"
,
user_updated_at
=
datetime
.
utcnow
()
),
]
for
tcu
in
samples
:
tcu
.
save
()
\ No newline at end of file
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