RomanPolek / wad2_ae1

1 stars 0 forks source link

Please let me know when the backend is finished #15

Open RomanPolek opened 3 years ago

RomanPolek commented 3 years ago

Hey backend team, Please let me know as soon as the backend is finished. We have to then connect the backend frontend together and fix bugs together. Ill not be working on backend anymore as I see that you started to work on it. There's very little time left, that's why while you are working on it and frontend is waiting, Im gonna fork and work on a backup - in case the main branch doesnt work near the deadline, we can use the working finished backup branch.

We should definitely have a meeting and discuss the progress. Just let me know when u can today @mrkajetanp @2397741k

mrkajetanp commented 3 years ago

Well my part ie models & admin is done, Anna asked me not to touch the views so I didn't but if there's anything I need to do I'm happy to help. As for a meeting I'm currently coordinating a competition so I'm on a call pretty much until 9 pm today. I can still do project work if needed but I can't do a meeting before that.

RomanPolek commented 3 years ago

I feel like we are each doing our own part but aren't actually putting these parts together. It can end up that each of us will finish his/her part a few hours before deadline but the project will be buggy and unusable and not working. Therefore I would be glad if we had the meeting so we can talk about what needs to be done and put our parts together. Im totally fine if we have it after 9pm. I feel like its important to have this meeting. @deccygpm @2397741k is it okay if we have the meeting at 10pm?

deccygpm commented 3 years ago

Tonight at 10:00pm BST? That works for me.

RomanPolek commented 3 years ago

@2397741k is 10pm okay for you?

ann-kmnsk commented 3 years ago

I’m sorry but I’m not available for the meeting today at that time. Could we organise a meeting at 10:00am tomorrow?

I have added the formset. You can dynamically add or remove form from the frontend. I did some tests with user forms, they appear to be working. So you can use the forms in the html.

The backend still needs a few things to be working properly. I am aware of the "non-nullable field without default value" prompt. There are multiple ways to solve it. The easiest, not ideal route - deleting the migrations, second is using populaltion script and setting default user but that is not ready. The solution is actually outlined in the book page 97-100.

RomanPolek commented 3 years ago

As other ppl are available for 10pm, I would still like to hold a meeting today with others, maybe a shorter one. And tomorrow we could have a full meeting with you. I think at this final stage communication between frontend and backend is really important. Frontend is currently using a really different system for forms than backend and we would need to somehow merge it together and discuss a lot of things

mrkajetanp commented 3 years ago

Sure, we can do both meetings, sounds okay. Could someone explain to me why they removed the User model and only replaced the most basic functionality with Profile while cutting out everything connecting courses with teachers & students, exams with questions and breaking half the admin functionality in the process without even @ing me in the commit?

RomanPolek commented 3 years ago

that was me. I think i put it into some issue like a week ago So basically the backend didnt work with the User. In django there's a default class User. Overloading it is moderately complicated so I decided for this project its not necessary. Another method how to add some fields to User is through OneToOne relationship - what u see now in admin. Basically every user has a Profile class tied to it containing now only role (but can have more) Profile updates seamlessly with users so you will not even notice its there. I changed all the references in backend of .role into .profile.role Like the branch backup works and so far there's no bugs present. We can definitely discuss this on the meeting

RomanPolek commented 3 years ago

https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html

mrkajetanp commented 3 years ago

Hm yeah that's true, the backup branch definitely works better than master right now. I can see that the main fields for some reason missing from master are there so it's not too bad I guess. The User Profile thing was a good call for sure.

mrkajetanp commented 3 years ago

@RomanPolek Yesterday I added an additional role, 'None' as the default role so that superusers aren't lumped in with Students anymore. It seems to have fixed the issues around it and doesn't affect user registration as the form only has the Student/Teacher choice anyway. As far as I can tell it didn't break anything but if you have some code somewhere that relies on Student being the default role, let me know / take a look at it!

Also, is there anything specific you need me to fix/implement?

RomanPolek commented 3 years ago

Thanks, It did not break anything. Could you please look at a way to implement edit / remove exam? I imagine in a teachers view of /exams/ page, each exam would have 3 buttons - view edit and delete. Then I would just reuse the template for add exam, but fill it with existing exam data and change other bits and it should work. So could you please have a look at this? Dont worry about the button positioning / style too much, just so the functionality is there. Ill then make the buttons neater in the frontend. Thanks. While doing this please try to use existing functions. get_courses() will get all available courses for the person - performs checks. get_exams(courses) will get all available exams. error displays errors etc.

Here I imagine the buttons 3 would be only for teacher. Student will have 1 button - Start as there is alrdy: image image

mrkajetanp commented 3 years ago

Some other things we need to fix / implement that I found along the way:

RomanPolek commented 3 years ago

1) Ill fix this 2) Somebody please look into this, but at this point i dont think we have time to implement this 3) Im working on it rn 4) I tried to fix it, idk why it still shows this warning. This is low priority fix - we dont use timezones anyways 5) Ill fix this Thanks

RomanPolek commented 3 years ago

I alrdy fixed 1., 5. Ill continue working on submitting the exam / calculating statistics / displaying mistakes to students etc..

mrkajetanp commented 3 years ago

When adding a exam through the front end, the form doesn't let you add a question with any of the 5 answers missing. That should definitely be fixed.

Teachers can't view the exams that are not currently open, I'm pretty sure it's due to the check in the render call at the beginning of exams view.

RomanPolek commented 3 years ago

1) yep for now not. This is medium priority. I wanna finish firstly so that user needs to put every answer cuz its easier then if we have time ill change it

2) Its due to the get_exams which checks for deadline. U can add a parameter to the function which overrides this check or sth

mrkajetanp commented 3 years ago

@RomanPolek If you look at exams.html, for some reason changing anything about the "a" tags there completely breaks the formatting of specific exams showing up in exams view. To make specific buttons do different things I had to wrap just them in "a"s but that had really weird effects on positioning of things. I market the relevant parts with "BUG" in html comments, could you take a look?

RomanPolek commented 3 years ago

ye i know about this. The exam containers are kinda buggy. ill polish them as soon as u finish. Dont worry about the frontend too much because ill be changing it slightly anyways

RomanPolek commented 3 years ago

OK i made a big commit. I added the submissions etc. all around submitting exams. It shows u which answers wrong, score, preview of past exams...

mrkajetanp commented 3 years ago

That's great! I've got editing exams mostly worked out, I'll commit it soonish after I eat dinner

RomanPolek commented 3 years ago

perfect. and ill also soon commit the statistics thing for class

RomanPolek commented 3 years ago

@mrkajetanp Anna wanted to move the meeting to 10:00. She needs more time to finish. So the meeting will be at 10 then. Therefore we also have time to polish everything

mrkajetanp commented 3 years ago

@RomanPolek All right, both removing and editing exams now works, what do you need me to do next?

RomanPolek commented 3 years ago

Great job! Now in the view exams I calculate the percentage etc.. create new submission I think it would be better if we calculated this directly in the model and when exam is updated it will automatically update all the submissions. Imagine a teacher publishes some exam, but then finds out one question is bad so she edits it out - after some ppl alrdy finished. As soon as she removes the question from the exam all the submissions linked to the exam will update. I would put some method directly inside the submission model e.g. recalculate, which would calculate the scores max scores, percentages.. again. I think the Answer class will get deleted by CASCADE when the question is deleted

RomanPolek commented 3 years ago

Also we need to handle what if teacher deletes the exam - then all the submission will prolly need to be deleted too

RomanPolek commented 3 years ago

this might help u. Its a receiver that listens for updates of User. So we can do the same with Exam and Submissions image

mrkajetanp commented 3 years ago

Seems like the main thing we're missing here besides that is letting teachers see their students' exam results when they click 'view' on an exam, should I just do that first?

RomanPolek commented 3 years ago

yep sure thats a great idea. Actually I can do this, because I already have everything nicely setup for this. It will be easy for me

RomanPolek commented 3 years ago

So u can start work on the first thing im gonna now do the thing u said

mrkajetanp commented 3 years ago

All right all right

mrkajetanp commented 3 years ago

Also we need to handle what if teacher deletes the exam - then all the submission will prolly need to be deleted too

Submissions already delete themselves if the exam gets removed due to cascading, I just tested it so we've got that covered

RomanPolek commented 3 years ago

ye i mean mainly calculate percentage, score, max_score vars in Submission Cuz if u remove question and Answer, percentage, score max_score changes

RomanPolek commented 3 years ago

btw great job on the Edit exam button. Works flawlessly and looks amazing

RomanPolek commented 3 years ago

image

mrkajetanp commented 3 years ago

Thanks! I had to write some slightly weird JS but if it works it works I suppose

RomanPolek commented 3 years ago

i updated backend so get_exams() function returns all exams for teachers (also before and past deadline)

RomanPolek commented 3 years ago

and finished the viewing of students exams by teacher

mrkajetanp commented 3 years ago

That's great! I'll have updating the submissions working pretty soon, already got most of it

RomanPolek commented 3 years ago

im working on the statistics container now. should be finished before meeting

RomanPolek commented 3 years ago

teachers will have modified statistics container where they will also see each person in this course

RomanPolek commented 3 years ago

it would be wise to have a remove button next to each person. so teachers can remove ppl from course

mrkajetanp commented 3 years ago

The submissions now update after their exam gets edited. I've noticed a backend issue that doesn't affect the usability in any way, namely, because questions are connected to exams with a many-to-many field they don't get deleted along with the exam leading to old questions being left in the db for no reason. Replacing it with a foreign key relationship should fix it, should I try doing that?

RomanPolek commented 3 years ago

https://stackoverflow.com/questions/3937194/django-cascade-deletion-in-manytomanyrelation

RomanPolek commented 3 years ago

image

RomanPolek commented 3 years ago

i personally think M2M is ok. We can do a receiver that will delete like this. Also foreign keys would work but i think M2M fits a bit better if we can solve that issue with this solution

mrkajetanp commented 3 years ago

Oh that's even better, thanks! I'll implement it then

mrkajetanp commented 3 years ago

@RomanPolek I'm not sure if it's just my machine or not but in add_course the Description field seems to be a bit too wide and sticking outside the containing rectangle, could you take a look at it?

mrkajetanp commented 3 years ago

@RomanPolek If you try doing an exam as a student the page still seems to highlight the correct answer which is obviously a problem, would you be okay fixing that?

RomanPolek commented 3 years ago

solved