コード例 #1
0
def prepare_average_grade_graph():
    #this function prepares data for this plot and calls function for api.py to make it | no arguments, no returns

    #prepare connection with Vulcan account
    with open("cert.json") as f:
        certificate = json.load(f)

    client = Vulcan(certificate)

    values = []
    dates = []
    components = []
    weights = []

    for grade in client.get_grades():

        if ((grade.weight == 0.0) or (grade.value == None)
                or (grade.value == 0.0)):
            continue
        else:
            components.append(grade.value * grade.weight)
            weights.append(grade.weight)
            values.append(round(sum(components) / sum(weights), 2))
            dates.append(str(grade.date.month) + "." + str(grade.date.day))

    average_grade_history_graph(dates, values)
コード例 #2
0
def fill_subjects_list():
    #this function uses grades list to fill "subjects" list with user's subjects name | no arguments, no returns

    with open("cert.json") as f:
        certificate = json.load(f)

    client = Vulcan(certificate)

    for grade in client.get_grades():
        if not grade.subject.short in subjects:
            subjects.append(grade.subject.short)
コード例 #3
0
ファイル: apiVulcan.py プロジェクト: Sanitsonn/messenger-bot
def getLastGrade(certificate):
    client = Vulcan(certificate)
    LastGradeID = ""
    LastGradeData = ""
    returnList = []
    for grade in client.get_grades():
        LastGradeID = grade.id
        LastGradeData = grade.subject.name + "\n" + grade.content
    returnList.append(LastGradeID)
    returnList.append(LastGradeData)
    return returnList
コード例 #4
0
def update_grades():
    #this function downloads grades from connected account | no arguments, no returns

    #prepare connection with Vulcan account
    with open("cert.json") as f:
        certificate = json.load(f)

    client = Vulcan(certificate)

    for grade in client.get_grades():

        #grade_to_add
        if grade.weight == 0.0: continue
        elif grade.content == "np": grade_to_add = "np"
        elif grade.content == "1": grade_to_add = "1"
        elif grade.content == "1+": grade_to_add = "1+"
        elif grade.content == "2": grade_to_add = "2"
        elif grade.content == "2+": grade_to_add = "2+"
        elif grade.content == "2-": grade_to_add = "2-"
        elif grade.content == "3": grade_to_add = "3"
        elif grade.content == "3+": grade_to_add = "3+"
        elif grade.content == "3-": grade_to_add = "3-"
        elif grade.content == "4": grade_to_add = "4"
        elif grade.content == "4-": grade_to_add = "4-"
        elif grade.content == "4+": grade_to_add = "4+"
        elif grade.content == "5": grade_to_add = "5"
        elif grade.content == "5-": grade_to_add = "5-"
        elif grade.content == "5+": grade_to_add = "5+"
        elif grade.content == "6": grade_to_add = "6"
        elif grade.content == "6-": grade_to_add = "6-"
        elif grade.content == "+": grade_to_add = "+"
        elif grade.content == "-": grade_to_add = "-"
        else: continue

        #subject_to_add
        subject_to_add = grade.subject.short

        #add grade to file
        path = "oceny/" + subject_to_add + ".txt"
        file = open(path, "a")
        file.write(grade_to_add)
        file.write("\n")
        file.close()
コード例 #5
0
ファイル: apiVulcan.py プロジェクト: Sanitsonn/messenger-bot
def getAverage(certificate, przedmiot):
    client = Vulcan(certificate)
    weights = 0
    grades = 0
    for grade in client.get_grades():
        if (grade.subject.name.lower() == przedmiot):
            if (len(grade.content) == 2):
                if ("+" in grade.content):
                    gradeG = int(grade.content[:-1])
                    gradeG += 0.25
                    grades += gradeG * int(grade.weight)
                    weights += int(grade.weight)
                else:
                    gradeG = int(grade.content[:-1])
                    gradeG -= 0.25
                    grades += gradeG * int(grade.weight)
                    weights += int(grade.weight)
            elif (grade.content.isnumeric() == True):
                grades += int(grade.content) * int(grade.weight)
                weights += int(grade.weight)
    return round(grades / weights, 2)