API Reference

Configuration helpers.

course_hoanganhduc.config.cache_course_code(course_code)[source]

Persist a normalized course code in the local .course_code cache.

course_hoanganhduc.config.clear_config(config_path=None, course_code=None, verbose=False)[source]

Remove the stored config file.

course_hoanganhduc.config.clear_credentials(credentials_path=None, token_path=None, course_code=None, verbose=False)[source]

Remove stored credentials and token files.

course_hoanganhduc.config.get_cached_course_code()[source]

Return the cached course code from .course_code if available.

course_hoanganhduc.config.get_default_config_path(course_code=None, verbose=False)[source]

Get the default config file path for the current operating system. The course_code controls the subfolder name under the base config directory. - Windows: %APPDATA%course<course_code>config.json - macOS: ~/Library/Application Support/course/<course_code>/config.json - Linux: ~/.config/course/<course_code>/config.json If verbose is True, print details about the chosen path. Otherwise, print only an important notice if the config file does not exist.

course_hoanganhduc.config.get_default_credentials_path(course_code=None, verbose=False)[source]

Get the default credentials file path alongside the config file.

course_hoanganhduc.config.get_default_download_folder(verbose=False)[source]

Get the default download folder for the current operating system. Returns the Downloads folder path appropriate for Windows, Mac, or Linux. If verbose is True, print details about the chosen path. Otherwise, print only an important notice if the folder does not exist.

course_hoanganhduc.config.get_default_token_path(course_code=None, verbose=False)[source]

Get the default token file path alongside the config file.

course_hoanganhduc.config.load_config(config_path=None, verbose=False)[source]

Load configuration from a JSON or base64-encoded JSON file at the default location and return config values as a dict. If config_path is not provided, loads from the OS-specific default location. config_path can be a file path (JSON or base64-encoded JSON) or a base64 string. Returns a dict of the loaded config values (does NOT set global variables). If verbose is True, print more details; otherwise, print only important notice.

NOTE: If you want to update global variables, you must set:

DEFAULT_AI_METHOD ALL_AI_METHODS GEMINI_API_KEY HUGGINGFACE_API_KEY GEMINI_DEFAULT_MODEL DEFAULT_OCR_METHOD ALL_OCR_METHODS OCRSPACE_API_KEY OCRSPACE_API_URL LOCAL_LLM_COMMAND LOCAL_LLM_MODEL LOCAL_LLM_ARGS LOCAL_LLM_TIMEOUT CANVAS_LMS_API_URL CANVAS_LMS_API_KEY CANVAS_LMS_COURSE_ID GOOGLE_CLASSROOM_GRADE_CATEGORY_METHOD GOOGLE_CLASSROOM_CC_TOPICS GOOGLE_CLASSROOM_GK_TOPICS GOOGLE_CLASSROOM_CK_TOPICS GOOGLE_SHEET_URL COURSE_CODE COURSE_NAME DEFAULT_RESTRICTED WEIGHT_CC WEIGHT_GK WEIGHT_CK QUALITY_MIN_CHARS QUALITY_UNIQUE_CHAR_RATIO_MIN QUALITY_REPEAT_CHAR_RATIO_MAX QUALITY_VN_CHAR_RATIO_MIN QUALITY_ALNUM_RATIO_MIN QUALITY_SYMBOL_RATIO_MAX QUALITY_EMPTY_LINE_RATIO_MAX QUALITY_MATH_DENSITY_THRESHOLD QUALITY_LENGTH_RATIO_LOW QUALITY_LENGTH_RATIO_MEDIUM QUALITY_LENGTH_RATIO_HIGH MIDTERM_DATE EXAM_TYPE CANVAS_MIDTERM_ASSIGNMENT_ID CANVAS_FINAL_ASSIGNMENT_ID CANVAS_CC_ASSIGNMENT_ID

course_hoanganhduc.config.validate_config(config, verbose=False)[source]

Lightweight validation for config values. Returns a list of warning strings.

Canvas LMS helpers.

course_hoanganhduc.canvas.interactive_modify_database(students, db_path=None, verbose=False)[source]

Interactively modify student records in the database. Allows searching, editing, adding, and deleting students. When editing a field, pre-fill the old value for easy modification. After editing a field, ask if the user wants to continue editing other fields of the same student, edit another student, or quit. Always allow quitting at any step. If no response after 60 seconds from user then quit. If verbose is True, print more details; otherwise, print only important notice.

course_hoanganhduc.google_classroom.download_google_classroom_assignment_submissions(course_id=None, credentials_path='gclassroom_credentials.json', token_path='token.pickle', coursework_ids=None, dest_dir=None, ocr_service='ocrspace', lang='auto', meaningfulness_threshold=0.4, similarity_threshold=0.85, verbose=False)[source]

Download latest Google Classroom submissions for selected coursework, then run meaningfulness + similarity checks on PDFs.

course_hoanganhduc.google_classroom.download_google_sheet_to_csv(sheet_url, output_path=None, credentials_path='gclassroom_credentials.json', token_path='token.pickle', verbose=False, sheet_name=None, sheet_selection='first')[source]

Download a Google Sheet as CSV using the first sheet, gid in URL, or specified sheet. Returns the output CSV path.

Parameters:
  • sheet_name – Specific sheet name to download

  • sheet_selection – Mode for sheet selection - ‘first’ (default), ‘select’ (interactive), ‘all’, or ‘merge’

course_hoanganhduc.google_classroom.grade_google_classroom_assignment_submissions(course_id=None, credentials_path='gclassroom_credentials.json', token_path='token.pickle', coursework_ids=None, score=None, ungraded_only=True, apply_all=False, verbose=False)[source]

Grade Google Classroom assignment submissions interactively or with provided IDs. - If coursework_ids is None, prompt for selection. - If score is None, prompt for a score and apply to selected submissions. - If ungraded_only is True, only list ungraded submissions.

course_hoanganhduc.google_classroom.sync_students_with_google_classroom(students, db_path=None, course_id=None, credentials_path='gclassroom_credentials.json', token_path='token.pickle', fetch_grades=False, verbose=False)[source]

Sync students in the local database with active students from Google Classroom. For each student fetched from Google Classroom:

  • match by the local field ‘Google Classroom Display Name’ (case-insensitive)

  • if matched: fill missing local fields from Google data (Google_ID, Email, Google_Classroom_Display_Name)

  • if not matched: create a new student entry with Name, Email, Google_ID and Google_Classroom_Display_Name

Optionally fetch grades/submission state when fetch_grades=True.

Returns (added_count, updated_count).

course_hoanganhduc.google_classroom.unenroll_google_classroom_students(course_id=None, domains=None, emails=None, select_all=False, select_mode=False, credentials_path='gclassroom_credentials.json', token_path='token.pickle', apply_all=False, missing_student_id=False, db_path=None, update_local_db=True, dry_run=False, verbose=False)[source]

Unenroll students from a Google Classroom course by email domain.