Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions proctoring/Get_proctoring_links.py
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Домен прокторинга нужно вынести в константу

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("_", " ")
Copy link

@Artanias Artanias May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cтоит указать в месте добавления аргумента "name", что он required=True, иначе кто-то не задаст и будет неочевидное падение. Также и по поводу других аргументов, может им также стоит прописать required?


subprocess.run("./../mongo_export.sh")

refactor_statistics()
create_links(args)
31 changes: 31 additions & 0 deletions proctoring/ReadMe.md
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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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)>`

#### Результат
```
<описание_события>: <ссылка_на_прокторинг_с_таймкодом>
<описание_события>: <ссылка_на_прокторинг_с_таймкодом>
<описание_события>: <ссылка_на_прокторинг_с_таймкодом>
<описание_события>: <ссылка_на_прокторинг_с_таймкодом>
<описание_события>: <ссылка_на_прокторинг_с_таймкодом>
```