feat: update web Interface

This commit is contained in:
Yao Wang 2022-07-29 14:22:57 +02:00
parent d5d633b6c7
commit f9844dba10
1111 changed files with 171093 additions and 0 deletions

View file

@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Question
admin.site.register(Question)

View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class Qa1Config(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'qa1'

View file

@ -0,0 +1,27 @@
# Generated by Django 3.2.6 on 2021-08-16 20:18
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Question',
fields=[
('ID', models.IntegerField(primary_key=True, serialize=False)),
('QA_results', models.CharField(max_length=20000)),
('reco_results', models.CharField(max_length=20000)),
('timeing', models.CharField(max_length=20000)),
('surveyData', models.CharField(max_length=20000)),
('tasks', models.CharField(max_length=20000)),
('workerId', models.CharField(max_length=20000)),
('assId', models.CharField(max_length=20000)),
],
),
]

View file

@ -0,0 +1,16 @@
from django.db import models
class Question(models.Model):
ID = models.IntegerField(primary_key=True)
QA_results = models.CharField(max_length=20000)
reco_results = models.CharField(max_length=20000)
timeing = models.CharField(max_length=20000)
surveyData = models.CharField(max_length=20000)
tasks = models.CharField(max_length=20000)
workerId = models.CharField(max_length=20000)
assId = models.CharField(max_length=20000)
def __str__(self):
return self.ID

View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View file

@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]

View file

@ -0,0 +1,27 @@
from django.shortcuts import render
import simplejson
# Create your views here.
from django.http import HttpResponse
from .models import Question
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def index(request):
if request.method == 'POST':
print(request.POST)
req = simplejson.loads(request.body)
print(req)
QA_results = req['results']["outputs"]['qa_answers']
reco_results = req['results']["outputs"]["re_answers"]
timeing = req['results']["outputs"]["timing"]
surveyData = req['results']["outputs"]["surveyData"]
tasks = req['results']["outputs"]["tasks"]
workerId = req['workerId']
assId = req['assignmentId']
Question.objects.create(QA_results = QA_results, reco_results = reco_results, timeing = timeing, surveyData = surveyData, tasks = tasks, workerId = workerId, assId = assId)
return HttpResponse("receive")
else:
return HttpResponse("Hello, world. You're at the qa1 index.")