forked from openedx/openedx-platform
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add cli command to generate report #277
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| """ | ||
| Contains the logic for generating a survey report. | ||
| """ | ||
|
|
||
| def generate_report() -> None: | ||
| """Generate a survey report for all courses in the system.""" | ||
|
Henrrypg marked this conversation as resolved.
Outdated
|
||
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions
21
openedx/features/survey_report/management/commands/generate_report.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """ | ||
| CLI command to generate survey report. | ||
| """ | ||
|
|
||
| from django.core.management.base import BaseCommand, CommandError | ||
| from openedx.features.survey_report.application import generate_report | ||
|
|
||
| class Command(BaseCommand): | ||
| """ | ||
| Command to generate survey report. | ||
| """ | ||
|
|
||
| help = 'This command will generate survey report.' | ||
|
|
||
| def handle(self, *args, **options): | ||
| try: | ||
| generate_report() | ||
| except Exception as error: | ||
| raise CommandError('An error has ocurred while report was generating.') from error | ||
|
|
||
| self.stdout.write(self.style.SUCCESS('Survey report has been generated successfully.')) |
Empty file.
13 changes: 13 additions & 0 deletions
13
openedx/features/survey_report/management/commands/tests/test_generate_report.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Test for generate_report command. | ||
| """ | ||
|
|
||
| from io import StringIO | ||
| from django.core.management import call_command | ||
| from django.test import TestCase | ||
|
|
||
| class GenerateReportTest(TestCase): | ||
| def test_command_output(self): | ||
| out = StringIO() | ||
| call_command('generate_report', stdout=out) | ||
| self.assertIn('Survey report has been generated successfully.', out.getvalue()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.