sendAward method
dynamic
sendAward(
- String userId
)
Implementation
sendAward(String userId) async {
final taskId = "trophy";
final trophyList = _taskController.getTaskByTaskId(taskId);
if (trophyList.isEmpty) {}
var content = "";
if (trophyList.isEmpty) {
content = jsonEncode([
{"userId": userId, "count": 1},
]);
} else {
final contentList = jsonDecode(trophyList.first.content);
final userTrophy = contentList.firstWhere(
(element) => element["userId"] == userId,
);
userTrophy["count"] = userTrophy["count"] + 1;
content = jsonEncode(contentList);
}
TCICLog.info(
"sendAward: $content",
actionModule: ActionModule.tcicController.name,
actionName: ActionName.sendAward.name,
);
await _taskController.updateTask(
UpdateTaskParams(
classId: int.parse(_config.classId),
taskId: taskId,
content: content,
),
);
}