Skip to content

Commit

Permalink
Adicionando filtro para telemetry data e visualização do código envia…
Browse files Browse the repository at this point in the history
…do pelo aluno
  • Loading branch information
BarbaraTieko committed Sep 4, 2023
1 parent 14f03b1 commit 46f937d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/app/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@

from .models import Student, Instructor, Course, CourseClass, Exercise, ExerciseTag, TelemetryData


class TelemetryDataAdmin(admin.ModelAdmin):
list_filter = ("author", "exercise")
readonly_fields = ('solution',)

admin.site.register(Student, UserAdmin)
admin.site.register(Instructor, UserAdmin)
admin.site.register(Course)
admin.site.register(CourseClass)
admin.site.register(Exercise)
admin.site.register(ExerciseTag)
admin.site.register(TelemetryData)
admin.site.register(TelemetryData, TelemetryDataAdmin)




14 changes: 14 additions & 0 deletions backend/app/core/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.db import models
from django.contrib.auth.models import AbstractUser, UserManager
from django.utils import timezone
from django.utils.html import format_html


class User(AbstractUser):
Expand Down Expand Up @@ -102,5 +103,18 @@ class TelemetryData(models.Model):
log = models.JSONField()
last = models.BooleanField(default=True)

def solution(self):
formatted = ''
for chave, valor in self.log.get('student_input', {}).items():
codigo = valor.replace("\n", "<br>")
codigo = codigo.replace(' ', '&nbsp;')
formatted += f'<h2>{chave}</h2>'
formatted += f'''
<p style="font-size:1rem;">{codigo}</p>
'''

return format_html(formatted)


def __str__(self) -> str:
return f"{self.exercise} -> {self.author.username} ({self.submission_date})"

0 comments on commit 46f937d

Please sign in to comment.