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

(Contributor Recognition Infrastructure) Milestone2.4: Add certificate generation for contributors (including service method, API controller) #16513

Merged
merged 156 commits into from
Jan 27, 2023

Conversation

chris7716
Copy link
Contributor

@chris7716 chris7716 commented Nov 8, 2022

Overview

  1. This PR fixes or fixes part of n/a.
  2. This PR does the following: This PR adds the certificate generation in the contributor dashboard.3.

This branch is taken from the milestone2.2 branch so there are some optional files changed that is not related to this PR. You can review the below files which are only related to this PR.

core/controllers/*
core/domain/suggestion_services*
core/feconf.py
core/storage/suggestion/*
core/templates/pages/contributor-dashboard-page/contributor-stats/contributor-stats.component.spec.ts(Line 186 - 189)
core/templates/pages/contributor-dashboard-page/contributor-stats/contributor-stats.component.ts (Line 372 - 389)
core/templates/pages/contributor-dashboard-page/modal-templates/*
core/templates/pages/contributor-dashboard-page/services/*
main.py
requirements.in
requirements.txt

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

Proof that changes are correct

Screen.Recording.2022-12-07.at.08.57.09.mov

Proof of changes on desktop with slow/throttled network

Proof of changes on mobile phone

Proof of changes in Arabic language

PR Pointers

  • Make sure to follow the instructions for making a code change.
  • If you need a review or an answer to a question, and don't have permissions to assign people, leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL". Oppiabot will help assign that person for you.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays.
  • Never force push. If you do, your PR will be closed.
  • Some of the e2e tests are flaky, and can fail for reasons unrelated to your PR. We are working on fixing this, but in the meantime, if you need to restart the tests, please check the "If your build fails" wiki page.

@chris7716 chris7716 requested a review from a team as a code owner November 8, 2022 21:39
@chris7716 chris7716 requested a review from a team November 8, 2022 21:39
@oppiabot
Copy link

oppiabot bot commented Jan 17, 2023

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

@oppiabot
Copy link

oppiabot bot commented Jan 24, 2023

Hi @chris7716, 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 Jan 24, 2023
Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Took a pass.


if suggestion_type == feconf.SUGGESTION_TYPE_TRANSLATE_CONTENT:
language = self.normalized_request['language']
language = self.normalized_request.get('language')
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
language = self.normalized_request.get('language')
language = self.normalized_request['language']

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 think we will have to use the self.normalized_request.get('language') because when generating the question certificate, we do not include language param in the request and it throws KeyError: 'language' if we use self.normalized_request['language']

We can get the the default value which is set as None if we use self.normalized_request.get('language') when language is not included in the request.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right, sorry.

# Go to the below link for more information about how we count hours
# contributed.# Goto the below link for more information.
# https://docs.google.com/spreadsheets/d/1ykSNwPLZ5qTCkuO21VLdtm_2SjJ5QJ0z0PlVjjSB4ZQ/edit?usp=sharing
hours_contributed = round((words_count / 300), 2)
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
hours_contributed = round((words_count / 300), 2)
hours_contributed = round(words_count / 300, 2)

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

# Go to the below link for more information about how we count hours
# contributed.
# https://docs.google.com/spreadsheets/d/1ykSNwPLZ5qTCkuO21VLdtm_2SjJ5QJ0z0PlVjjSB4ZQ/edit?usp=sharing
hours_contributed = round((minutes_contributed / 60), 2)
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
hours_contributed = round((minutes_contributed / 60), 2)
hours_contributed = round(minutes_contributed / 60, 2)

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

createCertificate(response: ContributorCertificateResponse): void {
const canvas = document.createElement('canvas');
const currentDate = new Date();
const dateOptions: Intl.DateTimeFormatOptions = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain that in code comment?

// Textual parts are starting when y coordinate is equals to 350.
let linePosition = 350;
const image = new Image(this.LOGO_WIDTH, this.LOGO_HEIGHT);
image.src = '/assets/images/contributor_dashboard/oppia-logo.jpg';
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this path be placed into a constant?

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

@oppiabot
Copy link

oppiabot bot commented Jan 27, 2023

Unassigning @vojtechjelinek since the review is done.

@oppiabot
Copy link

oppiabot bot commented Jan 27, 2023

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

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM!


if suggestion_type == feconf.SUGGESTION_TYPE_TRANSLATE_CONTENT:
language = self.normalized_request['language']
language = self.normalized_request.get('language')
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right, sorry.

@oppiabot
Copy link

oppiabot bot commented Jan 27, 2023

Hi @chris7716, this PR is ready to be merged. Please address any remaining comments prior to merging, and feel free to merge this PR once the CI checks pass and you're happy with it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants