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
4a835433
Commit
4a835433
authored
May 02, 2013
by
Carlos Andrés Rocha
Committed by
Calen Pennington
May 15, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused fixtures
parent
79a029ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
100 deletions
+0
-100
fixtures/anonymize_fixtures.py
+0
-98
fixtures/pm.json
+0
-2
No files found.
fixtures/anonymize_fixtures.py
deleted
100755 → 0
View file @
79a029ce
#! /usr/bin/env python
import
sys
import
json
import
random
import
copy
from
collections
import
defaultdict
from
argparse
import
ArgumentParser
,
FileType
from
datetime
import
datetime
def
generate_user
(
user_number
):
return
{
"pk"
:
user_number
,
"model"
:
"auth.user"
,
"fields"
:
{
"status"
:
"w"
,
"last_name"
:
"Last"
,
"gold"
:
0
,
"is_staff"
:
False
,
"user_permissions"
:
[],
"interesting_tags"
:
""
,
"email_key"
:
None
,
"date_joined"
:
"2012-04-26 11:36:39"
,
"first_name"
:
""
,
"email_isvalid"
:
False
,
"avatar_type"
:
"n"
,
"website"
:
""
,
"is_superuser"
:
False
,
"date_of_birth"
:
None
,
"last_login"
:
"2012-04-26 11:36:48"
,
"location"
:
""
,
"new_response_count"
:
0
,
"email"
:
"user{num}@example.com"
.
format
(
num
=
user_number
),
"username"
:
"user{num}"
.
format
(
num
=
user_number
),
"is_active"
:
True
,
"consecutive_days_visit_count"
:
0
,
"email_tag_filter_strategy"
:
1
,
"groups"
:
[],
"password"
:
"sha1$90e6f$562a1d783a0c47ce06ebf96b8c58123a0671bbf0"
,
"silver"
:
0
,
"bronze"
:
0
,
"questions_per_page"
:
10
,
"about"
:
""
,
"show_country"
:
True
,
"country"
:
""
,
"display_tag_filter_strategy"
:
0
,
"seen_response_count"
:
0
,
"real_name"
:
""
,
"ignored_tags"
:
""
,
"reputation"
:
1
,
"gravatar"
:
"366d981a10116969c568a18ee090f44c"
,
"last_seen"
:
"2012-04-26 11:36:39"
}
}
def
parse_args
(
args
=
sys
.
argv
[
1
:]):
parser
=
ArgumentParser
()
parser
.
add_argument
(
'-d'
,
'--data'
,
type
=
FileType
(
'r'
),
default
=
sys
.
stdin
)
parser
.
add_argument
(
'-o'
,
'--output'
,
type
=
FileType
(
'w'
),
default
=
sys
.
stdout
)
parser
.
add_argument
(
'count'
,
type
=
int
)
return
parser
.
parse_args
(
args
)
def
main
(
args
=
sys
.
argv
[
1
:]):
args
=
parse_args
(
args
)
data
=
json
.
load
(
args
.
data
)
unique_students
=
set
(
entry
[
'fields'
][
'student'
]
for
entry
in
data
)
if
args
.
count
>
len
(
unique_students
)
*
0.1
:
raise
Exception
(
"Can't be sufficiently anonymous selecting {count} of {unique} students"
.
format
(
count
=
args
.
count
,
unique
=
len
(
unique_students
)))
by_problems
=
defaultdict
(
list
)
for
entry
in
data
:
by_problems
[
entry
[
'fields'
][
'module_id'
]]
.
append
(
entry
)
out_data
=
[]
out_pk
=
1
for
name
,
answers
in
by_problems
.
items
():
for
student_id
in
xrange
(
args
.
count
):
sample
=
random
.
choice
(
answers
)
data
=
copy
.
deepcopy
(
sample
)
data
[
"fields"
][
"student"
]
=
student_id
+
1
data
[
"fields"
][
"created"
]
=
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
data
[
"fields"
][
"modified"
]
=
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
data
[
"pk"
]
=
out_pk
out_pk
+=
1
out_data
.
append
(
data
)
for
student_id
in
xrange
(
args
.
count
):
out_data
.
append
(
generate_user
(
student_id
))
json
.
dump
(
out_data
,
args
.
output
,
indent
=
2
)
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
fixtures/pm.json
deleted
100644 → 0
View file @
79a029ce
[{
"pk"
:
1
,
"model"
:
"user.userprofile"
,
"fields"
:
{
"name"
:
"pm"
,
"language"
:
"pm"
,
"courseware"
:
"course.xml"
,
"meta"
:
""
,
"location"
:
"pm"
,
"user"
:
1
}},
{
"pk"
:
1
,
"model"
:
"auth.user"
,
"fields"
:
{
"status"
:
"w"
,
"last_name"
:
""
,
"gold"
:
0
,
"is_staff"
:
true
,
"user_permissions"
:
[],
"interesting_tags"
:
""
,
"email_key"
:
null
,
"date_joined"
:
"2012-01-23 17:03:54"
,
"first_name"
:
""
,
"email_isvalid"
:
false
,
"avatar_type"
:
"n"
,
"website"
:
""
,
"is_superuser"
:
true
,
"date_of_birth"
:
null
,
"last_login"
:
"2012-01-23 17:04:16"
,
"location"
:
""
,
"new_response_count"
:
0
,
"email"
:
"pmitros@csail.mit.edu"
,
"username"
:
"pm"
,
"is_active"
:
true
,
"consecutive_days_visit_count"
:
0
,
"email_tag_filter_strategy"
:
1
,
"groups"
:
[],
"password"
:
"sha1$a3e96$dbabbd114f0da01bce2cc2adcafa2ca651c7ae0a"
,
"silver"
:
0
,
"bronze"
:
0
,
"questions_per_page"
:
10
,
"about"
:
""
,
"show_country"
:
false
,
"country"
:
""
,
"display_tag_filter_strategy"
:
0
,
"seen_response_count"
:
0
,
"real_name"
:
""
,
"ignored_tags"
:
""
,
"reputation"
:
1
,
"gravatar"
:
"7a591afd0cc7972fdbe5e12e26af352a"
,
"last_seen"
:
"2012-01-23 17:04:41"
}},
{
"pk"
:
1
,
"model"
:
"user.userprofile"
,
"fields"
:
{
"name"
:
"pm"
,
"language"
:
"pm"
,
"courseware"
:
"course.xml"
,
"meta"
:
""
,
"location"
:
"pm"
,
"user"
:
1
}},
{
"pk"
:
1
,
"model"
:
"auth.user"
,
"fields"
:
{
"status"
:
"w"
,
"last_name"
:
""
,
"gold"
:
0
,
"is_staff"
:
true
,
"user_permissions"
:
[],
"interesting_tags"
:
""
,
"email_key"
:
null
,
"date_joined"
:
"2012-01-23 17:03:54"
,
"first_name"
:
""
,
"email_isvalid"
:
false
,
"avatar_type"
:
"n"
,
"website"
:
""
,
"is_superuser"
:
true
,
"date_of_birth"
:
null
,
"last_login"
:
"2012-01-23 17:04:16"
,
"location"
:
""
,
"new_response_count"
:
0
,
"email"
:
"pmitros@csail.mit.edu"
,
"username"
:
"pm"
,
"is_active"
:
true
,
"consecutive_days_visit_count"
:
0
,
"email_tag_filter_strategy"
:
1
,
"groups"
:
[],
"password"
:
"sha1$a3e96$dbabbd114f0da01bce2cc2adcafa2ca651c7ae0a"
,
"silver"
:
0
,
"bronze"
:
0
,
"questions_per_page"
:
10
,
"about"
:
""
,
"show_country"
:
false
,
"country"
:
""
,
"display_tag_filter_strategy"
:
0
,
"seen_response_count"
:
0
,
"real_name"
:
""
,
"ignored_tags"
:
""
,
"reputation"
:
1
,
"gravatar"
:
"7a591afd0cc7972fdbe5e12e26af352a"
,
"last_seen"
:
"2012-01-23 17:04:41"
}}]
\ 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