Formatted, debugging. Added exception.

This commit is contained in:
2024-02-13 19:24:25 +01:00
parent 5e975cead1
commit 99e356d96a
12 changed files with 294 additions and 157 deletions

View File

@ -1,25 +1,30 @@
# Module to handle each assignment (most difficult part)
from Course import Course
from File import File
from Submission import Submission
from Downloadable import Downloadable
from Base import Base
from Exercise import Exercise
from requests import Session
class Assignment(Base):
def __init__(self, url:str, name:str, session:Session, parent:Course):
def __init__(self, url:str, name:str, session:Session, parent):
super().__init__()
self.files = self.files
self.download = Downloadable(url, name, session, self)
def __str__(self):
return f"Assignment {self.name} in course {self.parent.name}"
return f"Assignment {self.name} in course {self.parent.name}"
def getSubmissions(self) -> Submission:
pass
def getExercises(self) -> list[Exercise]:
# Find li large
ul = self.soup.find('ul', class_='round')
def getExercises(self) -> list[Excercise]:
pass
# Turn each li to an exercise instance
return self.liLargeToExercises(ul, self.session, self)
def getExercise(self, name:str) -> Exercise:
pass
# Get the exercise
r = self.session.get(self.url)
soup = BeautifulSoup(r.text, 'lxml')
# Search by name
exercise = soup.find('a', text=name)
# Get the url and transform it into an exercise object
return Exercise(url=exercise['href'], name=name, session=self.session, assignment=self)