Skip to content

Commit

Permalink
kodegolf: show score on success.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajrakso committed Oct 12, 2024
1 parent 80e2552 commit d8a2fdf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nablapps/interactive/templates/interactive/code_golf.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h3>{{ task }}</h3>
</form>

<pre v-if="errors" class="alert alert-warning" id="error">[[ errors ]]</pre>
<div v-if="status=='correct'" class="alert alert-success">Riktig output!</div>
<div v-if="status=='correct'" class="alert alert-success">Riktig output! Din skår: [[ outputLength ]] tegn!</div>
<div v-if="longerThanBest" class="alert alert-warning">Koden din er lengre enn den beste du har sendt inn. Du kan sende den inn, men skåren din vil ikke endres.</div>
<pre v-if="output" class="alert alert-primary">
<h4 class="alert-heading">Output:</h4>
Expand All @@ -84,6 +84,7 @@ <h4 class="alert-heading">Output:</h4>
status: null, // One of "correct", "incorrect", "spinning"
user_code: null,
output: null,
outputLength: null,
longerThanBest: false
}
},
Expand Down Expand Up @@ -117,6 +118,7 @@ <h4 class="alert-heading">Output:</h4>
this.status = "correct"
this.errors = null
this.longerThanBest = outputLength > shortestSolution
this.outputLength = outputLength
} else {
this.status = "incorrect"
this.errors = "Output does not match correct output."
Expand Down
1 change: 1 addition & 0 deletions nablapps/interactive/views/code_golf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def get_context_data(self, **kwargs):
else:
best_result_length = best_result.length
context["best_attempt"] = best_result_length
context["logged_in"] = True if self.request.user.is_authenticated else False
return context

def form_valid(self, form):
Expand Down

0 comments on commit d8a2fdf

Please sign in to comment.