Commit 90224e26a4c82b0c2aa8cbb3ef5081a1ab34ffe5
1 parent
f60bd9dc2b
Exists in
master
参数补充
Showing
3 changed files
with
31 additions
and
0 deletions
Show diff stats
app/src/main/java/com/hjx/parent/HomeworkFeedbackActivity.java
1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
2 | 2 | ||
3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
6 | import android.view.View; | 6 | import android.view.View; |
7 | import android.widget.ImageView; | 7 | import android.widget.ImageView; |
8 | import android.widget.RadioButton; | 8 | import android.widget.RadioButton; |
9 | import android.widget.Toast; | 9 | import android.widget.Toast; |
10 | 10 | ||
11 | import androidx.annotation.NonNull; | 11 | import androidx.annotation.NonNull; |
12 | import androidx.annotation.Nullable; | 12 | import androidx.annotation.Nullable; |
13 | 13 | ||
14 | import com.bumptech.glide.Glide; | 14 | import com.bumptech.glide.Glide; |
15 | import com.chad.library.adapter.base.BaseQuickAdapter; | 15 | import com.chad.library.adapter.base.BaseQuickAdapter; |
16 | import com.chad.library.adapter.base.BaseViewHolder; | 16 | import com.chad.library.adapter.base.BaseViewHolder; |
17 | import com.google.android.flexbox.FlexboxLayoutManager; | 17 | import com.google.android.flexbox.FlexboxLayoutManager; |
18 | import com.google.gson.Gson; | 18 | import com.google.gson.Gson; |
19 | import com.hjx.parent.databinding.ActivityHomeworkFeedbackBinding; | 19 | import com.hjx.parent.databinding.ActivityHomeworkFeedbackBinding; |
20 | import com.hjx.parent.rx.BaseRxActivity; | 20 | import com.hjx.parent.rx.BaseRxActivity; |
21 | import com.prws.common.bean.Student; | 21 | import com.prws.common.bean.Student; |
22 | import com.prws.common.bean.homework.Correction; | 22 | import com.prws.common.bean.homework.Correction; |
23 | import com.prws.common.bean.homework.CorrectionPoint; | 23 | import com.prws.common.bean.homework.CorrectionPoint; |
24 | import com.prws.common.bean.homework.CorrectionSer; | ||
24 | import com.prws.common.bean.homework.HomeWork; | 25 | import com.prws.common.bean.homework.HomeWork; |
25 | import com.prws.common.bean.homework.HomeworkList; | 26 | import com.prws.common.bean.homework.HomeworkList; |
26 | import com.prws.common.bean.homework.KeyValue; | 27 | import com.prws.common.bean.homework.KeyValue; |
27 | import com.prws.common.net.NetWorks; | 28 | import com.prws.common.net.NetWorks; |
28 | 29 | ||
29 | import java.text.DecimalFormat; | 30 | import java.text.DecimalFormat; |
30 | import java.text.SimpleDateFormat; | 31 | import java.text.SimpleDateFormat; |
31 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
32 | import java.util.HashMap; | 33 | import java.util.HashMap; |
33 | import java.util.HashSet; | 34 | import java.util.HashSet; |
34 | import java.util.List; | 35 | import java.util.List; |
35 | import java.util.Locale; | 36 | import java.util.Locale; |
36 | import java.util.Map; | 37 | import java.util.Map; |
37 | import java.util.Set; | 38 | import java.util.Set; |
38 | 39 | ||
39 | public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFeedbackBinding> { | 40 | public class HomeworkFeedbackActivity extends BaseRxActivity<ActivityHomeworkFeedbackBinding> { |
40 | private Student student; | 41 | private Student student; |
41 | private HomeworkList mData; | 42 | private HomeworkList mData; |
42 | private ArrayList<HomeWork> mList; | 43 | private ArrayList<HomeWork> mList; |
43 | private List<Correction> corrections = new ArrayList<>(); | 44 | private List<Correction> corrections = new ArrayList<>(); |
44 | 45 | ||
45 | @SuppressWarnings("unchecked") | 46 | @SuppressWarnings("unchecked") |
46 | @Override | 47 | @Override |
47 | public void initView(Bundle savedInstanceState) { | 48 | public void initView(Bundle savedInstanceState) { |
48 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); | 49 | binding.toolbar.setNavigationOnClickListener(v -> onBackPressed()); |
49 | student = (Student) getIntent().getSerializableExtra("student"); | 50 | student = (Student) getIntent().getSerializableExtra("student"); |
50 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); | 51 | mData = (HomeworkList) getIntent().getSerializableExtra("data"); |
51 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); | 52 | mList = (ArrayList<HomeWork>) getIntent().getSerializableExtra("list"); |
52 | 53 | ||
53 | binding.tvStuName.setText(student.stuName); | 54 | binding.tvStuName.setText(student.stuName); |
54 | binding.tvGrade.setText(student.grade); | 55 | binding.tvGrade.setText(student.grade); |
55 | 56 | ||
56 | List<HomeWork> errorList = new ArrayList<>(); | 57 | List<HomeWork> errorList = new ArrayList<>(); |
57 | int correctNo = 0; | 58 | int correctNo = 0; |
58 | for (HomeWork homeWork: mList) { | 59 | for (HomeWork homeWork: mList) { |
59 | homeWork.state = 1; | 60 | homeWork.state = 1; |
60 | homeWork.index = mList.indexOf(homeWork); | 61 | homeWork.index = mList.indexOf(homeWork); |
61 | corrections.add(new Correction(homeWork.brief, homeWork.check ? 1 : 0)); | 62 | corrections.add(new Correction(homeWork.brief, homeWork.check ? 1 : 0)); |
62 | if (!homeWork.check) correctNo ++; | 63 | if (!homeWork.check) correctNo ++; |
63 | else errorList.add(homeWork); | 64 | else errorList.add(homeWork); |
64 | } | 65 | } |
65 | binding.tvPercent.setText(new DecimalFormat("0%").format(1f * correctNo / mList.size())); | 66 | binding.tvPercent.setText(new DecimalFormat("0%").format(1f * correctNo / mList.size())); |
66 | 67 | ||
67 | binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); | 68 | binding.rvCorrect.setLayoutManager(new FlexboxLayoutManager(this)); |
68 | NumberAdapter numberAdapter = new NumberAdapter(mList); | 69 | NumberAdapter numberAdapter = new NumberAdapter(mList); |
69 | binding.rvCorrect.setAdapter(numberAdapter); | 70 | binding.rvCorrect.setAdapter(numberAdapter); |
70 | binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); | 71 | binding.rvError.setVisibility(errorList.isEmpty() ? View.GONE : View.VISIBLE); |
71 | binding.rvError.setAdapter(new EvalAdapter(errorList)); | 72 | binding.rvError.setAdapter(new EvalAdapter(errorList)); |
72 | if (errorList.isEmpty()) { | 73 | if (errorList.isEmpty()) { |
73 | binding.flEval.setVisibility(View.GONE); | 74 | binding.flEval.setVisibility(View.GONE); |
74 | } | 75 | } |
75 | 76 | ||
76 | binding.btnDetail.setOnClickListener(v -> { | 77 | binding.btnDetail.setOnClickListener(v -> { |
77 | viewTopicDetail(0); | 78 | viewTopicDetail(0); |
78 | }); | 79 | }); |
79 | numberAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { | 80 | numberAdapter.setOnItemClickListener((baseQuickAdapter, view, i) -> { |
80 | viewTopicDetail(i); | 81 | viewTopicDetail(i); |
81 | }); | 82 | }); |
82 | binding.btnPublish.setOnClickListener(v -> submit()); | 83 | binding.btnPublish.setOnClickListener(v -> submit()); |
83 | } | 84 | } |
84 | 85 | ||
85 | private void viewTopicDetail(int position) { | 86 | private void viewTopicDetail(int position) { |
86 | Intent intent = new Intent(this, HomeworkTopicActivity.class); | 87 | Intent intent = new Intent(this, HomeworkTopicActivity.class); |
87 | intent.putExtra("list", mList); | 88 | intent.putExtra("list", mList); |
88 | intent.putExtra("position", position); | 89 | intent.putExtra("position", position); |
89 | startActivity(intent); | 90 | startActivity(intent); |
90 | } | 91 | } |
91 | 92 | ||
92 | @SuppressLint("CheckResult") | 93 | @SuppressLint("CheckResult") |
93 | private void submit() { | 94 | private void submit() { |
94 | Map<String, Object> body = new HashMap<>(); | 95 | Map<String, Object> body = new HashMap<>(); |
95 | body.put("homeworkId", mData.getId()); | 96 | body.put("homeworkId", mData.getId()); |
96 | body.put("comment", binding.etComment.getText().toString()); | 97 | body.put("comment", binding.etComment.getText().toString()); |
97 | body.put("stuId", student.stuId); | 98 | body.put("stuId", student.stuId); |
98 | body.put("points", countPoint()); | 99 | body.put("points", countPoint()); |
99 | body.put("correctionList", corrections); | 100 | body.put("correctionList", corrections); |
101 | body.put("extra", buildExtra()); | ||
100 | NetWorks.service_url.uploadHomeworkFeedback(NetWorks.getHeader(), body) | 102 | NetWorks.service_url.uploadHomeworkFeedback(NetWorks.getHeader(), body) |
101 | .compose(transformSingle()) | 103 | .compose(transformSingle()) |
102 | .subscribe((response, th) -> { | 104 | .subscribe((response, th) -> { |
103 | if (th != null) th.printStackTrace(); | 105 | if (th != null) th.printStackTrace(); |
104 | if (response != null && response.getSuccess()) { | 106 | if (response != null && response.getSuccess()) { |
105 | Toast.makeText(this, "反馈成功", Toast.LENGTH_SHORT).show(); | 107 | Toast.makeText(this, "反馈成功", Toast.LENGTH_SHORT).show(); |
106 | 108 | ||
107 | Intent intent = new Intent(this, HomeworkShareActivity.class); | 109 | Intent intent = new Intent(this, HomeworkShareActivity.class); |
108 | intent.putExtra("student", student); | 110 | intent.putExtra("student", student); |
109 | intent.putExtra("id", mData.getId()); | 111 | intent.putExtra("id", mData.getId()); |
110 | intent.putExtra("grade", mData.getGrade()); | 112 | intent.putExtra("grade", mData.getGrade()); |
111 | intent.putExtra("subject", mData.getSubject()); | 113 | intent.putExtra("subject", mData.getSubject()); |
112 | String name = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(mData.uploadTime); | 114 | String name = new SimpleDateFormat("yyyy年M月d日作业", Locale.CHINA).format(mData.uploadTime); |
113 | intent.putExtra("name", name); | 115 | intent.putExtra("name", name); |
114 | startActivity(intent); | 116 | startActivity(intent); |
115 | 117 | ||
116 | setResult(RESULT_OK); | 118 | setResult(RESULT_OK); |
117 | finish(); | 119 | finish(); |
118 | } else { | 120 | } else { |
119 | Toast.makeText(this, "反馈失败", Toast.LENGTH_SHORT).show(); | 121 | Toast.makeText(this, "反馈失败", Toast.LENGTH_SHORT).show(); |
120 | } | 122 | } |
121 | }); | 123 | }); |
122 | } | 124 | } |
123 | 125 | ||
126 | private String buildExtra() { | ||
127 | if (mList == null || mList.isEmpty()) return null; | ||
128 | List<CorrectionSer> maps = new ArrayList<>(); | ||
129 | for (HomeWork item: mList) { | ||
130 | maps.add(item.toSer()); | ||
131 | } | ||
132 | Gson gson = new Gson(); | ||
133 | return gson.toJson(maps); | ||
134 | } | ||
135 | |||
124 | @SuppressLint("CheckResult") | 136 | @SuppressLint("CheckResult") |
125 | private List<CorrectionPoint> countPoint() { | 137 | private List<CorrectionPoint> countPoint() { |
126 | Set<KeyValue> set = new HashSet<>(); | 138 | Set<KeyValue> set = new HashSet<>(); |
127 | Map<String, Integer> totalTimes = new HashMap<>(); | 139 | Map<String, Integer> totalTimes = new HashMap<>(); |
128 | Map<String, Integer> correctTimes = new HashMap<>(); | 140 | Map<String, Integer> correctTimes = new HashMap<>(); |
129 | Map<String, Integer> underTimes = new HashMap<>(); | 141 | Map<String, Integer> underTimes = new HashMap<>(); |
130 | Map<String, Integer> baseTimes = new HashMap<>(); | 142 | Map<String, Integer> baseTimes = new HashMap<>(); |
131 | Map<String, Integer> normalTimes = new HashMap<>(); | 143 | Map<String, Integer> normalTimes = new HashMap<>(); |
132 | Gson gson = new Gson(); | 144 | Gson gson = new Gson(); |
133 | for (HomeWork homeWork: mList) { | 145 | for (HomeWork homeWork: mList) { |
134 | homeWork.formatPoints(gson); | 146 | homeWork.formatPoints(gson); |
135 | 147 | ||
136 | set.addAll(homeWork.pointsObj); | 148 | set.addAll(homeWork.pointsObj); |
137 | for (KeyValue keyValue: homeWork.pointsObj) { | 149 | for (KeyValue keyValue: homeWork.pointsObj) { |
138 | String key = keyValue.Key; | 150 | String key = keyValue.Key; |
139 | if (totalTimes.containsKey(key)) { | 151 | if (totalTimes.containsKey(key)) { |
140 | totalTimes.put(key, totalTimes.get(key) + 1); | 152 | totalTimes.put(key, totalTimes.get(key) + 1); |
141 | } else { | 153 | } else { |
142 | totalTimes.put(key, 1); | 154 | totalTimes.put(key, 1); |
143 | } | 155 | } |
144 | if (!homeWork.check) { | 156 | if (!homeWork.check) { |
145 | if (correctTimes.containsKey(key)) { | 157 | if (correctTimes.containsKey(key)) { |
146 | correctTimes.put(key, correctTimes.get(key) + 1); | 158 | correctTimes.put(key, correctTimes.get(key) + 1); |
147 | } else { | 159 | } else { |
148 | correctTimes.put(key, 1); | 160 | correctTimes.put(key, 1); |
149 | } | 161 | } |
150 | } else if (homeWork.state == 1) { | 162 | } else if (homeWork.state == 1) { |
151 | if (underTimes.containsKey(key)) { | 163 | if (underTimes.containsKey(key)) { |
152 | underTimes.put(key, underTimes.get(key) + 1); | 164 | underTimes.put(key, underTimes.get(key) + 1); |
153 | } else { | 165 | } else { |
154 | underTimes.put(key, 1); | 166 | underTimes.put(key, 1); |
155 | } | 167 | } |
156 | } else if (homeWork.state == 2) { | 168 | } else if (homeWork.state == 2) { |
157 | if (baseTimes.containsKey(key)) { | 169 | if (baseTimes.containsKey(key)) { |
158 | baseTimes.put(key, baseTimes.get(key) + 1); | 170 | baseTimes.put(key, baseTimes.get(key) + 1); |
159 | } else { | 171 | } else { |
160 | baseTimes.put(key, 1); | 172 | baseTimes.put(key, 1); |
161 | } | 173 | } |
162 | } else if (homeWork.state == 3) { | 174 | } else if (homeWork.state == 3) { |
163 | if (normalTimes.containsKey(key)) { | 175 | if (normalTimes.containsKey(key)) { |
164 | normalTimes.put(key, normalTimes.get(key) + 1); | 176 | normalTimes.put(key, normalTimes.get(key) + 1); |
165 | } else { | 177 | } else { |
166 | normalTimes.put(key, 1); | 178 | normalTimes.put(key, 1); |
167 | } | 179 | } |
168 | } | 180 | } |
169 | } | 181 | } |
170 | } | 182 | } |
171 | List<CorrectionPoint> points = new ArrayList<>(); | 183 | List<CorrectionPoint> points = new ArrayList<>(); |
172 | for (KeyValue obj: set) { | 184 | for (KeyValue obj: set) { |
173 | CorrectionPoint point = new CorrectionPoint(); | 185 | CorrectionPoint point = new CorrectionPoint(); |
174 | point.pointId = obj.Key; | 186 | point.pointId = obj.Key; |
175 | point.pointName = obj.Value; | 187 | point.pointName = obj.Value; |
176 | point.totalCount = ifNull(totalTimes.get(obj.Key), 1); | 188 | point.totalCount = ifNull(totalTimes.get(obj.Key), 1); |
177 | point.correctCount = ifNull(correctTimes.get(obj.Key), 0); | 189 | point.correctCount = ifNull(correctTimes.get(obj.Key), 0); |
178 | point.understandCount = ifNull(underTimes.get(obj.Key), 0); | 190 | point.understandCount = ifNull(underTimes.get(obj.Key), 0); |
179 | point.basicCount = ifNull(baseTimes.get(obj.Key), 0); | 191 | point.basicCount = ifNull(baseTimes.get(obj.Key), 0); |
180 | point.normalCount = ifNull(normalTimes.get(obj.Key), 0); | 192 | point.normalCount = ifNull(normalTimes.get(obj.Key), 0); |
181 | 193 | ||
182 | points.add(point); | 194 | points.add(point); |
183 | } | 195 | } |
184 | 196 | ||
185 | return points; | 197 | return points; |
186 | } | 198 | } |
187 | 199 | ||
188 | private int ifNull(Integer src, int defaultVal) { | 200 | private int ifNull(Integer src, int defaultVal) { |
189 | if (src == null) return defaultVal; | 201 | if (src == null) return defaultVal; |
190 | else return src; | 202 | else return src; |
191 | } | 203 | } |
192 | 204 | ||
193 | 205 | ||
194 | @Override | 206 | @Override |
195 | protected ActivityHomeworkFeedbackBinding getViewBinding() { | 207 | protected ActivityHomeworkFeedbackBinding getViewBinding() { |
196 | return ActivityHomeworkFeedbackBinding.inflate(getLayoutInflater()); | 208 | return ActivityHomeworkFeedbackBinding.inflate(getLayoutInflater()); |
197 | } | 209 | } |
198 | 210 | ||
199 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 211 | static class NumberAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
200 | 212 | ||
201 | public NumberAdapter(List<HomeWork> list) { | 213 | public NumberAdapter(List<HomeWork> list) { |
202 | super(R.layout.item_feedback_num, list); | 214 | super(R.layout.item_feedback_num, list); |
203 | } | 215 | } |
204 | 216 | ||
205 | @Override | 217 | @Override |
206 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 218 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
207 | int position = getData().indexOf(homeWork); | 219 | int position = getData().indexOf(homeWork); |
208 | holder.setText(R.id.tvNum, String.valueOf(position + 1)); | 220 | holder.setText(R.id.tvNum, String.valueOf(position + 1)); |
209 | if (homeWork.check) { | 221 | if (homeWork.check) { |
210 | holder.setImageResource(R.id.ivType, R.drawable.ic_wrong_small); | 222 | holder.setImageResource(R.id.ivType, R.drawable.ic_wrong_small); |
211 | } else { | 223 | } else { |
212 | holder.setImageResource(R.id.ivType, R.drawable.ic_correct_small); | 224 | holder.setImageResource(R.id.ivType, R.drawable.ic_correct_small); |
213 | } | 225 | } |
214 | } | 226 | } |
215 | } | 227 | } |
216 | 228 | ||
217 | static class EvalAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { | 229 | static class EvalAdapter extends BaseQuickAdapter<HomeWork, BaseViewHolder> { |
218 | 230 | ||
219 | public EvalAdapter(@Nullable List<HomeWork> data) { | 231 | public EvalAdapter(@Nullable List<HomeWork> data) { |
220 | super(R.layout.item_homework_eval, data); | 232 | super(R.layout.item_homework_eval, data); |
221 | } | 233 | } |
222 | 234 | ||
223 | @Override | 235 | @Override |
224 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { | 236 | protected void convert(@NonNull BaseViewHolder holder, HomeWork homeWork) { |
225 | holder.itemView.setClipToOutline(true); | 237 | holder.itemView.setClipToOutline(true); |
226 | holder.setText(R.id.tvNo, "题目" + (homeWork.index + 1)); | 238 | holder.setText(R.id.tvNo, "题目" + (homeWork.index + 1)); |
227 | ImageView iv = holder.getView(R.id.ivTopic); | 239 | ImageView iv = holder.getView(R.id.ivTopic); |
228 | Glide.with(mContext).load(homeWork.url).into(iv); | 240 | Glide.with(mContext).load(homeWork.url).into(iv); |
229 | 241 | ||
230 | RadioButton chk1 = holder.getView(R.id.chk1); | 242 | RadioButton chk1 = holder.getView(R.id.chk1); |
231 | RadioButton chk2 = holder.getView(R.id.chk2); | 243 | RadioButton chk2 = holder.getView(R.id.chk2); |
232 | RadioButton chk3 = holder.getView(R.id.chk3); | 244 | RadioButton chk3 = holder.getView(R.id.chk3); |
233 | chk1.setOnCheckedChangeListener((v, b) -> { | 245 | chk1.setOnCheckedChangeListener((v, b) -> { |
234 | if (b) { | 246 | if (b) { |
235 | homeWork.state = 1; | 247 | homeWork.state = 1; |
236 | } | 248 | } |
237 | }); | 249 | }); |
238 | chk2.setOnCheckedChangeListener((v, b) -> { | 250 | chk2.setOnCheckedChangeListener((v, b) -> { |
239 | if (b) { | 251 | if (b) { |
240 | homeWork.state = 2; | 252 | homeWork.state = 2; |
241 | } | 253 | } |
242 | }); | 254 | }); |
243 | chk3.setOnCheckedChangeListener((v, b) -> { | 255 | chk3.setOnCheckedChangeListener((v, b) -> { |
244 | if (b) { | 256 | if (b) { |
245 | homeWork.state = 3; | 257 | homeWork.state = 3; |
246 | } | 258 | } |
247 | }); | 259 | }); |
248 | chk1.setChecked(homeWork.state == 1); | 260 | chk1.setChecked(homeWork.state == 1); |
249 | chk2.setChecked(homeWork.state == 2); | 261 | chk2.setChecked(homeWork.state == 2); |
250 | chk3.setChecked(homeWork.state == 3); | 262 | chk3.setChecked(homeWork.state == 3); |
251 | } | 263 | } |
252 | } | 264 | } |
253 | } | 265 | } |
254 | 266 |
libs/common/src/main/java/com/prws/common/bean/homework/CorrectionSer.java
File was created | 1 | package com.prws.common.bean.homework; | |
2 | |||
3 | public class CorrectionSer { | ||
4 | public String brief; | ||
5 | public int correction; // 0 对, 1 错 | ||
6 | public int state; // 1: 已听懂; 2: 基本听懂; 3: 一般听懂 | ||
7 | |||
8 | public CorrectionSer() { | ||
9 | } | ||
10 | |||
11 | public CorrectionSer(String brief, int correction, int state) { | ||
12 | this.brief = brief; | ||
13 | this.correction = correction; | ||
14 | this.state = state; | ||
15 | } | ||
16 | } | ||
17 |
libs/common/src/main/java/com/prws/common/bean/homework/HomeWork.java
1 | package com.prws.common.bean.homework; | 1 | package com.prws.common.bean.homework; |
2 | 2 | ||
3 | import com.google.gson.Gson; | 3 | import com.google.gson.Gson; |
4 | import com.google.gson.annotations.SerializedName; | 4 | import com.google.gson.annotations.SerializedName; |
5 | import com.google.gson.reflect.TypeToken; | 5 | import com.google.gson.reflect.TypeToken; |
6 | 6 | ||
7 | import java.io.Serializable; | 7 | import java.io.Serializable; |
8 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
9 | import java.util.List; | 9 | import java.util.List; |
10 | 10 | ||
11 | public class HomeWork implements Serializable { | 11 | public class HomeWork implements Serializable { |
12 | 12 | ||
13 | @SerializedName(value = "homeworkId", alternate = "id") | 13 | @SerializedName(value = "homeworkId", alternate = "id") |
14 | public String homeworkId; | 14 | public String homeworkId; |
15 | public String brief; | 15 | public String brief; |
16 | public String url; | 16 | public String url; |
17 | public String analyseUrl; | 17 | public String analyseUrl; |
18 | public String analyseVideoUrl; | 18 | public String analyseVideoUrl; |
19 | public Integer correction; | 19 | public Integer correction; |
20 | public String answer; | 20 | public String answer; |
21 | public String points; | 21 | public String points; |
22 | 22 | ||
23 | public boolean check = false; //选中为错题 | 23 | public boolean check = false; //选中为错题 |
24 | public transient int index = 0; | 24 | public transient int index = 0; |
25 | public transient int state = 1; | 25 | public transient int state = 1; |
26 | 26 | ||
27 | public transient List<KeyValue> pointsObj; | 27 | public transient List<KeyValue> pointsObj; |
28 | public void formatPoints(Gson gson) { | 28 | public void formatPoints(Gson gson) { |
29 | if (points == null) { | 29 | if (points == null) { |
30 | pointsObj = new ArrayList<>(); | 30 | pointsObj = new ArrayList<>(); |
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | try { | 33 | try { |
34 | pointsObj = gson.fromJson(points, new TypeToken<List<KeyValue>>(){}.getType()); | 34 | pointsObj = gson.fromJson(points, new TypeToken<List<KeyValue>>(){}.getType()); |
35 | } catch (Exception e) { | 35 | } catch (Exception e) { |
36 | e.printStackTrace(); | 36 | e.printStackTrace(); |
37 | pointsObj = new ArrayList<>(); | 37 | pointsObj = new ArrayList<>(); |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | public CorrectionSer toSer() { | ||
42 | return new CorrectionSer(brief, check ? 1 : 0, state); | ||
43 | } | ||
41 | } | 44 | } |
42 | 45 |