-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtongji.rb
executable file
·72 lines (61 loc) · 1.54 KB
/
tongji.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'yaml'
points_path = File.expand_path("../points/points.yml", __FILE__)
points = YAML.load_file points_path
kinds = %w{
single_choice
multi_choice
bool
essay
file_upload
}
tongji_info = {}
points.each do |point|
tongji_info[point] = {}
kinds.each do |kind|
tongji_info[point][kind] = {
count: 0,
items: []
}
end
end
path = File.expand_path("../", __FILE__)
Dir[File.join(path, "*.yml")].each do |yaml_file|
yaml = YAML.load_file yaml_file
yaml.each do |item|
p item
kind = item["kind"]
point = item["points"][0]
tongji_info[point][kind][:count] += 1
tongji_info[point][kind][:items] << item
end
end
all_count = 0
single_choice = 0
multi_choice = 0
essay = 0
file_upload = 0
points.each do |point|
p "--------------- 知识点:#{point}"
kinds.each do |kind|
if kind == "single_choice"
single_choice += tongji_info[point][kind][:count]
end
if kind == "multi_choice"
multi_choice += tongji_info[point][kind][:count]
end
if kind == "essay"
essay += tongji_info[point][kind][:count]
end
if kind == "file_upload"
file_upload += tongji_info[point][kind][:count]
end
all_count += tongji_info[point][kind][:count]
p "#{kind}: #{tongji_info[point][kind][:count]}"
end
end
p "~~~~~~~~~~~~~~~~~"
p "single_choice: #{single_choice}"
p "multi_choice: #{multi_choice}"
p "essay: #{essay}"
p "file_upload: #{file_upload}"
p "all_count: #{all_count}"