Skip to content

Commit

Permalink
feat: character image in short answer XBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturGaspar committed Nov 7, 2024
1 parent 9fa5d57 commit 4340876
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ai_eval/shortanswer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ class ShortAnswerAIEvalXBlock(AIEvalXBlock):
scope=Scope.settings,
)

character_image = String(
display_name=_("Character Image URL"),
help=_(
"URL for an image to be shown to the left of the chat box; "
"leave empty to disable"
),
scope=Scope.settings,
)

max_responses = Integer(
display_name=_("Max Responses"),
help=_("The maximum number of response messages the student can submit"),
Expand All @@ -47,6 +56,7 @@ class ShortAnswerAIEvalXBlock(AIEvalXBlock):
editable_fields = AIEvalXBlock.editable_fields + (
"max_responses",
"allow_reset",
"character_image",
)

def validate_field_data(self, validation, data):
Expand Down
9 changes: 9 additions & 0 deletions ai_eval/static/css/shortanswer.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
/* CSS for ShortAnswerAIEvalXBlock */

.shortanswer_image {
float: left;
margin-right: 4rem;
width: 30%;
}

.shortanswer_image + .shortanswer_block {
}

.shortanswer_block .count {
font-weight: bold;
}
Expand Down
6 changes: 6 additions & 0 deletions ai_eval/templates/shortanswer.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{% if self.character_image %}
<div class="shortanswer_image">
<img src="{{ self.character_image }}" />
</div>
{% endif %}

<div class="shortanswer_block">
<div>
<div id="question-text">
Expand Down

0 comments on commit 4340876

Please sign in to comment.