Skip to content

Commit

Permalink
Fix populate script
Browse files Browse the repository at this point in the history
edx changed the behaviour of auto_auth:
- duplicate username will cause error
- response is in json format instead of text
  • Loading branch information
kitsook committed Jul 6, 2018
1 parent ff69bbb commit 57b01b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion scripts/populate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ var config = require('./populate.json');

api.baseUrls = config.baseUrls;

var timestamp = new Date();
var timestamp_str = timestamp.getFullYear() + ("0" + (timestamp.getMonth() + 1)).slice(-2) + ("0" + timestamp.getDate()).slice(-2) + ("0" + timestamp.getHours()).slice(-2) + ("0" + timestamp.getMinutes()).slice(-2) + ("0" + timestamp.getSeconds()).slice(-2);

async.timesSeries(config.answers.length, function(i, next) {
async.timesSeries(config.xblock_keys.length, function(j, nextx) {
async.series([
function (cb) {
api.createUserOrLogin('pitestuser'+i, 'lms', config.course_key, cb);
api.createUserOrLogin('pitestuser_'+timestamp_str+'_'+i, 'lms', config.course_key, cb);
},
function (cb) {
api.piSubmitAnswer(config.course_key, config.xblock_prefix + config.xblock_keys[j], {
Expand Down
12 changes: 6 additions & 6 deletions ubcpi/static/js/features/support/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ Api.prototype.createUserOrLogin = function (username, target, course_id, callbac
});

// parse the response
var userInfo = body.match(/Logged in user (.+) \((.+)\) with password (.+) and user_id (.+)/);
var userInfo = JSON.parse(body)
self.users[target] = {
username: userInfo[1],
email: userInfo[2],
password: userInfo[3],
id: userInfo[4]
username: userInfo['username'],
email: userInfo['email'],
password: userInfo['password'],
id: userInfo['user_id']
};
//console.log(target + ': ' + body);
// console.log(self.users[target])
callback(null, self.users[target]);
}
);
Expand Down

0 comments on commit 57b01b4

Please sign in to comment.