提交 c824fe23 编写于 作者: C CodFrm

提交新题目增加打码次数

上级 9807dfe1
module.exports = {
url: "https://cx.icodef.com/",
version: 2.11,
version: 2.10,
update: 'https://github.com/CodFrm/cxmooc-tools/releases',
enforce: false,
cx: {
......@@ -9,7 +9,7 @@ module.exports = {
},
injection: '',
hotversion: {
v2_10: 2.101,
v2_10: 2.100,
v2_08: 2.083,
v2_07: 2.071,
v2_06: 2.06,
......
......@@ -45,7 +45,7 @@ app.use(bodyParser.urlencoded({
}));
app.use(express.static(path.join(__dirname, 'static'), {
maxage: '7d'
maxage: '1d'
}));
app.get('/', function (req, res) {
......@@ -89,6 +89,7 @@ app.post('/answer', function (req, res) {
});
}
let num = 0;
let addTokenNum = 0;
for (let i in req.body) {
let topic = req.body[i];
if (topic.correct == undefined || topic.type == undefined || topic.topic == undefined ||
......@@ -113,6 +114,8 @@ app.post('/answer', function (req, res) {
data.platform = platform;
data.token = token;
mooc.insert('answer', data);
//增加token次数
addTokenNum += 10;
} else if ((type == 4 && result.type == 4) || (type == 2 && result.type == 2)) {
//填空多选,答案合并
try {
......@@ -128,10 +131,15 @@ app.post('/answer', function (req, res) {
}
ret.push(cond);
if (ret.length == num) {
res.send({
code: 0,
msg: 'success',
result: ret
redis.getTokenNum(token, function (num) {
redis.setToken(token, num + addTokenNum)
res.send({
code: 0,
msg: 'success',
result: ret,
token_num: num + addTokenNum,
add_token_num: addTokenNum
});
});
}
});
......@@ -188,7 +196,7 @@ app.post('/v2/answer', function (req, res) {
if (type[i] != undefined) {
where = { type: parseInt(type[i]) };
}
where.topic = { $regex: '^'+topic_n };
where.topic = { $regex: '^' + topic_n };
return where;
});
});
......
......@@ -29,6 +29,7 @@ module.exports = function () {
});
});
}
this.vtoken = function (token, callback) {
if (!token) {
return callback && callback(0);
......@@ -37,6 +38,20 @@ module.exports = function () {
callback && callback(res);
});
}
this.getTokenNum = function (token, callback) {
if (!token) {
return callback && callback(0);
}
client.get('cxmooc:vtoken:' + token, function (err, res) {
callback && callback(res)
});
}
this.setToken = function (token, num) {
client.set('cxmooc:vtoken:' + token, num);
}
this.set = function (key, value) {
client.set(key, value);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册