Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphic Exercises #372

Merged
merged 24 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f510596
Refactor feedback reference
LeonWehrhahn Nov 16, 2024
ba85feb
Merge branch 'develop' into feature/modeling/reference
LeonWehrhahn Nov 16, 2024
6b98bb8
Enhance Apollon JSON transformer and parser for improved element ID m…
LeonWehrhahn Nov 18, 2024
2bba32f
Merge branch 'feature/modeling/reference' of https://github.com/ls1in…
LeonWehrhahn Nov 18, 2024
ac31664
Merge branch 'develop' into feature/modeling/reference
LeonWehrhahn Nov 18, 2024
bf5a80d
Merge branch 'develop' into feature/modeling/reference
LeonWehrhahn Nov 22, 2024
9de3f10
Add element_ids field to ModelingFeedback and update feedback convers…
LeonWehrhahn Nov 27, 2024
e15d11c
Merge branch 'feature/modeling/reference' of https://github.com/ls1in…
LeonWehrhahn Nov 28, 2024
1e8e21d
Add element_ids field to DBModelingFeedback model
LeonWehrhahn Nov 28, 2024
a5203ff
Add JSON type import to db_modeling_feedback.py
LeonWehrhahn Nov 29, 2024
2a169b8
Merge branch 'develop' into feature/modeling/reference
LeonWehrhahn Nov 29, 2024
b6af29a
Merge branch 'develop' into feature/modeling/reference
LeonWehrhahn Dec 3, 2024
7b488a3
add structured grading instruction cache
LeonWehrhahn Dec 3, 2024
f2604c9
Increase default max_tokens to 4000 in OpenAI model configuration
LeonWehrhahn Dec 3, 2024
87a66a7
Increase max_input_tokens to 5000 and update element_ids assignment i…
LeonWehrhahn Dec 3, 2024
322fd55
Refactor exercise models to implement polymorphism and establish rela…
LeonWehrhahn Dec 6, 2024
fda3f13
Merge branch 'feature/modeling/reference' into feature/modeling/caching
LeonWehrhahn Dec 6, 2024
a83ac8b
Refactor exercise storage and structured grading criterion handling; …
LeonWehrhahn Dec 6, 2024
55449ec
Merge branch 'develop' into feature/modeling/caching
LeonWehrhahn Dec 6, 2024
0eff118
Remove DBStructuredGradingCriterion model and clean up imports in __i…
LeonWehrhahn Dec 7, 2024
672f762
Refactor grading criterion handling: remove structured grading criter…
LeonWehrhahn Dec 7, 2024
ce29d4a
Merge branch 'develop' into feature/modeling/caching
LeonWehrhahn Jan 10, 2025
db7d5d6
Merge branch 'develop' into feature/modeling/caching
LeonWehrhahn Jan 20, 2025
8020d92
Remove whitespace from grading_criterion.py
maximiliansoelch Jan 28, 2025
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
15 changes: 12 additions & 3 deletions athena/athena/models/db_exercise.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
from sqlalchemy import Column, String, Float, JSON, Enum as SqlEnum

from sqlalchemy.orm import relationship
from athena.database import Base
from athena.schemas import ExerciseType
from .model import Model
from .big_integer_with_autoincrement import BigIntegerWithAutoincrement


class DBExercise(Model):
class DBExercise(Model, Base):
__tablename__ = "exercise"
id = Column(BigIntegerWithAutoincrement, primary_key=True, index=True, nullable=False)
lms_url = Column(String, index=True, nullable=False)
title = Column(String, index=True, nullable=False)
type = Column(SqlEnum(ExerciseType), index=True, nullable=False)
max_points = Column(Float, index=True, nullable=False)
bonus_points = Column(Float, index=True, nullable=False)
grading_instructions = Column(String)
problem_statement = Column(String)
grading_criteria = Column(JSON, nullable=True)
meta = Column(JSON, nullable=False)

# Polymorphism, discriminator attribute
type = Column(SqlEnum(ExerciseType), index=True, nullable=False)

__mapper_args__ = {
'polymorphic_identity': 'exercise',
'polymorphic_on': 'type'
}
19 changes: 11 additions & 8 deletions athena/athena/models/db_modeling_exercise.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from sqlalchemy import Column, String
from athena.schemas.exercise_type import ExerciseType
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import relationship

from athena.database import Base
from .db_exercise import DBExercise


class DBModelingExercise(DBExercise, Base):
from .big_integer_with_autoincrement import BigIntegerWithAutoincrement
class DBModelingExercise(DBExercise):
__tablename__ = "modeling_exercises"

example_solution: str = Column(String) # type: ignore

example_solution = Column(String) # type: ignore

id = Column(BigIntegerWithAutoincrement, ForeignKey('exercise.id'), primary_key=True)
submissions = relationship("DBModelingSubmission", back_populates="exercise")
feedbacks = relationship("DBModelingFeedback", back_populates="exercise")

__mapper_args__ = {
'polymorphic_identity': ExerciseType.modeling.value
}
12 changes: 9 additions & 3 deletions athena/athena/models/db_programming_exercise.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
from sqlalchemy import Column, String
from athena.schemas.exercise_type import ExerciseType
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import relationship

from athena.database import Base
from .db_exercise import DBExercise
from .big_integer_with_autoincrement import BigIntegerWithAutoincrement


class DBProgrammingExercise(DBExercise, Base):
class DBProgrammingExercise(DBExercise):
__tablename__ = "programming_exercises"

id = Column(BigIntegerWithAutoincrement, ForeignKey('exercise.id'), primary_key=True)
programming_language: str = Column(String, nullable=False) # type: ignore
solution_repository_uri: str = Column(String, nullable=False) # type: ignore
template_repository_uri: str = Column(String, nullable=False) # type: ignore
tests_repository_uri: str = Column(String, nullable=False) # type: ignore

submissions = relationship("DBProgrammingSubmission", back_populates="exercise")
feedbacks = relationship("DBProgrammingFeedback", back_populates="exercise")

__mapper_args__ = {
'polymorphic_identity': ExerciseType.programming.value
}
12 changes: 9 additions & 3 deletions athena/athena/models/db_text_exercise.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
from sqlalchemy import Column, String
from athena.schemas.exercise_type import ExerciseType
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import relationship

from athena.database import Base
from .db_exercise import DBExercise
from .big_integer_with_autoincrement import BigIntegerWithAutoincrement


class DBTextExercise(DBExercise, Base):
class DBTextExercise(DBExercise):
__tablename__ = "text_exercises"
id = Column(BigIntegerWithAutoincrement, ForeignKey('exercise.id'), primary_key=True)

example_solution: str = Column(String) # type: ignore

submissions = relationship("DBTextSubmission", back_populates="exercise")
feedbacks = relationship("DBTextFeedback", back_populates="exercise")

__mapper_args__ = {
'polymorphic_identity': ExerciseType.text.value
}
2 changes: 1 addition & 1 deletion athena/athena/schemas/grading_criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class GradingCriterion(Schema, ABC):
{"credits": 0.0, "gradingScale": "Bad", "instructionDescription": "Some instructions", "feedback": "Try again!", "usageCount": 0}])

class StructuredGradingCriterion(BaseModel):
criteria: List[GradingCriterion]
criteria: List[GradingCriterion]
Loading