コード例 #1
0
 def insertQuestion(self, courseId, question):
     db = dbc()
     query = "INSERT INTO questions (course_id, question) VALUES ({0}, '{1}')"
     query = query.format(courseId, question)
     db.execute(query)
     questionId = db.getLastId()
     return questionId
コード例 #2
0
    def getUserCourses(self, userId):
        db = dbc()
        query = "SELECT title, type, date_log FROM courses_taken as A JOIN courses as B ON A.course_id = B.course_id WHERE user_id={0} ORDER BY date_log DESC".format(
            userId)
        courses = db.resultDict(query)

        return courses
コード例 #3
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def insertQuestion(self, courseId, question):
     db = dbc()
     query = "INSERT INTO questions (course_id, question) VALUES ({0}, '{1}')"
     query = query.format(courseId, question)
     db.execute(query)
     questionId = db.getLastId()
     return questionId
コード例 #4
0
 def insertCourse(self, userId, title, type):
     db = dbc()
     query = "INSERT INTO courses (author_id, title, type, date) VALUES ({0}, '{1}', '{2}', NOW())".format(
         userId, title, type)
     db.execute(query)
     id = db.getLastId()
     return id
コード例 #5
0
 def getNewestCourse(self):
     db = dbc()
     newestCourseQuery = "SELECT * FROM courses ORDER BY date DESC LIMIT 1"
     result = db.resultDict(newestCourseQuery)
     if result:
         return result[0]
     return False
コード例 #6
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def getNewestCourse(self):
     db = dbc()
     newestCourseQuery = "SELECT * FROM courses ORDER BY date DESC LIMIT 1"
     result = db.resultDict(newestCourseQuery)
     if result:
         return result[0]
     return False
コード例 #7
0
    def getUserData(self, userId):
        db = dbc()
        query = "SELECT email, username FROM users WHERE user_id={0}".format(
            userId)
        userData = db.resultDict(query)

        return userData
コード例 #8
0
ファイル: UserRepository.py プロジェクト: Morrghana/teachMe
    def checkUser(self, name, email):
        db = dbc()

        selectQuery = "SELECT username, email FROM users WHERE username='******' OR email='{1}'".format(
            name, email)
        result = dict(db.resultTuple(selectQuery))
        usersCount = len(result)
        return usersCount
コード例 #9
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def insertDescription(self, courseId, description):
     db = dbc()
     query = "UPDATE courses SET description='{0}' WHERE course_id='{1}'".format(description, courseId)
     db.execute(query)
コード例 #10
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def insertCourse(self, userId, title, type):
     db = dbc()
     query = "INSERT INTO courses (author_id, title, type, date) VALUES ({0}, '{1}', '{2}', NOW())".format(userId, title, type)
     db.execute(query)
     id = db.getLastId()
     return id
コード例 #11
0
 def insertDescription(self, courseId, description):
     db = dbc()
     query = "UPDATE courses SET description='{0}' WHERE course_id='{1}'".format(
         description, courseId)
     db.execute(query)
コード例 #12
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def getCourseTypes(self):
     db = dbc()
     query = "SELECT type FROM course_types"
     types = db.resultDict(query)
     return types
コード例 #13
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
    def getUserData(self, userId):
        db = dbc()
        query = "SELECT email, username FROM users WHERE user_id={0}".format(userId)
        userData = db.resultDict(query)

        return userData
コード例 #14
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def getAnswers(self, questionId):
     db = dbc()
     answersQuery = "SELECT answer_id, answer, correct FROM answers WHERE question_id={0}".format(questionId)
     answers = db.resultDict(answersQuery)
     return answers
コード例 #15
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def insertAnswer(self, questionId, answer, correct):
     db = dbc()
     answQuery = "INSERT INTO answers (question_id, answer, correct) VALUES({0}, '{1}', {2})"
     answQuery = answQuery.format(questionId, answer, correct)
     db.execute(answQuery)
コード例 #16
0
 def courseTaken(self, userId, courseId):
     db = dbc()
     query = "INSERT INTO courses_taken (user_id, course_id, date_log) VALUES({0}, {1}, NOW()) ".format(
         userId, courseId)
     db.execute(query)
コード例 #17
0
 def getAnswers(self, questionId):
     db = dbc()
     answersQuery = "SELECT answer_id, answer, correct FROM answers WHERE question_id={0}".format(
         questionId)
     answers = db.resultDict(answersQuery)
     return answers
コード例 #18
0
 def getQuestions(self, courseId):
     db = dbc()
     questionsQuery = "SELECT question_id, question FROM questions WHERE course_id={0}".format(
         courseId)
     questions = db.resultDict(questionsQuery)
     return questions
コード例 #19
0
 def insertAnswer(self, questionId, answer, correct):
     db = dbc()
     answQuery = "INSERT INTO answers (question_id, answer, correct) VALUES({0}, '{1}', {2})"
     answQuery = answQuery.format(questionId, answer, correct)
     db.execute(answQuery)
コード例 #20
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def getQuestions(self, courseId):
     db = dbc()
     questionsQuery = "SELECT question_id, question FROM questions WHERE course_id={0}".format(courseId)
     questions = db.resultDict(questionsQuery)
     return questions
コード例 #21
0
 def getCourseTypes(self):
     db = dbc()
     query = "SELECT type FROM course_types"
     types = db.resultDict(query)
     return types
コード例 #22
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def courseTaken(self, userId, courseId):
     db = dbc()
     query = "INSERT INTO courses_taken (user_id, course_id, date_log) VALUES({0}, {1}, NOW()) ".format(userId, courseId)
     db.execute(query)
コード例 #23
0
 def searchCourses(self, courseType):
     db = dbc()
     query = "SELECT course_id, title FROM courses WHERE type='{0}'".format(
         courseType)
     courses = db.resultDict(query)
     return courses
コード例 #24
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
    def getUserCourses(self, userId):
        db = dbc()
        query = "SELECT title, type, date_log FROM courses_taken as A JOIN courses as B ON A.course_id = B.course_id WHERE user_id={0} ORDER BY date_log DESC".format(userId)
        courses = db.resultDict(query)

        return courses
コード例 #25
0
 def getDescription(self, courseId):
     db = dbc()
     query = "SELECT description FROM courses WHERE course_id={0}".format(
         courseId)
     descr = db.resultDict(query)
     return descr
コード例 #26
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def searchCourses(self, courseType):
     db = dbc()
     query = "SELECT course_id, title FROM courses WHERE type='{0}'".format(courseType)
     courses = db.resultDict(query)
     return courses
コード例 #27
0
ファイル: UserRepository.py プロジェクト: Morrghana/teachMe
 def createUser(self, name, email, password):
     db = dbc()
     query = "INSERT INTO users (username, email, password) VALUES('{0}', '{1}', '{2}')".format(
         name, email, password)
     db.execute(query)
コード例 #28
0
ファイル: CourseRepository.py プロジェクト: Morrghana/teachMe
 def getDescription(self, courseId):
     db = dbc()
     query = "SELECT description FROM courses WHERE course_id={0}".format(courseId)
     descr = db.resultDict(query)
     return descr
コード例 #29
0
ファイル: UserRepository.py プロジェクト: Morrghana/teachMe
 def getUserInfo(self, email, password):
     db = dbc()
     query = "SELECT user_id, role FROM users WHERE email = '{0}' AND password = '******'".format(
         email, password)
     result = db.resultDict(query)
     return result