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
e4ffb2a5
Commit
e4ffb2a5
authored
Oct 24, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TestCenterUser model and export for Pearson
parent
be947770
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
0 deletions
+126
-0
common/djangoapps/student/management/commands/pearson_export_cdd.py
+60
-0
common/djangoapps/student/migrations/0020_add_test_center_user.py
+0
-0
common/djangoapps/student/models.py
+66
-0
No files found.
common/djangoapps/student/management/commands/pearson_export_cdd.py
0 → 100644
View file @
e4ffb2a5
import
csv
from
collections
import
OrderedDict
from
datetime
import
datetime
from
django.core.management.base
import
BaseCommand
,
CommandError
from
student.models
import
TestCenterUser
class
Command
(
BaseCommand
):
CSV_TO_MODEL_FIELDS
=
OrderedDict
([
(
"ClientCandidateID"
,
"client_candidate_id"
),
(
"FirstName"
,
"first_name"
),
(
"LastName"
,
"last_name"
),
(
"MiddleName"
,
"middle_name"
),
(
"Suffix"
,
"suffix"
),
(
"Salutation"
,
"salutation"
),
(
"Email"
,
"email"
),
# Skipping optional fields Username and Password
(
"Address1"
,
"address_1"
),
(
"Address2"
,
"address_2"
),
(
"Address3"
,
"address_3"
),
(
"City"
,
"city"
),
(
"State"
,
"state"
),
(
"PostalCode"
,
"postal_code"
),
(
"Country"
,
"country"
),
(
"Phone"
,
"phone"
),
(
"Extension"
,
"extension"
),
(
"PhoneCountryCode"
,
"phone_country_code"
),
(
"FAX"
,
"fax"
),
(
"FAXCountryCode"
,
"fax_country_code"
),
(
"CompanyName"
,
"company_name"
),
# Skipping optional field CustomQuestion
(
"LastUpdate"
,
"user_updated_at"
),
# in UTC, so same as what we store
])
args
=
'<output_file>'
help
=
"""
Export user information from TestCenterUser model into a tab delimited
text file with a format that Pearson expects.
"""
def
handle
(
self
,
*
args
,
**
kwargs
):
if
len
(
args
)
<
1
:
print
Command
.
help
return
with
open
(
args
[
0
],
"wb"
)
as
outfile
:
writer
=
csv
.
DictWriter
(
outfile
,
Command
.
CSV_TO_MODEL_FIELDS
,
delimiter
=
"
\t
"
,
quoting
=
csv
.
QUOTE_MINIMAL
,
extrasaction
=
'ignore'
)
writer
.
writeheader
()
for
tcu
in
TestCenterUser
.
objects
.
order_by
(
'id'
):
record
=
dict
((
csv_field
,
getattr
(
tcu
,
model_field
))
for
csv_field
,
model_field
in
Command
.
CSV_TO_MODEL_FIELDS
.
items
())
record
[
"LastUpdate"
]
=
record
[
"LastUpdate"
]
.
strftime
(
"
%
Y/
%
m/
%
d
%
H:
%
M:
%
S"
)
writer
.
writerow
(
record
)
common/djangoapps/student/migrations/0020_add_test_center_user.py
0 → 100644
View file @
e4ffb2a5
This diff is collapsed.
Click to expand it.
common/djangoapps/student/models.py
View file @
e4ffb2a5
...
...
@@ -133,6 +133,72 @@ class UserProfile(models.Model):
def
set_meta
(
self
,
js
):
self
.
meta
=
json
.
dumps
(
js
)
class
TestCenterUser
(
models
.
Model
):
"""This is our representation of the User for in-person testing, and
specifically for Pearson at this point. A few things to note:
* Pearson only supports Latin-1, so we have to make sure that the data we
capture here will work with that encoding.
* While we have a lot of this demographic data in UserProfile, it's much
more free-structured there. We'll try to pre-pop the form with data from
UserProfile, but we'll need to have a step where people who are signing
up re-enter their demographic data into the fields we specify.
* Users are only created here if they register to take an exam in person.
The field names and lengths are modeled on the conventions and constraints
of Pearson's data import system, including oddities such as suffix having
a limit of 255 while last_name only gets 50.
"""
# Our own record keeping...
# user = models.ForeignKey(User, unique=True)
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
,
db_index
=
True
)
updated_at
=
models
.
DateTimeField
(
auto_now
=
True
,
db_index
=
True
)
# user_updated_at happens only when the user makes a change to their data,
# and is something Pearson needs to know to manage updates. Unlike
# updated_at, this will not get incremented when we do a batch data import.
user_updated_at
=
models
.
DateTimeField
(
db_index
=
True
)
# Unique ID given to us for this User by the Testing Center. It's null when
# we first create the User entry, and is assigned by Pearson later.
candidate_id
=
models
.
IntegerField
(
null
=
True
,
db_index
=
True
)
# Unique ID we assign our user for a the Test Center.
client_candidate_id
=
models
.
CharField
(
max_length
=
50
,
db_index
=
True
)
# Name
first_name
=
models
.
CharField
(
max_length
=
30
,
db_index
=
True
)
last_name
=
models
.
CharField
(
max_length
=
50
,
db_index
=
True
)
middle_name
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
)
suffix
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
salutation
=
models
.
CharField
(
max_length
=
50
,
blank
=
True
)
# Address
address_1
=
models
.
CharField
(
max_length
=
40
)
address_2
=
models
.
CharField
(
max_length
=
40
,
blank
=
True
)
address_3
=
models
.
CharField
(
max_length
=
40
,
blank
=
True
)
city
=
models
.
CharField
(
max_length
=
32
,
db_index
=
True
)
# state example: HI -- they have an acceptable list that we'll just plug in
# state is required if you're in the US or Canada, but otherwise not.
state
=
models
.
CharField
(
max_length
=
20
,
blank
=
True
,
db_index
=
True
)
# postal_code required if you're in the US or Canada
postal_code
=
models
.
CharField
(
max_length
=
16
,
blank
=
True
,
db_index
=
True
)
# country is a ISO 3166-1 alpha-3 country code (e.g. "USA", "CAN", "MNG")
country
=
models
.
CharField
(
max_length
=
3
,
db_index
=
True
)
# Phone
phone
=
models
.
CharField
(
max_length
=
35
)
extension
=
models
.
CharField
(
max_length
=
8
,
blank
=
True
,
db_index
=
True
)
phone_country_code
=
models
.
CharField
(
max_length
=
3
,
db_index
=
True
)
fax
=
models
.
CharField
(
max_length
=
35
,
blank
=
True
)
# fax_country_code required *if* fax is present.
fax_country_code
=
models
.
CharField
(
max_length
=
3
,
blank
=
True
)
# Company
company_name
=
models
.
CharField
(
max_length
=
50
,
blank
=
True
)
@property
def
email
(
self
):
return
""
# should return user.email, but stub for now
## TODO: Should be renamed to generic UserGroup, and possibly
# Given an optional field for type of group
...
...
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