ApplicationDataHelper.java
3.84 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.sunvote.txpad;
import android.text.TextUtils;
import com.sunvote.txpad.bean.StudentScore;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Created by Elvis on 2017/9/22.
* Email:Eluis@psunsky.com
* 版权所有:长沙中天电子设计开发有限公司
* Description: 易测(ETest)
*/
public class ApplicationDataHelper {
private static final ApplicationDataHelper ourInstance = new ApplicationDataHelper();
public static ApplicationDataHelper getInstance() {
return ourInstance;
}
private ApplicationDataHelper() {
}
/**
* 获取题目类型
* @param id
* @return
*/
public int getQuestionType(int id) {
switch (id) {
case 1:
return R.string.examination_question_type_choose;
default:
return 0;
}
}
/**
* 获取试卷类型 文本转换
* @param id 试卷类型
* @return
*/
public int getPaperType(String id) {
switch (id) {
case "mn":
return R.string.score_book_type_analog;
case "zt":
return R.string.score_book_type_zhenti;
case "pv":
return R.string.score_book_type_personal;
}
return R.string.score_book_type_analog;
}
/**
* @deprecated
* 替换键盘功能
* @param string
* @return
*/
public Map<Integer, Integer> getKeyBoardReplace(String string) {
Map<Integer, Integer> map = new HashMap<>();
if (string != null) {
String[] items = string.split(";");
if (items.length > 0) {
for (String item : items) {
String[] keyboards = item.split(":");
if (keyboards.length == 2) {
int oldBoard = Integer.parseInt(keyboards[0]);
int newBoard = Integer.parseInt(keyboards[1]);
map.put(oldBoard, newBoard);
}
}
}
}
return map;
}
/**
* @deprecated
* 替换键盘集合
* @param map
* @return
*/
public String getKeyboardReplaceStr(Map<Integer, Integer> map) {
StringBuilder sb = new StringBuilder();
if (map != null) {
Set<Integer> set = map.keySet();
for (Integer integer : set) {
sb.append(integer).append(":").append(map.get(integer)).append(";");
}
}
return sb.toString();
}
/**
* 查询是否有键盘信息
* @param map 键盘替换集合
* @param newKeyboard 新键盘
* @return
*/
public Integer getKeyboardBeenReplace(Map<Integer,Integer> map, Integer newKeyboard){
int ret = - 1;
if(map != null){
Set<Integer> set = map.keySet();
for (Integer integer : set) {
if(map.get(integer) == newKeyboard){
return integer;
}
}
}
return ret;
}
/**
* 是否是有效学生考试成绩
* @param studentScore 学生成绩考分
* @return
*/
public boolean isEffectiveStduent(StudentScore studentScore){
if(studentScore != null){
List<String> strings = studentScore.getAnswer();
if(strings != null){
for(String str : strings){
if(!TextUtils.isEmpty(str)){
String[] ss = str.split(",");
if(ss != null && ss.length >= 3 && (!TextUtils.isEmpty(ss[2]))){
if(!"0".equals(ss[2])){
return true;
}
}
}
}
}
}
return false;
}
}