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

Add CLI flags to output well-formatted optional question attributes. #123

Merged

Conversation

realistschuckle
Copy link
Contributor

@realistschuckle realistschuckle commented Feb 29, 2024

NOTE: This change is backward compatible with the current learn interface.

What was done

This commit adds three new flags to the learn md command:

  • --with-explanation/-e (bool) which creates explanation attributes for correct and incorrect responses
  • --with-rubric/-r (bool) which creates rubric attributes
  • --with-hints/-n (int) which creates the indicated number of hint attributes

Without the minimal flag, the comments are preserved in the question as it previously worked. If a user specifies one of the above flags, then the corresponding comment is removed from the final output.

How was it tested

64 new unit tests for the new functionality exist in the app/cmd/challenge_attributes_test.go file. All tests pass.

Built and tested with

  • go1.20.14
  • go1.21.7
  • go1.22.0

Example output

Here is running it in maximal mode with all of the new options.

$ ./glearn-cli md mc -e -r -n 1 -o
<!-- >>>>>>>>>>>>>>>>>>>>>> BEGIN CHALLENGE >>>>>>>>>>>>>>>>>>>>>> -->
<!-- Replace everything in square brackets [] and remove brackets  -->

### !challenge

* type: multiple-choice
* id: 8080855d-1bb3-4aea-88e2-507d0680ae89
* title: [text, a short question title]
<!-- * points: [1] (optional, the number of points for scoring as a checkpoint) -->
<!-- * topics: [python, pandas] (Checkpoints only. optional the topics for analyzing points) -->

##### !question

[markdown, your question]

##### !end-question

##### !options

a| [Option 1]
b| [Option 2]
c| [Option 3, etc]

##### !end-options

##### !answer

b|

##### !end-answer

##### !hint

[Put a single hint, here. Add more hint blocks as needed.]

##### !end-hint

##### !rubric

[Put your rubric here specifying how to allocate points for the challenge]

##### !end-rubric

##### !explanation-correct:

[Put the explanation for the CORRECT response, here.]

##### !end-explanation

##### !explanation-incorrect:

[Put the explanation for the INCORRECT response, here.]

##### !end-explanation

### !end-challenge

<!-- ======================= END CHALLENGE ======================= -->

Here is running it in maximal mode with just one option. Note the preserved comments from the normal maximal output.

$ ./glearn-cli md mc -e -o
<!-- >>>>>>>>>>>>>>>>>>>>>> BEGIN CHALLENGE >>>>>>>>>>>>>>>>>>>>>> -->
<!-- Replace everything in square brackets [] and remove brackets  -->

### !challenge

* type: multiple-choice
* id: 884d5d81-3c84-4dd6-8ce1-5a17cd5664cd
* title: [text, a short question title]
<!-- * points: [1] (optional, the number of points for scoring as a checkpoint) -->
<!-- * topics: [python, pandas] (Checkpoints only. optional the topics for analyzing points) -->

##### !question

[markdown, your question]

##### !end-question

##### !options

a| [Option 1]
b| [Option 2]
c| [Option 3, etc]

##### !end-options

##### !answer

b|

##### !end-answer

<!-- other optional sections -->
<!-- !hint - !end-hint (markdown, hidden, students click to view) -->
<!-- !rubric - !end-rubric (markdown, instructors can see while scoring a checkpoint) -->

##### !explanation-correct:

[Put the explanation for the CORRECT response, here.]

##### !end-explanation

##### !explanation-incorrect:

[Put the explanation for the INCORRECT response, here.]

##### !end-explanation

### !end-challenge

<!-- ======================= END CHALLENGE ======================= -->

Finally, here's what it looks like in minimal mode.

./glearn-cli md mc -e -o -n 1 -r -m
<!-- >>>>>>>>>>>>>>>>>>>>>> BEGIN CHALLENGE >>>>>>>>>>>>>>>>>>>>>> -->

### !challenge

* type: multiple-choice
* id: 32adc0ad-5751-44bc-9ef0-64835e97a4f0
* title:

##### !question



##### !end-question

##### !options

a|
b|
c|

##### !end-options

##### !answer

a|

##### !end-answer

##### !hint

##### !end-hint

##### !rubric

##### !end-rubric

##### !explanation-correct:

##### !end-explanation

##### !explanation-incorrect:

##### !end-explanation

### !end-challenge

<!-- ======================= END CHALLENGE ======================= -->

This change is backward compatible with the current learn interface.

This commit adds three new flags to the `learn md` command:

- `--with-explanation/-e` (bool)  which creates explanation attributes
  for correct and incorrect responses
- `--with-rubric/-r` (bool) which creates rubric attributes
- `--with-hints/-n` (int) which creates the indicated number of hint
  attributes

Without the minimal flag, the comments are preserved in the question
as it previously worked. If a user specifies one of the above flags,
then the corresponding comment is removed from the final output.
@realistschuckle realistschuckle marked this pull request as draft February 29, 2024 21:27
@realistschuckle realistschuckle marked this pull request as ready for review February 29, 2024 21:28
@realistschuckle
Copy link
Contributor Author

@pgrunde @ToriK17 I can't add reviewers to this, so I'm just gonna tag y'all. 🧡

@pgrunde
Copy link
Collaborator

pgrunde commented Mar 1, 2024

I pulled down and QA'd, CI specs are passing.

  • New flags do nothing with non-question
  • New flags function independently from one another
  • New flag -n fails as expected when no integer is supplied
  • Integer properly denotes the number of expected hint blocks.
  • Absence of new flags results in a comment for the block as it was originally implemented.

@pgrunde pgrunde merged commit ef65ac2 into gSchool:master Mar 1, 2024
2 checks passed
@realistschuckle
Copy link
Contributor Author

Thank you, @pgrunde ! Hope you are well!

@realistschuckle realistschuckle deleted the add-optional-attributes-for-challenges branch March 6, 2024 16:56
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