-
Notifications
You must be signed in to change notification settings - Fork 0
Proctoring script #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Proctoring script #280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import argparse | ||
| import subprocess | ||
| import json | ||
| import datetime | ||
|
|
||
| class Time(datetime.time): | ||
| def __sub__(self, other): | ||
| x = self.hour * 3600 + self.minute * 60 + self.second | ||
| y = other.hour * 3600 + other.minute * 60 + other.second | ||
| return x-y | ||
|
|
||
|
|
||
| def create_links(parser): | ||
| statistics = open("statistics.json", mode="r") | ||
| data = json.load(statistics) | ||
| users_events = data["data"] | ||
| date = list(map(int, parser.date.split('.')[::-1])) | ||
| date = datetime.date(date[0], date[1], date[2]) | ||
| start = list(map(int, parser.start.split(':'))) | ||
| start = Time(start[0], start[1], 0, 0) | ||
| end = list(map(int, parser.end.split(':'))) | ||
| end = Time(end[0], end[1], 0, 0) | ||
| for writes in users_events: | ||
| if writes["student"] != parser.name: | ||
| continue | ||
| for event in writes["actions"]: | ||
| if event["event_type"] == "scroll": | ||
| continue | ||
| date_time = event["timestamp"]["$date"].split("T") | ||
| event_date = list(map(int, date_time[0].split('-'))) | ||
| event_date = datetime.date(event_date[0], event_date[1] ,event_date[2]) | ||
| if event_date != date: | ||
| continue | ||
| event_time = list(map(int, date_time[1].replace('.', ':').replace('Z', '').split(':'))) | ||
| event_time = Time(event_time[0], event_time[1], event_time[2], event_time[3]) | ||
| if event_time < start or event_time > end: | ||
| continue | ||
| event_description = event["element_type"] + " " + event["event_type"] + ":" | ||
| time_code = str(event_time - start) | ||
| link = "https://proctoring.moevm.info/teach/" + parser.id + '?webTime=' + time_code + '&screenTime=' + time_code | ||
| print(event_description, link) | ||
|
|
||
|
|
||
| def refactor_statistics(): | ||
| with open('statistics.json', 'r') as f: | ||
| data = f.read() | ||
| count = data.count('\n') | ||
| data = data.replace('\n', ',\n', count-1) | ||
|
|
||
| with open('statistics.json', 'r+') as f: | ||
| f.writelines(['{', '"data" : [ ']) | ||
| f.write(data) | ||
| f.write(']}') | ||
|
|
||
| parser = argparse.ArgumentParser(description="Скрипт для генерации ссылок прокторинга на конкретные действия студента") | ||
| parser.add_argument("name", help="ИФ студента через нижнее подчеркивание") | ||
| parser.add_argument("id", help="id сессии прокторинга") | ||
| parser.add_argument("date", help="Дата сессии") | ||
| parser.add_argument("start", help="Время начала сессии") | ||
| parser.add_argument("end", help="Время окончания сессии") | ||
|
|
||
| args = parser.parse_args() | ||
| args.name = args.name.replace("_", " ") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cтоит указать в месте добавления аргумента "name", что он |
||
|
|
||
| subprocess.run("./../mongo_export.sh") | ||
|
|
||
| refactor_statistics() | ||
| create_links(args) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Инструкция запуска | ||
|
|
||
| ### Вывод справки | ||
| `python3 Get_proctoring_links.py -h` | ||
| #### Результат | ||
| ``` | ||
| usage: Get_proctoring_links.py [-h] name id date start end | ||
|
|
||
| Скрипт для генерации ссылок прокторинга на конкретные действия студента | ||
|
|
||
| positional arguments: | ||
| name ИФ студента через нижнее подчеркивание | ||
| id id сессии прокторинга | ||
| date Дата сессии | ||
| start Время начала сессии | ||
| end Время окончания сессии | ||
|
Comment on lines
+14
to
+16
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Давайте сделаем два параметра типа datetime - start и finish |
||
|
|
||
| options: | ||
| -h, --help show this help message and exit | ||
| ``` | ||
| ### Запуск скрипта | ||
| `python3 Get_proctoring_links.py <Имя>_<Фамилия> <id_сессии> <Дата_сессии(DD.MM.YYYY)> <Время_начала_сессии(HH:MM)> <Время_конца_сессии(HH:MM)>` | ||
|
|
||
| #### Результат | ||
| ``` | ||
| <описание_события>: <ссылка_на_прокторинг_с_таймкодом> | ||
| <описание_события>: <ссылка_на_прокторинг_с_таймкодом> | ||
| <описание_события>: <ссылка_на_прокторинг_с_таймкодом> | ||
| <описание_события>: <ссылка_на_прокторинг_с_таймкодом> | ||
| <описание_события>: <ссылка_на_прокторинг_с_таймкодом> | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Домен прокторинга нужно вынести в константу