Пример #1
0
 def test_retrieve_fc(self):
     sub = "math"
     que = "2+2"
     ans = "4"
     dbRoutine.create_fc(sub, que, ans)
     flashcards = dbRoutine.retrieve_fc(sub)
     self.assertEqual(1, flashcards.count())
Пример #2
0
 def test_link_card(self):    
     
     acc = "acc"
     pwd = "pwd"
     dbRoutine.create_account(acc, pwd)
     account = dbRoutine.retrieve_account(acc, pwd)
     dbRoutine.create_fc("biology", "q", "a")
Пример #3
0
 def test_retrieve_empty_fc(self):
     sub = "math"
     que = "que"
     ans = "ans"
     dbRoutine.create_fc(sub, que, ans);
     
     flashcards = dbRoutine.retrieve_fc("english");
     
     self.assertEqual(False, flashcards)
Пример #4
0
 def test_delete_subject(self):
     sub1 = "math"
     sub2 = "english"
     que = "question"
     ans = "answer"
     
     dbRoutine.create_fc(sub1, que, ans);
     dbRoutine.create_fc(sub2, que, ans);
     
     #dbRoutine.delete_sub("math")
     
     subjects = dbRoutine.retrieve_allSub();
Пример #5
0
 def test_link_session(self):
     
     acc = "acc"
     pwd = "pwd"
     dbRoutine.create_account(acc, pwd)
     account = dbRoutine.retrieve_account(acc, pwd)
     dbRoutine.create_fc("biology", "q", "a")
     session = dbRoutine.create_session("biology", 17)
     dbRoutine.link_session(account.getName(), session)
     sessions = account.getSessions()
     
     self.assertEqual(1, sessions.count())
Пример #6
0
    def test_create_flashcard(self):
        sub = "Test Subject"
        que = "Test Question"
        ans = "Test Answer"

        dbRoutine.create_fc(sub, que, ans)

        flashcards = dbRoutine.retrieve_fc("Test Subject")

        self.assertEqual(1, flashcards.count())

        # add another of the same subject
        sub = "Test Subject"
        que = "Test Question2"
        ans = "Test Answer2"

        dbRoutine.create_fc(sub, que, ans)

        flashcards = dbRoutine.retrieve_fc("Test Subject")

        self.assertEqual(2, flashcards.count())
Пример #7
0
 def test_empty_create_fc(self):
     sub = None
     que = None
     ans = None
     dbRoutine.create_fc(sub, que, ans);
     
     subjects = dbRoutine.retrieve_allSub();
     
     self.assertEqual(0, subjects.count());
     
     
     sub = None
     que = "question"
     ans = "answer"
     dbRoutine.create_fc(sub, que, ans);
     
     subjects = dbRoutine.retrieve_allSub();
     
     self.assertEqual(0, subjects.count());
     
     
     sub = "math"
     que = None
     ans = None
     dbRoutine.create_fc(sub, que, ans);
     
     subjects = dbRoutine.retrieve_allSub();
     
     self.assertEqual(0, subjects.count());
Пример #8
0
def new_card(request):
    
    json_dict = json.loads(request.body.decode('utf-8'))
    
    subject = json_dict['subject']
    question = json_dict['question']
    answer = json_dict['answer']
    
    subject.lower().title()
    card = dbRoutine.create_fc(subject, question, answer)

    current_user = request.user
    dbUser = dbRoutine.retrieve_account_no_password(current_user)
    dbRoutine.link_card(dbUser.getName(), card)
    dbRoutine.link_subject(dbUser.getName(), subject)
    
    return JsonResponse({'new_card':'success'})
Пример #9
0
def index(request):
    sub=""
    que=""
    ans=""
    form = CreateForm(request.POST or None)
    
    if form.is_valid():
        sub = form.cleaned_data['subject']
        que = form.cleaned_data['question']
        ans = form.cleaned_data['answer']
        
        sub.lower();
        card = dbRoutine.create_fc(sub, que, ans)
    
        current_user = request.user
        dbUser = dbRoutine.retrieve_account_no_password(current_user)
        dbRoutine.link_card(dbUser.getName(), card)
        dbRoutine.link_subject(dbUser.getName(), sub)
        
        cards = dbUser.getCards()
        
        print (cards.count())
    
        return HttpResponseRedirect('createMore/')
    #===========================================================================
    # allSubjects = Subject.objects.all();
    # 
    # subjectData = {
    #     "sub_detail" : allSubjects
    # }
    #===========================================================================
    
    if request.user.is_authenticated():
        current_user = request.user
        logged_in = 1
    else:
        current_user = request.user
        logged_in = 0
    
    context={
        "form": form,
        "current_user": current_user,
        "logged_in": logged_in
    }   
    
    return render(request, 'create.html', context)
Пример #10
0
 def test_retrieve_subjects(self):
     sub1 = "math"
     sub2 = "english"
     sub3 = "physics"
     que = "question"
     ans = "answer"
     
     dbRoutine.create_fc(sub1, que, ans);
     dbRoutine.create_fc(sub2, que, ans);
     dbRoutine.create_fc(sub3, que, ans);
     
     subjects = dbRoutine.retrieve_allSub();
     
     self.assertEqual(3, subjects.count());
Пример #11
0
    def test_create_multiple_flashcards(self):

        sub = "Test Subject"
        que = "Test Question"
        ans = "Test Answer"
        dbRoutine.create_fc(sub, que, ans)

        sub = "Test Subject2"
        dbRoutine.create_fc(sub, que, ans)

        sub = "Test Subject3"
        dbRoutine.create_fc(sub, que, ans)

        subjects = dbRoutine.retrieve_allSub()

        self.assertEqual(3, subjects.count())
Пример #12
0
 def test_retrieve_all_cards(self):
     
     sub1 = "sub1" 
     que1 = "que1" 
     ans1 = "ans1"  
     
     sub2 = "sub2" 
     que2 = "que2" 
     ans2 = "ans2"  
     
     sub3 = "sub3" 
     que3 = "que3" 
     ans3 = "ans3"  
     
     dbRoutine.create_fc(sub1, que1, ans1)
     dbRoutine.create_fc(sub2, que2, ans2)
     dbRoutine.create_fc(sub3, que3, ans3)
     
     cards = dbRoutine.retrieve_allCard()
     
     self.assertEqual(3, cards.count())
Пример #13
0
 def test_create_flashcard(self):
     sub = "math"
     que = "2+2"
     ans = "4"
     dbRoutine.create_fc(sub, que, ans);