Exemplo n.º 1
0
 def createSet(self):
     global flashcard_set
     flashcard_set = classes.Set(db_x.get_id(mail), self.description.text)
     # print(flashcard_set.ID)
     # print(flashcard_set.Flashcards)
     self.reset()
     sm.current = "createFlashcard"
 def get_set(self, set_id):
     result_cards = []
     if self.db["cardssets"].count_documents({"_id": ObjectId(set_id)}) == 0:
         return -1
     cards_set = self.db["cardssets"].find({"_id": ObjectId(set_id)})
     for card_id in cards_set["cards"]:
         card = self.db["flashcards"].findOne({"_id": ObjectId(card_id)})
         result_cards.append(classes.Flashcard(card["Question"], card["Answer"], card["Set"], card["User"]))
     return classes.Set(cards_set["Creator"], result_cards, set_id)
    def all_sets(self):
        result_sets = {}
        for cards_set in self.db["cardssets"].find({"Description": {"$exists": "true"}}):
            cur_set = classes.Set(cards_set["Creator"], cards_set["Description"], cards_set["_id"])
            for cardID in cards_set["cards"]:
                card = self.db["flashcards"].find_one({"_id": cardID})
                cur_set.addFlashcard(classes.Flashcard(card["Question"],
                                                       card["Answer"],
                                                       card["User"],
                                                       cards_set["_id"],
                                                       cardID))
            result_sets.update({cur_set.ID: cur_set})
            del cur_set

        return result_sets
Exemplo n.º 4
0
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, WipeTransition

import DBConnection, classes
# from flashcards_test.main import *

Builder.load_file("main.kv")
Builder.load_file("learningWindows.kv")
sm = ScreenManager()
sm.transition = WipeTransition(clearcolor=(1, 1, 1, 1))

mail = ""
flashcard_set = classes.Set("1", "a")
current_sets = {}

db_x = DBConnection.DBConnection()