kgrift 1.3.108
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/KGrift/Gemfile +22 -0
- data/KGrift/README.md +66 -0
- data/KGrift/bin/kgrift +11 -0
- data/KGrift/grifter.yml +224 -0
- data/KGrift/internal_test_graphs/basic_test_graph_definition.yml +2915 -0
- data/KGrift/internal_test_graphs/unicode_test_graph_definition.yml +3070 -0
- data/KGrift/knewton_grifts/analytics_grifts.rb +103 -0
- data/KGrift/knewton_grifts/async_helper_grifts.rb +63 -0
- data/KGrift/knewton_grifts/authenticator_grifts.rb +46 -0
- data/KGrift/knewton_grifts/basic_grifts.rb +29 -0
- data/KGrift/knewton_grifts/batch_grifts.rb +14 -0
- data/KGrift/knewton_grifts/content_collection_grifts.rb +204 -0
- data/KGrift/knewton_grifts/content_collection_v1_grifts.rb +521 -0
- data/KGrift/knewton_grifts/content_eid_grifts.rb +41 -0
- data/KGrift/knewton_grifts/copy_grifts.rb +151 -0
- data/KGrift/knewton_grifts/deprecated_graph_and_taxonomy_grifts.rb +353 -0
- data/KGrift/knewton_grifts/goal_grifts.rb +203 -0
- data/KGrift/knewton_grifts/graph_and_taxonomy_grifts.rb +136 -0
- data/KGrift/knewton_grifts/graph_create_grifts.rb +34 -0
- data/KGrift/knewton_grifts/graph_query_grifts.rb +448 -0
- data/KGrift/knewton_grifts/graph_tools_grifts.rb +151 -0
- data/KGrift/knewton_grifts/graph_validation_grifts.rb +447 -0
- data/KGrift/knewton_grifts/helper_grifts.rb +92 -0
- data/KGrift/knewton_grifts/jmeter_data_grifts.rb +56 -0
- data/KGrift/knewton_grifts/learning_instance_grifts.rb +46 -0
- data/KGrift/knewton_grifts/looper_grifts.rb +34 -0
- data/KGrift/knewton_grifts/moxy_grifts.rb +64 -0
- data/KGrift/knewton_grifts/oauth_grifts.rb +182 -0
- data/KGrift/knewton_grifts/partner_grifts.rb +70 -0
- data/KGrift/knewton_grifts/partner_support_grifts.rb +85 -0
- data/KGrift/knewton_grifts/recommendation_setup_grifts.rb +215 -0
- data/KGrift/knewton_grifts/registration_grifts.rb +159 -0
- data/KGrift/knewton_grifts/registration_info_grifts.rb +23 -0
- data/KGrift/knewton_grifts/report_grifts.rb +122 -0
- data/KGrift/knewton_grifts/shell_command_grifts.rb +21 -0
- data/KGrift/knewton_grifts/student_flow_grifts.rb +560 -0
- data/KGrift/knewton_grifts/tag_grifts.rb +41 -0
- data/KGrift/knewton_grifts/test_data_grifts.rb +328 -0
- data/KGrift/knewton_grifts/test_user_grifts.rb +264 -0
- data/KGrift/lib/dtrace.rb +20 -0
- data/KGrift/lib/kgrift.rb +7 -0
- data/KGrift/test_data_generators/basic_book_and_taxonomies.rb +35 -0
- data/KGrift/test_data_generators/lo_test_graph.rb +34 -0
- data/KGrift/test_data_generators/partner_owned_book_and_taxonomies.rb +28 -0
- data/KGrift/test_data_generators/partner_owned_book_and_taxonomies_unicode.rb +28 -0
- data/KGrift/test_data_generators/sandcastle_book_and_taxonomies.rb +13 -0
- data/KGrift/test_data_generators/sandcastle_book_and_taxonomies.yml +3709 -0
- data/KGrift/test_data_generators/sandcastle_graph.rb +8 -0
- data/KGrift/test_data_generators/sandcastle_graph_definition.json +4483 -0
- data/KGrift/test_data_generators/sandcastle_graph_full.rb +7 -0
- data/KGrift/test_data_generators/sandcastle_taxonomies.yml +378 -0
- data/KGrift/test_data_generators/sandcastle_with_taxons.rb +56 -0
- data/KGrift/test_data_generators/sandcastle_with_taxons.yml +3994 -0
- data/KGrift/test_data_generators/test_users_and_partners.rb +76 -0
- data/kgrift.gemspec +43 -0
- metadata +144 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
def get_module_iid graph, eid
|
2
|
+
graph['nodes'].select{|n| n['temp_id'] and n['temp_id']==(graph['name']+':'+eid)}.first['id']
|
3
|
+
end
|
4
|
+
|
5
|
+
def get_full_taxon_path taxonomy, taxon_id, path=''
|
6
|
+
taxon = taxonomy['taxons'].select{|t| t['id']==taxon_id}.first
|
7
|
+
if taxon['parent_id']
|
8
|
+
get_full_taxon_path(taxonomy, taxon['parent_id']) + '|' + taxon['name'] + path
|
9
|
+
else
|
10
|
+
taxon['name'] + path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def construct_taxon_eid_map taxonomies
|
15
|
+
taxons = []
|
16
|
+
taxonomies.each do |taxonomy|
|
17
|
+
taxonomy_name = taxonomy['name']
|
18
|
+
taxonomy['taxons'].each do |taxon|
|
19
|
+
taxons << {
|
20
|
+
'iid' => taxon['id'],
|
21
|
+
'eid' => 'tref-' + taxonomy_name + ":" + get_full_taxon_path(taxonomy, taxon['id'])
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
taxons
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_taxon_eid_to_iid_map_for_graph graph_id
|
29
|
+
#create LI, get taxonomies, and cleanup
|
30
|
+
dummy_li = create_learning_instance 'graph_id' => graph_id
|
31
|
+
taxonomies = get_referenced_taxonomies dummy_li['id']
|
32
|
+
delete_learning_instance dummy_li['id']
|
33
|
+
#construct map list
|
34
|
+
map_list = construct_taxon_eid_map taxonomies
|
35
|
+
#return hashmap
|
36
|
+
map = {}
|
37
|
+
map_list.each do |taxon|
|
38
|
+
map[taxon['eid']] = taxon['iid']
|
39
|
+
end
|
40
|
+
map
|
41
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
GRIFTER_INSTANCES_BY_ENVIRONMENT = {}
|
2
|
+
|
3
|
+
def get_grifter_instance_for_env env
|
4
|
+
if env
|
5
|
+
unless GRIFTER_INSTANCES_BY_ENVIRONMENT[env]
|
6
|
+
new_grifter_config = {environment: env}
|
7
|
+
new_grifter_config[:config_file] = grifter_configuration[:config_file] if grifter_configuration[:config_file]
|
8
|
+
GRIFTER_INSTANCES_BY_ENVIRONMENT[env] = Grifter.new new_grifter_config
|
9
|
+
end
|
10
|
+
GRIFTER_INSTANCES_BY_ENVIRONMENT[env]
|
11
|
+
else
|
12
|
+
self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def copy_learning_instance options={}
|
18
|
+
options = {
|
19
|
+
'goal_target_score_override' => nil,
|
20
|
+
'goal_days_from_now_override' => nil,
|
21
|
+
'force_metrics' => false
|
22
|
+
}.merge(options)
|
23
|
+
|
24
|
+
source_environment = get_grifter_instance_for_env options['source_environment']
|
25
|
+
|
26
|
+
original_learning_instance = nil
|
27
|
+
original_partner_id = nil
|
28
|
+
source_environment.instance_eval do
|
29
|
+
set_account :knerd
|
30
|
+
# we'll get the learning instance in this special way so we can also get the partner id of it
|
31
|
+
# in case the graph_id is an eid, we'll need the partner id to translate it into an iid
|
32
|
+
original_learning_instance = get_learning_instance options['learning_instance_id'], additional_headers: { 'X-Include-Partner-Id' => 'true' }
|
33
|
+
original_partner_id = kapi.last_response['X-Partner-Id']
|
34
|
+
end
|
35
|
+
|
36
|
+
# figure out the graph id we want to use in our new learning instance
|
37
|
+
graph_id = if options['graph_id']
|
38
|
+
options['graph_id']
|
39
|
+
elsif original_learning_instance['graph_id'] =~ /^gref-/
|
40
|
+
source_environment.instance_eval do
|
41
|
+
set_account :knerd
|
42
|
+
translate_graph_gref_into_internal_id original_partner_id, original_learning_instance['graph_id']
|
43
|
+
end
|
44
|
+
else
|
45
|
+
original_learning_instance['graph_id']
|
46
|
+
end
|
47
|
+
|
48
|
+
new_learning_instance = create_learning_instance 'name' => "test learning instance for interesting goals made #{Time.now}",
|
49
|
+
'graph_id' => graph_id
|
50
|
+
|
51
|
+
if options['goal_id']
|
52
|
+
goal_id_list = [ options['goal_id'] ]
|
53
|
+
elsif options['goal_id_list']
|
54
|
+
goal_id_list = options['goal_id_list']
|
55
|
+
end
|
56
|
+
|
57
|
+
if goal_id_list
|
58
|
+
new_goal_list = []
|
59
|
+
for goal_id in goal_id_list
|
60
|
+
goal_to_copy = source_environment.instance_eval do
|
61
|
+
get_goal original_learning_instance['id'], goal_id
|
62
|
+
end
|
63
|
+
# the API will create a new id for this new goal
|
64
|
+
goal_to_copy.delete('id')
|
65
|
+
# if this is an MTMPTS/LO goal, delete the target_ids too
|
66
|
+
for target_module in goal_to_copy['target_modules']
|
67
|
+
if target_module.include?('target_id')
|
68
|
+
target_module.delete('target_id')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
if options['goal_target_score_override']
|
72
|
+
goal_to_copy['target_modules'].each {|tm| tm['target_score'] = options['goal_target_score_override'] }
|
73
|
+
end
|
74
|
+
if options['goal_days_from_now_override']
|
75
|
+
goal_target_date_override = days_from_now options['goal_days_from_now_override']
|
76
|
+
goal_to_copy['target_modules'].each {|tm| tm['target_date'] = goal_target_date_override }
|
77
|
+
end
|
78
|
+
if options['force_metrics']
|
79
|
+
goal_to_copy['metrics_enabled'] = true
|
80
|
+
end
|
81
|
+
new_goal = create_goal new_learning_instance['id'], goal_to_copy
|
82
|
+
new_goal_list << new_goal
|
83
|
+
end
|
84
|
+
else
|
85
|
+
new_goal_list = [ nil ] # previously-- if goal_id wasn't passed in, goal => nil was returned
|
86
|
+
end
|
87
|
+
if new_goal_list.length > 1
|
88
|
+
{
|
89
|
+
'learning_instance' => new_learning_instance,
|
90
|
+
'goal_list' => new_goal_list,
|
91
|
+
}
|
92
|
+
else
|
93
|
+
{
|
94
|
+
'learning_instance' => new_learning_instance,
|
95
|
+
'goal' => new_goal_list[0],
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
def prepare_graph_copy graph_id, options={}
|
102
|
+
|
103
|
+
options = {
|
104
|
+
remove_taxon_ids: true
|
105
|
+
}
|
106
|
+
|
107
|
+
graph = get_graph_and_cache_it graph_id
|
108
|
+
|
109
|
+
Log.info "Copying graph: #{graph['id']}"
|
110
|
+
|
111
|
+
orig_id = graph.delete 'id'
|
112
|
+
graph['name'] = "Copy of #{orig_id}(#{graph['name']})"
|
113
|
+
|
114
|
+
|
115
|
+
id_to_temp_id = {}
|
116
|
+
graph['nodes'].each_with_index do |node, i|
|
117
|
+
temp_id = get_mref_eid(i.to_s)
|
118
|
+
node['temp_id'] = temp_id
|
119
|
+
id_to_temp_id[node.delete('id')] = temp_id
|
120
|
+
|
121
|
+
node['name'] = "#{node['subtype']}-#{random_string(8)}" unless node['name']
|
122
|
+
|
123
|
+
if options[:remove_taxon_ids]
|
124
|
+
node.delete 'taxon_ids'
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
graph['edges'].each do |edge|
|
130
|
+
edge['start_temp_id'] = id_to_temp_id[edge.delete('start')]
|
131
|
+
edge['end_temp_id'] = id_to_temp_id[edge.delete('end')]
|
132
|
+
end
|
133
|
+
|
134
|
+
filename = "copy_#{orig_id}.json"
|
135
|
+
Log.info "Writing #{filename}"
|
136
|
+
File.open filename, 'w' do |f|
|
137
|
+
f.write(JSON.pretty_generate(graph))
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def post_graph_from_file filename
|
144
|
+
graph_obj = YAML.load_file filename
|
145
|
+
|
146
|
+
p graph_obj['name']
|
147
|
+
graph = create_graph graph_obj
|
148
|
+
|
149
|
+
Log.info "Created graph: #{graph['id']}"
|
150
|
+
graph['id']
|
151
|
+
end
|
@@ -0,0 +1,353 @@
|
|
1
|
+
# DEPRECATED METHODS
|
2
|
+
# DELETE THESE ONCE OLYMPIK MIGRATION IS DONE
|
3
|
+
# TE-1225
|
4
|
+
|
5
|
+
|
6
|
+
def create_graph overrides={}, params={}
|
7
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
8
|
+
Log.info "Creating graph"
|
9
|
+
response = nil
|
10
|
+
temp_id_one = get_mref_eid('1')
|
11
|
+
temp_id_two = get_mref_eid('2')
|
12
|
+
do_as_knewton_partner overrides.delete('use_current_user') do
|
13
|
+
response = kapi.post '/v0/graphs?' + URI.encode_www_form(params), {
|
14
|
+
'name' => random_graph_name,
|
15
|
+
'nodes' => [
|
16
|
+
{'temp_id' => temp_id_one, 'type' => 'concept', 'name' => 'n1', 'subtype' => nil },
|
17
|
+
{'temp_id' => temp_id_two, 'type' => 'concept', 'name' => 'n2', 'subtype' => nil },
|
18
|
+
],
|
19
|
+
'edges' =>
|
20
|
+
[
|
21
|
+
{
|
22
|
+
'start_temp_id' => temp_id_one,
|
23
|
+
'end_temp_id' => temp_id_two,
|
24
|
+
'type' => 'prerequisite',
|
25
|
+
'custom_data' => {'custom_key' => 'custom_value'},
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}.merge(overrides)
|
29
|
+
end
|
30
|
+
Log.info "Waiting for titanik to create graph"
|
31
|
+
wait_for_code 200 do
|
32
|
+
get_graph_and_cache_it response["id"]
|
33
|
+
end
|
34
|
+
response
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_basic_concept_graph uri_params={}
|
38
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
39
|
+
concept1 = get_mref_eid("concept1")
|
40
|
+
|
41
|
+
bndl1 = get_mref_eid("bndl1")
|
42
|
+
bndl2 = get_mref_eid("bndl2")
|
43
|
+
bndl3 = get_mref_eid("bndl3")
|
44
|
+
|
45
|
+
atom1 = get_mref_eid("atom1")
|
46
|
+
atom2 = get_mref_eid("atom2")
|
47
|
+
atom3 = get_mref_eid("atom3")
|
48
|
+
atom4 = get_mref_eid("atom4")
|
49
|
+
|
50
|
+
pool1 = get_mref_eid("pool1")
|
51
|
+
pool2 = get_mref_eid("pool2")
|
52
|
+
|
53
|
+
name = 'Single Concept Graph ' + random_string
|
54
|
+
graph_params = {
|
55
|
+
'name' => name,
|
56
|
+
'temp_id' => 'mref-'+name,
|
57
|
+
'nodes' => [
|
58
|
+
{ 'temp_id' => concept1, 'type' => 'concept', 'subtype' => nil, 'name' => 'Transgressive Placemaking' },
|
59
|
+
|
60
|
+
{ 'temp_id' => bndl1, 'type' => 'module', 'subtype' => 'bndl', 'name' => 'History of Tresspassing' },
|
61
|
+
{ 'temp_id' => bndl2, 'type' => 'module', 'subtype' => 'bndl', 'name' => 'Ethics of Tresspassing' },
|
62
|
+
{ 'temp_id' => bndl3, 'type' => 'module', 'subtype' => 'bndl', 'name' => 'Laws of Tresspassing' },
|
63
|
+
|
64
|
+
{ 'temp_id' => atom1, 'type' => 'module', 'subtype' => 'atom', 'name' => 'Emergence of private property' },
|
65
|
+
{ 'temp_id' => atom2, 'type' => 'module', 'subtype' => 'atom', 'name' => 'Quiz #1 - Tresspasing concepts' },
|
66
|
+
{ 'temp_id' => atom3, 'type' => 'module', 'subtype' => 'atom', 'name' => 'Natural rights vs Legal righhts' },
|
67
|
+
{ 'temp_id' => atom4, 'type' => 'module', 'subtype' => 'atom', 'name' => 'Quiz #2 - Tresspassing Laws' },
|
68
|
+
|
69
|
+
{ 'temp_id' => pool1, 'type' => 'module', 'subtype' => 'pool', 'name' => 'secret pool 1' },
|
70
|
+
{ 'temp_id' => pool2, 'type' => 'module', 'subtype' => 'pool', 'name' => 'secret pool 2' },
|
71
|
+
],
|
72
|
+
'edges' => [
|
73
|
+
#one pool teaches, one pool assesses
|
74
|
+
{ 'start_temp_id' => concept1, 'end_temp_id' => pool1, 'type' => 'taught_by' },
|
75
|
+
{ 'start_temp_id' => concept1, 'end_temp_id' => pool2, 'type' => 'assessed_by' },
|
76
|
+
|
77
|
+
{ 'start_temp_id' => pool1, 'end_temp_id' => atom1, 'type' => 'contains' },
|
78
|
+
{ 'start_temp_id' => pool1, 'end_temp_id' => atom2, 'type' => 'contains' },
|
79
|
+
{ 'start_temp_id' => pool1, 'end_temp_id' => atom3, 'type' => 'contains' },
|
80
|
+
|
81
|
+
{ 'start_temp_id' => pool2, 'end_temp_id' => atom2, 'type' => 'contains' },
|
82
|
+
{ 'start_temp_id' => pool2, 'end_temp_id' => atom3, 'type' => 'contains' },
|
83
|
+
{ 'start_temp_id' => pool2, 'end_temp_id' => atom4, 'type' => 'contains' },
|
84
|
+
|
85
|
+
{ 'start_temp_id' => bndl1, 'end_temp_id' => atom1, 'type' => 'contains' },
|
86
|
+
{ 'start_temp_id' => bndl1, 'end_temp_id' => atom2, 'type' => 'contains' },
|
87
|
+
|
88
|
+
{ 'start_temp_id' => bndl2, 'end_temp_id' => atom2, 'type' => 'contains' },
|
89
|
+
{ 'start_temp_id' => bndl2, 'end_temp_id' => atom3, 'type' => 'contains' },
|
90
|
+
|
91
|
+
{ 'start_temp_id' => bndl3, 'end_temp_id' => atom3, 'type' => 'contains' },
|
92
|
+
{ 'start_temp_id' => bndl3, 'end_temp_id' => atom4, 'type' => 'contains' },
|
93
|
+
],
|
94
|
+
}
|
95
|
+
|
96
|
+
|
97
|
+
create_graph graph_params, uri_params
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
# DEPRECATED
|
102
|
+
# this is the old graph_generator_grifts.rb
|
103
|
+
|
104
|
+
|
105
|
+
def create_test_graph options={}
|
106
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
107
|
+
graph_obj = generate_test_graph_object options
|
108
|
+
graph = create_graph graph_obj
|
109
|
+
|
110
|
+
graph['id']
|
111
|
+
end
|
112
|
+
|
113
|
+
#we used to have a real create_random_graph method
|
114
|
+
#it didnt make realistic graphs
|
115
|
+
#now it makes realistic graphs
|
116
|
+
def create_random_graph options={}
|
117
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
118
|
+
graph_obj = generate_test_graph_object options
|
119
|
+
graph = create_graph graph_obj
|
120
|
+
graph
|
121
|
+
end
|
122
|
+
|
123
|
+
def generate_test_graph_object options={}
|
124
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
125
|
+
options = {
|
126
|
+
concept_depth: 3,
|
127
|
+
num_starting_concepts: 1,
|
128
|
+
num_post_requisites_per_concept: 2,
|
129
|
+
}.merge(options)
|
130
|
+
|
131
|
+
graph = {
|
132
|
+
'name' => "Generated test graph #{datetime}",
|
133
|
+
'nodes' => [],
|
134
|
+
'edges' => [],
|
135
|
+
}
|
136
|
+
|
137
|
+
concept_num = 1
|
138
|
+
prereqconcepts = []
|
139
|
+
options[:num_starting_concepts].times do
|
140
|
+
new_concept_tempid = add_concept_to_graph graph, [], options.merge({concept_num: concept_num})
|
141
|
+
prereqconcepts << new_concept_tempid
|
142
|
+
concept_num += 1
|
143
|
+
end
|
144
|
+
|
145
|
+
(options[:concept_depth] - 1).times do
|
146
|
+
new_concepts = []
|
147
|
+
prereqconcepts.each do |prereqconcept|
|
148
|
+
options[:num_post_requisites_per_concept].times do
|
149
|
+
new_concept_tempid = add_concept_to_graph graph, [prereqconcept], options.merge({concept_num: concept_num})
|
150
|
+
new_concepts << new_concept_tempid
|
151
|
+
concept_num += 1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
prereqconcepts = new_concepts
|
155
|
+
end
|
156
|
+
|
157
|
+
return graph
|
158
|
+
end
|
159
|
+
|
160
|
+
def add_concept_to_graph graph, prereq_temp_ids=[], options={}
|
161
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
162
|
+
options = {
|
163
|
+
num_instructional_bundles_per_concept: 1,
|
164
|
+
num_atoms_per_instructional_bundle: 1,
|
165
|
+
num_assessment_bundles_per_concept: 1,
|
166
|
+
num_atoms_per_assessment_bundle: 3,
|
167
|
+
concept_num: random_string(8),
|
168
|
+
}.merge(options)
|
169
|
+
|
170
|
+
concept_name = get_mref_eid("concept-#{options[:concept_num]}")
|
171
|
+
assessing_pool_name = get_mref_eid('assessing_pool-'+concept_name)
|
172
|
+
teaching_pool_name = get_mref_eid('teaching_pool-'+concept_name)
|
173
|
+
|
174
|
+
concept = {
|
175
|
+
'nodes' => [
|
176
|
+
{ 'temp_id' => concept_name, 'type' => 'concept', 'subtype' => nil, 'name' => concept_name },
|
177
|
+
{ 'temp_id' => teaching_pool_name, 'type' => 'module', 'subtype' => 'pool', 'name' => 'teaching_pool' },
|
178
|
+
{ 'temp_id' => assessing_pool_name, 'type' => 'module', 'subtype' => 'pool', 'name' => 'assessing_pool' },
|
179
|
+
],
|
180
|
+
'edges' => prereq_temp_ids.map{|prereq| { 'start_temp_id' => prereq, 'end_temp_id' => concept_name, 'type' => 'prerequisite'}} +
|
181
|
+
[
|
182
|
+
{ 'start_temp_id' => concept_name, 'end_temp_id' => teaching_pool_name, 'type' => 'taught_by' },
|
183
|
+
{ 'start_temp_id' => concept_name, 'end_temp_id' => assessing_pool_name, 'type' => 'assessed_by' },
|
184
|
+
],
|
185
|
+
}
|
186
|
+
|
187
|
+
options[:num_instructional_bundles_per_concept].times do |bndl_num|
|
188
|
+
bndl_name = concept_name + "-instructional-bundle-#{bndl_num}"
|
189
|
+
concept['nodes'] << {'temp_id' => bndl_name, 'type' => 'module', 'subtype' => 'bndl', 'name' => bndl_name }
|
190
|
+
|
191
|
+
options[:num_atoms_per_instructional_bundle].times do |atom_num|
|
192
|
+
atom_name = get_mref_eid(bndl_name + "-atom-#{atom_num}")
|
193
|
+
concept['nodes'] << {'temp_id' => atom_name, 'type' => 'module', 'subtype' => 'atom', 'name' => atom_name }
|
194
|
+
concept['edges'] << {'start_temp_id' => teaching_pool_name, 'end_temp_id' => atom_name, 'type' => 'contains' }
|
195
|
+
concept['edges'] << {'start_temp_id' => bndl_name, 'end_temp_id' => atom_name, 'type' => 'contains' }
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
options[:num_assessment_bundles_per_concept].times do |bndl_num|
|
200
|
+
bndl_name = concept_name + "-assessment-bundle-#{bndl_num}"
|
201
|
+
concept['nodes'] << {'temp_id' => bndl_name, 'type' => 'module', 'subtype' => 'bndl', 'name' => bndl_name }
|
202
|
+
|
203
|
+
options[:num_atoms_per_assessment_bundle].times do |atom_num|
|
204
|
+
atom_name = get_mref_eid(bndl_name + "-atom-#{atom_num}")
|
205
|
+
concept['nodes'] << {'temp_id' => atom_name, 'type' => 'module', 'subtype' => 'atom', 'name' => atom_name }
|
206
|
+
concept['edges'] << {'start_temp_id' => assessing_pool_name, 'end_temp_id' => atom_name, 'type' => 'contains' }
|
207
|
+
concept['edges'] << {'start_temp_id' => bndl_name, 'end_temp_id' => atom_name, 'type' => 'contains' }
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
graph['nodes'] += concept['nodes']
|
212
|
+
graph['edges'] += concept['edges']
|
213
|
+
|
214
|
+
return concept_name
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
# DEPRECATED TAXONOMY GET METHODS
|
219
|
+
# the old taxonomy_grifts.rb
|
220
|
+
|
221
|
+
def get_taxonomy (id, overrides={})
|
222
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
223
|
+
Log.info "Getting taxonomy by id: '#{id}'."
|
224
|
+
do_as_knewton_partner overrides.delete('use_current_user') do
|
225
|
+
kapi.get "/v0/taxonomies/#{id}"
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def get_taxonomies_for_partner_id(partner_id, overrides={})
|
230
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
231
|
+
Log.info "Getting taxonomies for partner id: '#{partner_id}'."
|
232
|
+
|
233
|
+
do_as_knewton_partner overrides.delete('use_current_user') do
|
234
|
+
kapi.get "/v0/taxonomies?"+ URI.encode_www_form({"partner_id" => partner_id})
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def get_referenced_taxonomies(learning_instance_id, overrides={})
|
239
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
240
|
+
Log.info "Getting referenced taxonomies by learning instance id: '#{learning_instance_id}'."
|
241
|
+
|
242
|
+
do_as_knewton_partner overrides.delete('use_current_user') do
|
243
|
+
kapi.get "/v0/taxonomies?"+ URI.encode_www_form({"learning_instance_id" => learning_instance_id})
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
def create_taxonomy (overrides={}, params={})
|
250
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
251
|
+
Log.info "Creating taxonomy."
|
252
|
+
do_as_knewton_partner overrides.delete('use_current_user') do
|
253
|
+
kapi.post '/v0/taxonomies?' + URI.encode_www_form(params), {
|
254
|
+
'name' => random_taxonomy_name,
|
255
|
+
'type' => 'role'
|
256
|
+
}.merge(overrides)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
def create_taxon (taxonomy_id, overrides={})
|
262
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
263
|
+
Log.info "Creating taxon on taxonomy with id: '#{taxonomy_id}'."
|
264
|
+
response = nil
|
265
|
+
do_as_knewton_partner overrides.delete('use_current_user') do
|
266
|
+
response = kapi.post "/v0/taxonomies/#{taxonomy_id}/taxons", {
|
267
|
+
'name' => 'footaxon',
|
268
|
+
}.merge(overrides)
|
269
|
+
end
|
270
|
+
Log.info "Waiting for Titanik to create taxon"
|
271
|
+
eventually do
|
272
|
+
taxonomy = get_taxonomy taxonomy_id
|
273
|
+
(taxonomy.find{|r| response['id']}).should_not == nil
|
274
|
+
end
|
275
|
+
response
|
276
|
+
end
|
277
|
+
|
278
|
+
def create_basic_taxonomy (overrides={}, params={})
|
279
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
280
|
+
basic_json = {
|
281
|
+
'name' => 'taxidermy',
|
282
|
+
'type' => 'role',
|
283
|
+
'taxons' => [
|
284
|
+
{'path' => 'basics|methods|material|basics|clay'},
|
285
|
+
{'path' => 'basics|methods|material|chemicals|dextrin'},
|
286
|
+
{'path' => 'basics|methods|tools|fleshing|throat_scraper_cone'},
|
287
|
+
{'path' => 'animals|fish|blobfish'}
|
288
|
+
]
|
289
|
+
}
|
290
|
+
response = create_taxonomy(basic_json.merge(overrides), params)
|
291
|
+
kapi.last_response.status.should == 201
|
292
|
+
Log.info "Waiting for titanik to create taxonomy"
|
293
|
+
eventually do
|
294
|
+
begin
|
295
|
+
get_taxonomy response["id"]
|
296
|
+
kapi.last_response.status.should == 200
|
297
|
+
rescue Grifter::RequestException
|
298
|
+
# ignored
|
299
|
+
end
|
300
|
+
kapi.last_response.status.should == 200
|
301
|
+
end
|
302
|
+
response
|
303
|
+
end
|
304
|
+
|
305
|
+
def create_basic_taxon_graph
|
306
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
307
|
+
taxonomy = create_basic_taxonomy
|
308
|
+
taxon_id1 = taxonomy['taxons'][0]['id']
|
309
|
+
taxon_id2 = taxonomy['taxons'][2]['id']
|
310
|
+
|
311
|
+
footempid1 = get_tref_eid("footempid1")
|
312
|
+
footempid2 = get_tref_eid("footempid2")
|
313
|
+
footempid3 = get_tref_eid("footempid3")
|
314
|
+
footempid4 = get_tref_eid("footempid4")
|
315
|
+
footempid5 = get_tref_eid("footempid5")
|
316
|
+
conceptparty = get_tref_eid("conceptparty")
|
317
|
+
poolparty = get_tref_eid("poolparty")
|
318
|
+
|
319
|
+
create_graph 'nodes' => [
|
320
|
+
{'temp_id' => footempid1, 'type' => 'module', 'name' => 'fooname1', 'subtype' => 'atom', 'taxon_ids' => [taxon_id1], 'is_taxon_recommendable' => true},
|
321
|
+
{'temp_id' => footempid2, 'type' => 'module', 'name' => 'fooname2', 'subtype' => 'atom', 'taxon_ids' => [taxon_id2], 'is_taxon_recommendable' => true},
|
322
|
+
{'temp_id' => footempid3, 'type' => 'module', 'name' => 'fooname3', 'subtype' => 'atom', 'taxon_ids' => [taxon_id2], 'is_taxon_recommendable' => true},
|
323
|
+
{'temp_id' => footempid4, 'type' => 'module', 'name' => 'fooname4', 'subtype' => 'atom', 'taxon_ids' => [taxon_id2], 'is_taxon_recommendable' => true},
|
324
|
+
{'temp_id' => footempid5, 'type' => 'module', 'name' => 'fooname5', 'subtype' => 'atom', 'taxon_ids' => [taxon_id2], 'is_taxon_recommendable' => true},
|
325
|
+
{'temp_id' => conceptparty, 'type' => 'concept', 'name' => 'some concept'},
|
326
|
+
{'temp_id' => poolparty, 'type' => 'module', 'subtype' => 'pool', 'name' => 'some pool', 'is_taxon_recommendable' => true},
|
327
|
+
],
|
328
|
+
'edges' => [
|
329
|
+
{ 'type' => 'contains', 'start_temp_id' => poolparty, 'end_temp_id' => footempid1},
|
330
|
+
{ 'type' => 'contains', 'start_temp_id' => poolparty, 'end_temp_id' => footempid2},
|
331
|
+
{ 'type' => 'contains', 'start_temp_id' => poolparty, 'end_temp_id' => footempid3},
|
332
|
+
{ 'type' => 'contains', 'start_temp_id' => poolparty, 'end_temp_id' => footempid4},
|
333
|
+
{ 'type' => 'contains', 'start_temp_id' => poolparty, 'end_temp_id' => footempid5},
|
334
|
+
{ 'type' => 'assessed_by', 'start_temp_id' => conceptparty, 'end_temp_id' => poolparty},
|
335
|
+
]
|
336
|
+
end
|
337
|
+
|
338
|
+
def get_all_graph_taxonomies graph
|
339
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
340
|
+
graph['nodes'].select{ |node| node['type']=='module' and
|
341
|
+
(node['subtype']=='atom' or node['subtype']=='bndl')
|
342
|
+
}.map{ |node| node['taxon_ids'] }.flatten.uniq
|
343
|
+
end
|
344
|
+
|
345
|
+
def get_modules_by_taxonomy graph, taxon_id
|
346
|
+
Log.warn "DEPRECATED GRIFT CALLED: #{__method__}"
|
347
|
+
#select all modules by taxon id
|
348
|
+
all_module_ids = graph['nodes'].select{|node| node['type']=='module' and
|
349
|
+
(node['subtype']=='atom' or node['subtype']=='bndl') and
|
350
|
+
node['taxon_ids'].include?(taxon_id)
|
351
|
+
}.map{|node| node['id'] }
|
352
|
+
return all_module_ids
|
353
|
+
end
|