Example #1
0
def build(args):
    db = DatabaseConnection(args.url)
    print u"Connected to {}.".format(repr(db.engine.url))
    if yes_no("Are you sure you want to build the database?"):
        from data.prepare import build_db
        print "Building database..."
        build_db(db.engine)
Example #2
0
def prepopulate(args):  # pylint: disable=W0613
    if yes_no("Are you sure you want to prepopulate the database with sample data?"):
        from data.prepare import prepopulate_db
        print "Prepopulating databsae..."
        prepopulate_db()
Example #3
0
def start_correction():
    for folder_name in os.listdir(KOREK_PATH):
        
        if "_" not in folder_name:
            continue

        name = folder_name.split("_")[0]
        
        if name not in student_set:
            name = fuzz_search(student_set.keys(), search_for=name)
        print("Found", name)
        students = [student_set[name]]

        if students[0].code in [x.students[0].code for x in exercice.entries]:
            print("skipping " + students[0].first_name + "\n")
            continue

        open_exercice(exercice, os.path.join(KOREK_PATH, folder_name))
        
        if yes_no("Is there another student (y/n) ?", True, False):
            students.append(student_set[fuzz_search(student_set.keys())])
        
        print("Une serie de question va être posé. La réponse doit être du style [points enlevés] [commentaire]. n pour next")
        questions = ['Remise', 'Fonctionnement du code', 'Commentaires', 'Beauté du code \n  - nom de variable \n  - aération des expressions \n  - variables inutile/répétition de code \n  - modulaire', "Autre commentaire"]
        comment = [[] * len(questions)]

        affichage = [
            (0, "Remise"),
            (50, "Fonctionnement du code"),
            (10, "Commentaires"),
            (40, "Beauté du code"),
            (0, "Autre commentaires")
        ]

        grade = 100

        final_string = ""

        for i in range(len(questions)):
            x = input("?? " + questions[i] + "\n-> ")
            current_string = ""
            point_lost = 0

            max_point, text  = affichage[i]

            while x != "n":
                try:
                    p = float(x.split()[0])
                    assert p <= 0
                    point_lost += p
                    current_string += "  " + x + "\n"
                except Exception as e:
                    print("error got", e)
                x = input("-> ")

            if max_point != 0 or len(current_string) != 0:
                grade += point_lost
                next_to = ""
                if max_point == 0:
                    next_to = str(point_lost)
                else:
                    next_to = str(abs(point_lost +max_point)) + "/" + str(max_point) 
                final_string += text + " " + next_to + " \n"
                final_string += current_string

        final_string += "\nNOTE FINALE : " + str(grade)

        exercice.entries.append(ExerciceEntry(students, grade, final_string))
        save_exercice(exercice)

        print(final_string + "\n\n====================")
Example #4
0

try:
    use_cp1251, use_auth = parse_arg(args[1]), parse_arg(args[2])
except ValueError as exc:
    print(f"Неверный аргумент: {exc.args[0]}. Возможны только аргументы {POSSIBLE_ARGS}")
    exit(-1)
except IndexError:
    pass

try:
    enc = CnM.from_path(INPUT_FNAME).best().first().encoding
    if enc != 'utf-8':
        print("\n\n", ENC_WARN, "\n\n")
        if use_cp1251 is None:
            use_cp1251 = yes_no("Использовать cp1251 вместо текущей кодировки?")
        if use_cp1251:
            enc = 'cp1251'
    # parse the file with group IDs
    print("Используется кодировка: ", enc)
    with open(INPUT_FNAME, 'r', newline='', encoding=enc) as csvf:
        dialect = csv.Sniffer().sniff(csvf.read(1024))
        csvf.seek(0)
        reader = csv.reader(csvf, dialect=dialect)
        for row in reader:
            if row[0] == INPUT_FILE_HEADER_GROUP_TITLE:
                continue
            data.append({FIELDNAMES[0]: row[0],  # name
                         FIELDNAMES[1]: row[1],  # link
                         FIELDNAMES[2]: None,  # memcount
                         FIELDNAMES[3]: None,  # last