Verified Commit c9babed9 authored by Peter Stanko's avatar Peter Stanko
Browse files

Cpp preparation

parent 56534c03
Pipeline #16898 passed with stage
in 9 minutes and 5 seconds
......@@ -8,45 +8,55 @@ from portal.database import models
from portal.tools import time
def create_project(factory, test_course, name: str):
factory.create_project(
course=test_course, name=name.upper(), codename=name, config=dict(
file_whitelist="*.*",
test_files_source='git@gitlab.fi.muni.cz:xstanko2/kontr2_tests',
test_files_subdir=name,
pre_submit_script="",
post_submit_script="",
submission_scheduler_config="",
submission_parameters="{\"type\":\"text\"}",
submissions_allowed_from=time.current_time() - timedelta(days=1),
submissions_allowed_to=time.current_time() + timedelta(days=10),
archive_from=time.current_time() + timedelta(days=30)
)
)
def init_cpp_data(app: Flask, db: SQLAlchemy):
with app.app_context():
factory = shared.DataFactory(db)
# course
test_course1 = factory.create_course(codename='PB161', name='Programování v jazyce C++')
cpp = factory.create_course(codename='PB161', name='Programování v jazyce C++')
# groups
tc1_students = factory.create_group(course=test_course1, name="seminar01")
tc1_teachers = factory.create_group(course=test_course1, name="teachers")
tc1_hw01 = factory.create_project(
course=test_course1, name="HW01", codename='hw01', config=dict(
file_whitelist="*.*",
test_files_source='https://gitlab.fi.muni.cz/grp-kontr2/testing/hello-test-files',
test_files_subdir='',
pre_submit_script="python for kontr pre",
post_submit_script="python for kontr post",
submission_scheduler_config="python for sub Q",
submission_parameters="{\"type\":\"text\"}",
submissions_allowed_from=time.current_time() - timedelta(days=1),
submissions_allowed_to=time.current_time() + timedelta(days=10),
archive_from=time.current_time() + timedelta(days=30)
)
)
seminar_kontr = factory.create_group(course=cpp, name="seminar_kontr")
teachers_group = factory.create_group(course=cpp, name="teachers")
projects = []
for num in range(2, 5):
name = f"hw0{num}"
projects.append(create_project(factory, cpp, name))
for num in range(4, 9):
name = f"mini0{num}"
projects.append(create_project(factory, cpp, name))
# roles
tc1_student = factory.scaffold_role(role_type='student', course=test_course1)
tc1_teacher = factory.scaffold_role(role_type='teacher', course=test_course1)
tc1_owner = factory.scaffold_role(role_type='owner', course=test_course1)
tc1_worker = factory.scaffold_role(role_type='worker', course=test_course1)
students = factory.scaffold_role(role_type='student', course=cpp)
teachers = factory.scaffold_role(role_type='teacher', course=cpp)
owner = factory.scaffold_role(role_type='owner', course=cpp)
workers = factory.scaffold_role(role_type='worker', course=cpp)
# Projects in groups
tc1_students.projects.append(tc1_hw01)
db.session.add_all([tc1_student, tc1_teacher, tc1_owner, tc1_teachers])
db.session.add_all([students, teachers, owner, teachers_group, seminar_kontr])
# workers
worker = factory.create_worker(name='worker', url='http://localhost:8080')
worker.secrets.append(models.Secret('executor_secret', 'executor_secret'))
worker.roles.append(tc1_worker)
worker.roles.append(workers)
db.session.add_all([worker])
# Commit to the DB
db.session.commit()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment