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

Feature publish assignment #47

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

SamuelVch98
Copy link
Collaborator

Assignments can be published for everyone or just for teachers
Display assignments in the researcher/teacher view

@SamuelVch98 SamuelVch98 force-pushed the Feature-Publish-Assignment branch from bb9b4ca to 551ca6a Compare October 21, 2024 17:44
@SamuelVch98 SamuelVch98 force-pushed the Feature-Publish-Assignment branch from 551ca6a to bafc49f Compare November 28, 2024 16:45
@anthonygego
Copy link
Member

Can you rebase ?

Copy link
Contributor

@AlexandreDoneux AlexandreDoneux left a comment

Choose a reason for hiding this comment

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

Changes are needed regarding the way draft and published assignments work.

Also use conditional fetching from DB and computing.

db.py Outdated
Comment on lines 151 to 155
publication_status = db.Column(
Enum(*PUBLICATION_STATUS, name='publication_status_enum'),
nullable=False,
default='Draft'
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why have a publication status inside the year table.

The assignements we consider up to date are the ones in the assignement_published table. When a draft is published all the assignements that were in the draft tables should be copied to the published table. So what is the use of publication_status ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I had a talk with Anthony. We aim to only keep the two assignment tables and remove the publication_status from the Year table. That way one can make changes on a published assignment and save it as draft, later publishing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

We just need to handle the case where we want the assignment to be visible only for teachers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How do we manage the case of publication for teachers only?

app.py Outdated Show resolved Hide resolved
app.py Outdated Show resolved Hide resolved
app.py Outdated
Comment on lines 62 to 63
researcher = db.session.query(Researcher).filter_by(user_id=user.id).first()
teacher = db.session.query(Teacher).filter_by(user_id=user.id).first() if user.is_teacher else None
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also handle these with conditionals. If the user is a teacher no need to check if they are a researcher. That way we have one less call to the database.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We hadn't discussed the fact that it was possible to be a teacher and a researcher at the same time?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll ask @anthony. But even if that is the case, we better do these calls in conditions. We could use the session to check the roles the user has.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If it's OK with @anthonygego, I can store this in the session

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We still have a problem differentiating between a global assignment and an assignment for teachers only.

app.py Outdated
researcher_current_course = []
researcher_evaluations = []

if teacher:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if teacher:
if user.is_teacher :
...
else :
researcher = db.session.query(Researcher).filter_by(user_id=user.id).first()
...

No need to go fetch the teacher in the database because you don't use it later. And you can check if the user is a researcher here in the condition as suggested in the comment above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm going to have to add an if condition in the else if the user is neither a teacher nor a researcher

Copy link
Contributor

Choose a reason for hiding this comment

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

That is a possibility. You can use an if/elif/else checking on the session flags for example

app.py Outdated Show resolved Hide resolved
templates/home.html Show resolved Hide resolved
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.

3 participants