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

Odstrani razred ProblemText #79

Merged
merged 1 commit into from
Dec 12, 2022
Merged

Odstrani razred ProblemText #79

merged 1 commit into from
Dec 12, 2022

Conversation

matijapretnar
Copy link
Contributor

Kot smo se pogovarjali, je s to izbiro besedil za naloge sama zmeda, po #72 bo pa še večja. Trenutno se je npr. dalo pri treh nalogah uporabiti isto besedilo in če si ga popravil pri eni, se je spremenil tudi pri ostalih dveh.

V PR je enostavnejša rešitev, kjer ima vsak tip naloge privzeto besedilo, potem se ga pa lahko pri vsaki nalogi posebej povozi.


class Meta:
model = Generator
exclude = ["content_type", "document"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["text"].queryset = content_type.problemtext_set
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tega dela ne razumem čisto. Ali je to treba spremeniti zaradi izbrisa razreda ProblemText, ali je samo neodpravljena posledica pull requesta #71?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ne, to je po novem, saj smo odstranili atribut text, ki se je prej skliceval na razred ProblemText. Tega razreda in s tem polja ni več, zato ni treba povedati, kakšne izbire so na voljo zanj.


class ProblemForm(forms.ModelForm):
instruction = forms.CharField(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Če prav razumem, je ta razred nek boolean field, ki glede na to, ali imamo privzeto besedilo ali ne, pridobi ustrezne atribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ja, to je dodatni atribut, ki ga ni v modelu, ampak je samo v obrazcu in se nastavi glede na to, ali uporabnik klikne na izbiro (radio button) pri privzetem ali lastnem besedilu. Podatke pa shranimo tako, da sta instruction in solution pri privzetem besedilu prazna, pri lastnem besedilu pa ne.

@@ -54,14 +33,13 @@ class Problem(models.Model):
on_delete=models.PROTECT,
limit_choices_to=limit_content_type_choices,
)
text = models.ForeignKey(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ali je mogoče, da z izbrisom tega kaj ne bi ustrezno delalo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideja te spremembe je, da ne :) Torej namesto text, ki je svoj model, imamo dve običajni polji instruction in solution. Treba je bilo veliko prilagotiev, ampak se mi zdi, da zdaj dela, kot bi moralo.

@matijapretnar matijapretnar merged commit 867af62 into master Dec 12, 2022
This was referenced Dec 12, 2022
@matijapretnar matijapretnar deleted the pobrisi-problemtext branch March 24, 2023 09:35
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.

2 participants