Skip to content

Add linear algebra#76

Merged
Davictory2003 merged 9 commits intomainfrom
add-linear-algebra
May 6, 2026
Merged

Add linear algebra#76
Davictory2003 merged 9 commits intomainfrom
add-linear-algebra

Conversation

@thejoeyluu
Copy link
Copy Markdown
Contributor

level 1 and 2 linear algebra is now in play

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the cheat-sheet formula catalog by adding Linear Algebra I/II content, and also introduces an orientation layout option that flows from the frontend layout controls through backend LaTeX generation/normalization.

Changes:

  • Add new Linear Algebra I and II formula datasets and register them in the formula catalog.
  • Add orientation as a persisted layout option in the frontend hook/UI and backend API/model.
  • Update LaTeX generation/normalization to include paper/orientation options, and adjust backend/frontend tests accordingly.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/src/hooks/latex.test.jsx Extends hook tests to cover the new orientation default and custom value.
frontend/src/hooks/latex.js Adds orientation state, persistence (localStorage), and API payload wiring for compile/normalize/generate calls.
frontend/src/components/CreateCheatSheet.jsx Adds an Orientation selector to layout controls and plumbs orientation state into the UI.
backend/api/views.py Accepts/validates orientation in generate/compile endpoints and returns it in normalize-only responses.
backend/api/tests.py Updates/extends tests for new layout comment and updated LaTeX header expectations.
backend/api/models.py Adds orientation field to CheatSheet.
backend/api/migrations/0008_cheatsheet_orientation.py DB migration to add the orientation column with a default.
backend/api/latex_utils.py Threads orientation through LaTeX header/layout-comment generation and normalization logic.
backend/api/formula_data/linear_algebra_i.py Adds Linear Algebra I formulas.
backend/api/formula_data/linear_algebra_ii.py Adds Linear Algebra II formulas.
backend/api/formula_data/init.py Registers Linear Algebra I/II into available classes and formula data mappings.
Comments suppressed due to low confidence (1)

backend/api/views.py:376

  • When compiling via cheat_sheet_id, the view overwrites columns/font_size/margins/spacing from the saved CheatSheet but does not overwrite orientation. This means a saved landscape sheet will still compile as portrait unless the client redundantly sends orientation. Set orientation = cheatsheet.orientation (and consider re-running validate_layout_params after loading the model values) so the stored layout is consistently respected.
    if cheat_sheet_id:
        cheatsheet = get_object_or_404(CheatSheet, pk=cheat_sheet_id, user=request.user)
        columns = cheatsheet.columns
        font_size = cheatsheet.font_size
        margins = cheatsheet.margins
        spacing = cheatsheet.spacing
        content = cheatsheet.build_full_latex()
    

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1027 to 1032
setSpacing,
margins,
setMargins,
orientation,
setOrientation,
pdfBlob,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

orientation is now part of the layout state, but it is not included in the onSave(...) payloads (both the autosave snapshot and the explicit Save handler). As a result, the new orientation setting won’t persist across reloads/restores even though the UI exposes it. Include orientation (and, if applicable, in compileSnapshot) wherever layout settings are saved.

Comment thread backend/api/models.py
Comment on lines 38 to 43
columns = models.IntegerField(default=4)
margins = models.CharField(max_length=20, default="0.15in")
font_size = models.CharField(max_length=10, default="9pt")
spacing = models.CharField(max_length=10, default="small")
orientation = models.CharField(max_length=20, default="portrait")
# Stores selected formulas with user-defined order: [{"class": "...", "category": "...", "name": "..."}]
Comment on lines +151 to +159
# 1. Force the PDF driver to rotate by passing landscape and letterpaper to the document class
doc_options = f"{doc_class_size},fleqn,letterpaper"
if orientation == "landscape":
doc_options += ",landscape"

# 2. Also pass them to the geometry package
geometry_options = f"letterpaper,margin={margins}"
if orientation == "landscape":
geometry_options += ",landscape"
Comment thread backend/api/views.py
Comment on lines 283 to 289
@api_view(["POST"])
def generate_sheet(request):
"""
POST /api/generate-sheet/
Accepts { "formulas": [...], "columns": 4, "font_size": "9pt", "margins": "0.15in", "spacing": "small" }
Accepts { "formulas": [...], "columns": 4, "font_size": "9pt", "margins": "0.15in", "spacing": "small", "orientation": "portrait" }
Each formula: { "class": "ALGEBRA I", "category": "Linear Equations", "name": "Slope Formula" }
Or for special classes (like UNIT CIRCLE): { "class": "UNIT CIRCLE", "name": "Unit Circle (Key Angles)" }
Returns { "tex_code": "..." }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR title/description focus on adding Linear Algebra content, but this PR also introduces a new layout feature (orientation) and changes LaTeX paper options (letterpaper) across compile/generate flows. Please update the PR description/title to reflect this additional user-facing behavior, or split the layout work into a separate PR for clearer review/release notes.

@Davictory2003
Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

…, and landscape test

Agent-Logs-Url: https://github.com/ChicoState/cheat-sheet/sessions/feaa4cd4-4709-4685-85f7-54a23f49946e

Co-authored-by: Davictory2003 <68972845+Davictory2003@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

@copilot apply changes based on the comments in this thread

Applied all four changes from the review thread in commit 8a449ba:

  1. orientation in onSave payloads — Added orientation to both the autosave snapshot (including compileSnapshot) and the explicit handleSave payload in CreateCheatSheet.jsx, and added orientation to the useEffect dependency array.

  2. orientation in serializer — Added "orientation" to CheatSheetSerializer.Meta.fields so clients can read and write the value via the API.

  3. build_full_latex() uses orientation — Updated models.py to build doc_options and geometry_options with letterpaper + landscape when orientation is landscape, making it consistent with build_dynamic_header().

  4. Landscape test — Added test_build_dynamic_header_landscape_includes_landscape_options in tests.py that verifies \documentclass[9pt,fleqn,letterpaper,landscape]{extarticle} and letterpaper,margin=0.15in,landscape in the generated header.

All 99 backend and 53 frontend tests pass.

Copilot AI requested a review from Davictory2003 May 6, 2026 18:39
@Davictory2003 Davictory2003 merged commit c39a5c1 into main May 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants