Exemple #1
0
def getStudentVueData():
    username = IntPrompt.ask('Enter your user id')
    pwd = Prompt.ask('Enter your password')
    domain = 'https://md-mcps-psv.edupoint.com'
    remember = Confirm.ask('Do you want to be remembered?')
    studentvue_client = StudentVue(str(username), pwd, domain)
    while 'RT_ERROR' in studentvue_client.get_gradebook().keys():
        text = Text('Username or password is incorrect. Try again')
        text.stylize(style="red")
        console.print(text)
        username = IntPrompt.ask('Enter your user id')
        pwd = Prompt.ask('Enter your password')
        studentvue_client = StudentVue(str(username), pwd, domain)
    return studentvue_client.get_gradebook()
Exemple #2
0
async def get(ctx, mp=2):

    if mp < 0:
        mp = 0
    if mp > 4:
        mp = 4
    mp -= 1
    print(mp)

    q = query("""select * from users where id == ?""", ctx.message.author.id)
    if len(q) == 0:
        await msg(ctx, ctx.message.author)
        return

    u = q[0]['username']
    p = f.decrypt(q[0]['password']).decode()
    d = q[0]['domain']
    sv = StudentVue(u, p, d)

    gb = sv.get_gradebook(mp)['Gradebook']['Courses']['Course']

    grades = []

    for t in gb:
        vals = ['', '', '']
        for key, value in t.items():
            if key == '@Title':
                vals[0] = value
            if key == 'Marks':
                for i in value['Mark']:
                    nextent = False
                    for j in i.items():
                        if j[0] == '@MarkName' and j[1][:2] == 'MP':
                            nextent = True

                        if nextent:
                            if j[0] == '@CalculatedScoreString':
                                vals[1] = j[1]
                            if j[0] == '@CalculatedScoreRaw':
                                vals[2] = j[1]
                                nextent = False
        grades.append(vals)

    res = "```Your Grades (quarter " + str(mp + 1) + "):\n"

    table = PrettyTable()
    table.field_names = ["Class", "Letter Grade", "Exact Grade"]

    for a in grades:
        table.add_row(a)

    table.align = "l"

    res += str(table)

    res += "```"

    await ctx.send(res)
    username = input("Enter username: "******"Enter password: "******"Enter password(hidden): ")
    student = StudentVue(username,password,"md-mcps-psv.edupoint.com")
    try:
        temp = student.get_attendance()["RT_ERROR"]["@ERROR_MESSAGE"]
        print("Invalid username or password. \n")
        time.sleep(1)
        os.system("cls")
    except:
        break
    
os.system("cls") 
name = student.get_student_info()['StudentInfo']["NickName"]["$"]
print("Welcome",name+"!")
grades = student.get_gradebook(2)

while True:
    os.system("cls")
    print("1. Student Info")
    print("2. Absences")
    print("3. Gradebook")
    print("4. Synergy Mail")
    print("5. Report Card")
    print("6. Refresh Data")

    try:
        print("")
        temp = int(input())
        if temp < 1 or temp > 6:
            print("\n")
Exemple #4
0
class SVInfo(object):
    def __init__(self, username="", password="", domain=""):
        cf = ConfigParser()
        p = os.path.join(os.path.dirname(__file__), "config.ini")
        cf.read(p)
        if username == "":
            username = input("Student ID -> ")
        if password == "":
            password = bullet.Password("Password -> ").launch()
        if domain == "":
            if not os.path.exists(p) or cf.get("values", "domain") == "":
                domain = input("District Edupoint Domain -> ")
                if not os.path.exists(p):
                    cf.add_section("values")
                cf.set("values", "domain", domain)
                with open(p, "w+") as configfile:
                    cf.write(configfile)
            else:
                domain = cf.get("values", "domain")
        self.sv = StudentVue(
            username,
            password,
            domain,
        )

    def grades(self, long=False, course="all"):
        courses = self.sv.get_gradebook().get("Gradebook").get("Courses").get(
            "Course")

        grades = []

        for c in courses:
            filtered_assignments = []
            try:
                assignments = (c.get("Marks").get("Mark").get(
                    "Assignments").get("Assignment"))
                if assignments != None and long:
                    for assignment in assignments:
                        filtered_assignments.append([
                            assignment.get("@Measure"),
                            assignment.get("@Points")
                        ])
            except:
                pass
            try:
                grades.append([
                    c.get("@Title"),
                    c.get("Marks").get("Mark").get("@CalculatedScoreRaw"),
                    filtered_assignments,
                ])
            except:
                grades.append([
                    c.get("@Title"),
                    "Grade unavailable",
                    filtered_assignments,
                ])
        fgrades = ""
        i = 0
        for grade in grades:
            add_grade = False
            i += 1
            if course != all:
                if type(course) is list:
                    if i in course or str(i) in course:
                        add_grade = True
                elif type(course) is int or type(course) is str:
                    if str(i) == str(course):
                        add_grade = True
                else:
                    raise TypeError(
                        'Type of "course" expected to be list or int. Got ' +
                        type(course).__name__)
            if course == "all" or add_grade:
                fgrades += grade[0].split("(")[0].rstrip() + ":  "
                fgrades += str(grade[1]) + "%\n"
                for assignment in grade[2]:
                    fgrades += "\t" + assignment[0] + ":  "
                    if "Points Possible" in assignment[1].split("/")[0]:
                        fgrades += (str(float(assignment[1].split(" ")[0])) +
                                    " " +
                                    " ".join(assignment[1].split(" ")[1:]) +
                                    "\n")
                    else:
                        fgrades += (str(float(assignment[1].split("/")[0])) +
                                    " / " +
                                    str(float(assignment[1].split("/")[1])) +
                                    "\n")

        return fgrades.strip()

    def schedule(self):
        times = []
        now = datetime.datetime.now()
        sched = (self.sv.get_schedule().get("StudentClassSchedule").get(
            "TodayScheduleInfoData").get("SchoolInfos").get("SchoolInfo"))
        if sched != None:
            sched = sched.get("Classes").get("ClassInfo")
            for item in sched:
                start = item.get("@StartTime").split(" ")
                end = item.get("@EndTime").split(" ")
                stimestr = start[0].split(":")
                etimestr = end[0].split(":")
                stime = []
                etime = []
                for item in stimestr:
                    stime.append(int(item))
                for item in etimestr:
                    etime.append(int(item))

                if start[1] == "PM" and stime[0] != 12:
                    stime[0] += 12
                if end[1] == "PM" and etime[0] != 12:
                    etime[0] += 12
                if start[1] == "AM" and stime[0] == 12:
                    stime[0] -= 12
                if end[1] == "AM" and etime[0] == 12:
                    etime[0] -= 12

                times.append([stime, etime])
            fschedule = f"Schedule for {now.month}/{now.day}/{now.year}:\n"
            t = 0
            for item in times:
                fschedule += ("\t" + " ".join(sched[t].get("@ClassName").split(
                    " ")[1:]).split("-")[0].rstrip() + ":  ")
                fschedule += f"{datetime.time(hour=item[0][0],minute=item[0][1])} to {datetime.time(hour=item[1][0],minute=item[1][1])}\n"

                t += 1
            return fschedule.strip()
        else:
            return "No school schedule"