Esempio n. 1
0
// Enables all words of type word_type for user user_id
func EnableUsersWordType(user_id int, type_id string) {
	sql := `
        REPLACE INTO users_types (user_id, type_id, enabled)
        VALUES (` + strconv.Itoa(user_id) + `, ` + type_id + `, 1)
    `
	data.ExecuteQuery(sql)
}
Esempio n. 2
0
// Disables all words of type word_type for user user_id
func DisableUsersWordType(user_id int, type_id string) {
	sql := `
        UPDATE users_types ut
        SET ut.enabled = 0
        WHERE user_id = ` + strconv.Itoa(user_id) + ` AND ut.type_id = '` + type_id + `'
    `
	data.ExecuteQuery(sql)
}
Esempio n. 3
0
// Sets all enabled users_words to level 0 for user_id
func ResetUsersVocabulary(user_id int) {
	sql := `
        UPDATE users_words uw
        INNER JOIN words_types wt ON wt.word_id = uw.word_id
        INNER JOIN users_types ut ON ut.type_id = wt.type_id AND ut.user_id = uw.user_id
        SET uw.level = 0
        WHERE ut.enabled = 1 AND uw.user_id = ` + strconv.Itoa(user_id)
	data.ExecuteQuery(sql)
}
Esempio n. 4
0
func UpdateUsersWord(user_id int, word_id string, level string) {
	sql := `UPDATE users_words SET level = ` + level + ` WHERE user_id = ` + strconv.Itoa(user_id) + ` AND word_id = ` + word_id
	data.ExecuteQuery(sql)
}
Esempio n. 5
0
// Enables all word_ids for user_id
func EnableUsersVocabulary(user_id int, word_ids string) {
	sql := `UPDATE users_words SET enabled = 1 WHERE user_id = ` + strconv.Itoa(user_id) + ` AND word_id IN (` + word_ids + `)`
	data.ExecuteQuery(sql)
}
Esempio n. 6
0
// Sets all users_words to disabled for user_id
func DisableUsersVocabulary(user_id int) {
	sql := `UPDATE users_words SET enabled = 0 WHERE user_id = ` + strconv.Itoa(user_id)
	data.ExecuteQuery(sql)
}