Beispiel #1
0
def harmonize_assignments(engine: str, adapter: Adapter) -> None:

    statements = [
        Statement(
            _generate_call_to_stored_procedure(
                engine,
                "harmonize_assignment",
                SOURCE_SYSTEM_NAMESPACE.CANVAS,
                SOURCE_SYSTEM.CANVAS,
            ),
            "Harmonizing Canvas LMS Assignments.",
        ),
        Statement(
            _generate_call_to_stored_procedure(
                engine,
                "harmonize_assignment",
                SOURCE_SYSTEM_NAMESPACE.GOOGLE,
                SOURCE_SYSTEM.GOOGLE,
            ),
            "Harmonizing Google Classroom LMS Assignments.",
        ),
        Statement(
            _generate_call_to_stored_procedure(
                engine, "harmonize_assignment",
                SOURCE_SYSTEM_NAMESPACE.SCHOOLOGY, SOURCE_SYSTEM.SCHOOLOGY),
            "Harmonizing Schoology LMS Assignments.",
        ),
    ]

    adapter.execute(statements)
def _record_migration_in_journal(adapter: Adapter, migration: str) -> None:
    statement = Statement(
        f"INSERT INTO lms.migrationjournal (script) values ('{migration}');",
        "Updating migration journal table",
    )

    adapter.execute([statement])
def _record_migration_in_journal(adapter: Adapter, migration: str) -> None:
    migration_name = _migration_name(migration)

    statement = Statement(
        f"insert into lms.migrationjournal_harmonizer (script) values ('{migration_name}');",
        "Updating migration journal table",
    )

    adapter.execute([statement])
def _run_migration_script(adapter: Adapter, migration: Migration) -> None:

    logger.debug(f"Running migration {migration.name}...")

    statements = _read_statements_from_file(migration.path)
    adapter.execute_script(statements)

    _record_migration_in_journal(adapter, migration.name)

    logger.debug(f"Done with migration {migration.name}.")
Beispiel #5
0
def _print_summary_for_sections_and_users(adapter: Adapter) -> None:
    users_count = adapter.get_int(QUERY_FOR_USERS_SUMMARY)
    sections_count = adapter.get_int(QUERY_FOR_SECTION_SUMMARY)
    if sections_count > 0 or users_count > 0:
        logger.warning(
            f"There are {sections_count} unmatched sections and {users_count} "
            f"unmatched users in the database.")
    else:
        logger.debug(
            "There are no unmatched sections or users in the database.")
Beispiel #6
0
def _print_summary_for_assignments_and_submissions(adapter: Adapter) -> None:
    assignments_count = adapter.get_int(QUERY_FOR_ASSIGNMENT_EXCEPTIONS)
    submissions_count = adapter.get_int(
        QUERY_FOR_ASSIGNMENT_SUBMISSION_EXCEPTIONS)
    if assignments_count > 0 or submissions_count > 0:
        logger.warning(
            f"There are {assignments_count} unmatched Assignments and"
            f" {submissions_count} unmatched Submissions")
    else:
        logger.debug(
            "There are no unmatched Assignments or Assignment submissions in the database."
        )
Beispiel #7
0
def _print_summary_for_descriptors(adapter: Adapter) -> None:
    assignment_descriptors_count = adapter.get_int(
        QUERY_FOR_ASSIGNMENT_CAT_DESCRIPTORS_SUMMARY)
    submission_descriptors_count = adapter.get_int(
        QUERY_FOR_SUBMISSION_STATUS_DESCRIPTORS_SUMMARY)
    if assignment_descriptors_count > 0 or submission_descriptors_count > 0:
        logger.warning(
            f"There are {assignment_descriptors_count} missing descriptors for Assignment Category "
            f"and {submission_descriptors_count} missing descriptors for Submission Status"
        )
    else:
        logger.debug(
            "There are no missing descriptors for Assignment Category or Submission Status in the database."
        )
def _script_has_been_run(adapter: Adapter, migration: str) -> bool:
    if (not _migrationjournal_exists(adapter)):
        return False

    statement = f"SELECT 1 FROM lms.migrationjournal WHERE script = '{migration}';"
    response = adapter.get_int(statement)
    return bool(response == 1)
def _migrationjournal_exists(adapter: Adapter) -> bool:
    statement = """
SELECT
    COUNT(table_name)
FROM
    information_schema.tables
WHERE
    table_schema LIKE 'lms' AND
    table_name = 'migrationjournal';
"""
    response = adapter.get_int(statement)
    return bool(response == 1)
Beispiel #10
0
def harmonize_sections(engine: str, adapter: Adapter) -> None:

    statements = [
        Statement(
            _generate_call_to_stored_procedure(engine,
                                               "harmonize_lmssection_canvas"),
            "Harmonizing Canvas LMS Sections.",
        ),
        Statement(
            _generate_call_to_stored_procedure(
                engine, "harmonize_lmssection_google_classroom"),
            "Harmonizing Google Classroom LMS Sections.",
        ),
        Statement(
            _generate_call_to_stored_procedure(
                engine, "harmonize_lmssection_schoology"),
            "Harmonizing Schoology LMS Sections.",
        ),
    ]

    adapter.execute(statements)
def _lms_migration_journal_exists(adapter: Adapter) -> bool:
    statement = """
select
    count(table_name)
from
    information_schema.tables
where
    table_schema like 'lms' and
    -- First option covers SQL Server if set to case sensitive mode,
    -- second option covers PostgreSQL
    table_name in ('MigrationJournal_Harmonizer', 'migrationjournal_harmonizer');
"""
    response = adapter.get_int(statement)
    return bool(response == 1)
def _script_has_been_run(adapter: Adapter, migration: str) -> bool:
    migration_name = _migration_name(migration)
    statement = f"select 1 from lms.migrationjournal_harmonizer where script = '{migration_name}';"
    response = adapter.get_int(statement)

    return bool(response == 1)