Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ When generating challenges with the `learn md` command, you can see explanations
* short answer
* number
* paragraph
* code snippet--js, py, java, sql (code directly in Learn)
* code snippet--js, py, java, go, sql (code directly in Learn)
* custom-snippet--write your own `Dockerfile` and `test.sh` to allow student code to run in a customized container
* project, testable project (code locally, submit a repo)

Expand Down
111 changes: 111 additions & 0 deletions app/cmd/markdown/questions/golang.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package questions

import (
"github.com/spf13/cobra"
)

func NewGoCommand(params NewQuestionCommandParams) *cobra.Command {
params.name = "Go"
params.abbr = "go"
params.maxTemplate = goTemplate
params.minTemplate = goTemplateMin
params.long = goLongDescription

return createQuestionCommand(params)
}

const goLongDescription = `Go Code Snippet Challenges allow a student to write Go code directly in
Learn. The submission is evaluated against unit tests that are set up as part
of the Challenge. The student then sees the standard output from the test
runner in Learn.

The test runner automatically wraps the submission in ` + "`package main`" + `, so the
placeholder and tests blocks should not declare a package — just write the
function, any imports, and the tests.`

const goTemplate = `<!-- >>>>>>>>>>>>>>>>>>>>>> BEGIN CHALLENGE >>>>>>>>>>>>>>>>>>>>>> -->
<!-- Replace everything in square brackets [] and remove brackets -->

### !challenge

* type: code-snippet
* language: golang
* id: %s
* title: [text, a short question title]
<!-- * points: [1] (optional, the number of points for scoring as a checkpoint) -->
<!-- * topics: [goroutines, channels] (Checkpoints only, optional the topics for analyzing points) -->
<!-- * test_file: [/path/to/file.txt] (External test file, replaces 'tests' section) -->

##### !question

[markdown, your question]

##### !end-question

##### !placeholder

[the code below is the starting code in the web editor]
~~~go
// DoSomething returns true
func DoSomething() bool {
// return true
return false
}
~~~

##### !end-placeholder

##### !tests

[the go tests below will run against the student submission]
~~~go
import (
"strings"
"testing"
)

func TestDoSomething(t *testing.T) {
if !DoSomething() {
t.Errorf("%s should return true", strings.ToLower("DoSomething"))
}
}
~~~

##### !end-tests

<optional-attributes>

### !end-challenge

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

const goTemplateMin = `<!-- >>>>>>>>>>>>>>>>>>>>>> BEGIN CHALLENGE >>>>>>>>>>>>>>>>>>>>>> -->

### !challenge

* type: code-snippet
* language: golang
* id: %s
* title:

##### !question



##### !end-question

##### !placeholder



##### !end-placeholder

##### !tests



##### !end-tests
<optional-attributes>
### !end-challenge

<!-- ======================= END CHALLENGE ======================= -->`
1 change: 1 addition & 0 deletions app/cmd/markdown/questions/questions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func getTestCases() []testCase {
return []testCase{
{"checkbox", "cb", NewCheckBoxCommand, checkboxTemplate, checkboxTemplateMin},
{"customsnippet", "cs", NewCustomSnippetCommand, customSnippetTemplate, customSnippetTemplateMin},
{"go", "go", NewGoCommand, goTemplate, goTemplateMin},
{"java", "ja", NewJavaCommand, javaTemplate, javaTemplateMin},
{"javascript", "js", NewJavaScriptCommand, javascriptTemplate, javascriptTemplateMin},
{"multiplechoice", "mc", NewMultipleChoiceCommand, multipleChoiceTemplate, multipleChoiceTemplateMin},
Expand Down
1 change: 1 addition & 0 deletions app/cmd/markdown/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func addQuestionCommands(c *cobra.Command) {
questions.NewPythonCommand,
questions.NewSqlCommand,
questions.NewRubyCommand,
questions.NewGoCommand,
questions.NewUploadCommand,
questions.NewCustomSnippetCommand,
questions.NewProjectCommand,
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Please set your API token with this command: learn set --api_token=<your_api_tok
You can get your api token at https://learn-2.galvanize.com/api_token`

// currentReleaseVersion is used to print the version the user currently has downloaded
const currentReleaseVersion = "v0.10.15"
const currentReleaseVersion = "v0.10.16"

// rootCmd is the base for all our commands. It currently just checks for all the
// necessary credentials and prompts the user to set them if they are not there.
Expand Down
Loading