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

Fix part of #19864 : Added feature to generate dummy suggestion questions #20248

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

HardikGoyal2003
Copy link
Contributor

Overview

  1. This PR fixes or fixes part of [Feature Request]: Add dummy review translation and review question option #19864
  2. This PR does the following:
    • Adds a feature to generate dummy suggestion question
    • Adds 'N' number of suggestion questions to specified skill.

Essential Checklist

Please follow the instructions for making a code change.

  • I have linked the issue that this PR fixes in the "Development" section of the sidebar.
  • I have checked the "Files Changed" tab and confirmed that the changes are what I want to make.
  • I have written tests for my code.
  • The PR title starts with "Fix #bugnum: " or "Fix part of #bugnum: ...", followed by a short, clear summary of the changes.
  • I have assigned the correct reviewers to this PR (or will leave a comment with the phrase "@{{reviewer_username}} PTAL" if I can't assign them directly).

Proof that changes are correct

Screencast.from.28-04-24.08.16.18.PM.IST.webm

PR Pointers

@HardikGoyal2003 HardikGoyal2003 requested review from a team as code owners May 1, 2024 21:49
Copy link

oppiabot bot commented May 1, 2024

Hi @vojtechjelinek, @DubeySandeep, @kevintab95, PTAL at this PR, it adds a new cron job.
Also @HardikGoyal2003 It seems you have added or edited a CRON job, if so please request a testing of this CRON job with this server jobs form Please refer to this guide for details.
Thanks!

@oppiabot oppiabot bot added the PR: Affects datastore layer Labels to indicate a PR that changes the datastore layer. label May 1, 2024
Copy link

oppiabot bot commented May 1, 2024

Assigning @nikitaevg for the first pass review of this PR. Thanks!

@@ -169,6 +170,8 @@ class AdminHandlerNormalizePayloadDict(TypedDict):
collection_id: Optional[str]
num_dummy_exps_to_generate: Optional[int]
num_dummy_exps_to_publish: Optional[int]
num_dummy_suggestion_ques_generate: Optional[int]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use short versions of words which are not widely acceptable. Here, ques is questions? No need to use ques.

I understand you might want to continue using num as in the fields above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

skill_summaries = skill_services.get_all_skill_summaries()
skill_summary_dicts = [
summary.to_dict() for summary in skill_summaries]
logging.error(skill_summary_dicts)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please re-read your PRs before sending them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Exception. User does not have enough rights to generate data.
"""
assert self.user_id is not None
if constants.DEV_MODE:
Copy link
Contributor

Choose a reason for hiding this comment

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

It's usually a very well serving pattern - handle corner cases first and common cases later.

Here

if not constants.DEV_MODE:
  raise...
<main_code>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nikitaevg In the whole file it is written like this so I thought it is the appropriate method, so now do I need to change mine code as well as other part of file?

'<p>This is a hint.</p>')),
]
# Ruling out the possibility of None for mypy type checking,
# because we above we are already updating the value
Copy link
Contributor

Choose a reason for hiding this comment

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

typo, please proofread PRs

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this comment and one below - try to make comments concise. Comments should point out something extraordinary, and the longer the comment the more attention it attracts. These two comments are not very important, try to make it 1, at most 2 lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

state.interaction.default_outcome.labelled_as_correct = True
state.interaction.default_outcome.dest = None
suggestion_change: Dict[
str, Union[str, float, question_domain.QuestionDict]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use AcceptableChangeDictTypes instead of the Union?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nikitaevg Yeah, I had a doubt about this. If we change Union[str, float, question_domain.QuestionDict] to change_domain.AcceptableChangeDictTypes, how will we know the exact data type we are receiving? Using change_domain.AcceptableChangeDictTypes doesn't make the code very generic. Currently, we know that we will only receive str, float, or question_domain.QuestionDict, but using AcceptableChangeDictTypes will not define that. Am I missing something about it?

Comment on lines +1375 to +1378
(
suggestion_services
.update_question_contribution_stats_at_submission(
suggestion))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you add parenthesis around this expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added parenthesis because this was exceeding max line character limit, so to distribute it into 2 lines.

@@ -420,7 +420,7 @@ class ClassifierDict(TypedDict):
# customization argument choices.
INVALID_CONTENT_ID = 'invalid_content_id'
# The default content text for the initial state of an exploration.
DEFAULT_INIT_STATE_CONTENT_STR = ''
DEFAULT_STATE_CONTENT_STR = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Please refrain from adding more changes to the PRs that are already not small. You complicate reviewers' life by adding more changes. Keep this, but in the future for any PR with >300 LOCs add only changes that are needed for this feature, you can refactor in the follow up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, from next time onwards I will remember that!

@@ -1226,6 +1270,115 @@ def _generate_dummy_classroom(self) -> None:
else:
raise Exception('Cannot generate dummy classroom in production.')

def _generate_dummy_suggestion_questions(
Copy link
Contributor

Choose a reason for hiding this comment

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

No tests, huh?

Copy link

oppiabot bot commented May 2, 2024

Unassigning @nikitaevg since the review is done.

@oppiabot oppiabot bot unassigned nikitaevg May 2, 2024
Copy link

oppiabot bot commented May 2, 2024

Hi @HardikGoyal2003, it looks like some changes were requested on this pull request by @nikitaevg. PTAL. Thanks!

Copy link
Contributor

@StephenYu2018 StephenYu2018 left a comment

Choose a reason for hiding this comment

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

Several concerns.

core/controllers/admin.py Outdated Show resolved Hide resolved
core/controllers/admin.py Outdated Show resolved Hide resolved
core/controllers/admin.py Outdated Show resolved Hide resolved
or not user_services.can_submit_question_suggestions(
self.user_id)):
raise Exception(
'User does not have enough rights to generate data.')
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename error message to User "${self.username}" must be a question submitter or question admin in order to generate question suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, my bad. Can you replace the JS string interpolation syntax in my suggestion with Python's string interpolation (either with % operator or f-strings)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't think that the syntax is correct. I think it should be:

                raise Exception((
                    'User "%s" must be a question submitter or question admin'
                    ' in order to generate question suggestions.'
                ) % self.username)

Also, do you have a backend test written that covers this part of the code? If you do have one, then running that test would also catch any syntax errors with this part of the code.

@DubeySandeep DubeySandeep removed their assignment May 6, 2024
Copy link

oppiabot bot commented May 11, 2024

Hi @HardikGoyal2003, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 4 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale label May 11, 2024
@oppiabot oppiabot bot closed this May 15, 2024
@AFZL210 AFZL210 reopened this May 18, 2024
@oppiabot oppiabot bot removed the stale label May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Affects datastore layer Labels to indicate a PR that changes the datastore layer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants