Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#302 save submission vs resultset #307

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docker-config/ws/init.sql
Expand Up @@ -221,6 +221,10 @@ CREATE TABLE `submission_testsystem` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

alter table submission_testsystem
add choice_best_result_fit text null;




DROP TABLE IF EXISTS `task`;
Expand Down
Expand Up @@ -29,7 +29,7 @@ class BaseChecker(val compile_production: Boolean) {
val checkername = "base"
private val LABEL_PASSED = "passed"
private val LABEL_EXITCODE = "exitcode"

private val LABEL_BEST_FIT = "choice_best_result_fit"
/** LABEL -v*/
val __option_v = "-v"
/** LABEL "/" */
Expand Down Expand Up @@ -220,7 +220,8 @@ class BaseChecker(val compile_production: Boolean) {
LABEL_EXITCODE -> exitcode.toString,
LABEL_TASKID -> task_id.toString,
LABEL_SUBMISSIONID -> submission_id.toString,
DATA -> output
DATA -> output,
LABEL_BEST_FIT -> ""
)))
} catch {
case e: Exception => {
Expand Down
Expand Up @@ -78,6 +78,7 @@ object SQLChecker extends App {
private val CHECK_ANSWER_TOPIC = SYSTEMIDTOPIC + "_check_answer"
private val TASK_REQUEST_TOPIC = SYSTEMIDTOPIC + "_new_task_request"
private val TASK_ANSWER_TOPIC = SYSTEMIDTOPIC + "_new_task_answer"
private val LABEL_BEST_FIT = "choice_best_result_fit"

private val appConfig = ConfigFactory.parseFile(new File(loadFactoryConfigPath()))
private val config = ConfigFactory.load(appConfig)
Expand Down Expand Up @@ -199,7 +200,7 @@ object SQLChecker extends App {
}
val task: SQLTask = new SQLTask(ULDIR + taskid, taskid)
var passed: Int = 0
val (msg, success) = task.runSubmission(userquery, userid)
val (msg, success, best_fit) = task.runSubmission(userquery, userid)
if (success){
passed = 1
}
Expand All @@ -209,7 +210,8 @@ object SQLChecker extends App {
"exitcode" -> "0",
"userid" -> userid,
LABEL_TASKID -> taskid,
"submissionid" -> submissionid
"submissionid" -> submissionid,
LABEL_BEST_FIT -> best_fit
)))
} catch {
case e: NoSuchElementException => {
Expand Down
Expand Up @@ -163,8 +163,8 @@ class SQLTask(val filepath: String, val taskId: String){
* @param userid userid
* @return tuple with message and boolean
*/
def runSubmission(userq: String, userid: String): (String, Boolean) = {
var msg = "Your Query didn't produce the correct result"
def runSubmission(userq: String, userid: String): (String, Boolean, String) = {
var msg = "Your Query didn't produce the correct result"; var fit = "No query did match"
var success = false; var identified = false; var foundindex = -1
val ustatement = connection.createStatement; ustatement.setQueryTimeout(timeoutsec)
val dbname = userid + us + dbliteral; val username = userid + us + taskid
Expand Down Expand Up @@ -205,9 +205,10 @@ class SQLTask(val filepath: String, val taskId: String){
s.execute(dropdb + taskid + us + dbname)
if(identified){
msg = queryres(foundindex).desc
fit = taskqueries(foundindex)("query")
if(msg.equals("OK")) success = true
}
(msg, success)
(msg, success, fit)
}

private def compareRow(userres: ResultSet, querynum: Int): Boolean = {
Expand Down
2 changes: 2 additions & 0 deletions web-gui/src/app/app-routing.module.ts
Expand Up @@ -23,6 +23,7 @@ import {ConnectedSystemsComponent} from "./components/connected-systems/connecte
import {ImportCourseComponent} from "./components/courses/import-course/import-course.component";
import {ChangePasswdComponent} from "./components/users/change-passwd/change-passwd.component";
import {GuestGuard} from "./guards/guest.guard";
import {CourseResultDetailsComponent} from "./components/courses/course-result-details/course-result-details.component";


const routes: Routes = [
Expand All @@ -37,6 +38,7 @@ const routes: Routes = [
{path: 'courses/search', component: SearchCourseComponent},
{path: 'courses/import', component: ImportCourseComponent, canActivate: [DocentGuard]},
{path: 'courses/:id', component: DetailCourseComponent},
{path: 'courses/:id/result', component: CourseResultDetailsComponent},

// Admin
{path: 'admin/dashboard', component: ProfDashboardComponent, canActivate: [AdminGuard]},
Expand Down
4 changes: 4 additions & 0 deletions web-gui/src/app/app.module.ts
Expand Up @@ -57,6 +57,8 @@ import { TaskResultComponent } from './components/courses/detail-course/task-res
import {MatSlideToggleModule} from "@angular/material";
import { ImportCourseComponent } from './components/courses/import-course/import-course.component';
import { ChangePasswdComponent } from './components/users/change-passwd/change-passwd.component';
import { CourseResultDetailsComponent } from './components/courses/course-result-details/course-result-details.component';
import { CourseResultDetailTableComponent } from './components/courses/course-result-detail-table/course-result-detail-table.component';


@Injectable()
Expand Down Expand Up @@ -115,6 +117,8 @@ export const httpInterceptorProviders = [
TaskResultComponent,
ImportCourseComponent,
ChangePasswdComponent,
CourseResultDetailsComponent,
CourseResultDetailTableComponent,
],
imports: [
BrowserModule,
Expand Down
@@ -0,0 +1,56 @@
<mat-expansion-panel class="e-panel">
<mat-expansion-panel-header>
<mat-panel-title>
Submission {{taskSubmission.submission_id}}
</mat-panel-title>
<mat-panel-description>
{{taskSubmission.filename || taskSubmission.submission_data}}
</mat-panel-description>
</mat-expansion-panel-header>

<div>

<table mat-table matSort [dataSource]="dataSource" class="mat-elevation-z8">

<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on the row definition" -->

<!-- Name Column -->
<ng-container matColumnDef="result">
<th mat-header-cell mat-sort-header *matHeaderCellDef>Result</th>
<td mat-cell *matCellDef="let eval"> {{eval.result}} </td>
</ng-container>

<!-- Weight Column -->
<ng-container matColumnDef="choice_best_result_fit">
<th mat-header-cell mat-sort-header *matHeaderCellDef>Choosen Result</th>
<td mat-cell *matCellDef="let eval"> {{eval.choice_best_result_fit}} </td>
</ng-container>

<!-- Symbol Column -->
<ng-container matColumnDef="result_date">
<th mat-header-cell mat-sort-header *matHeaderCellDef>Result Date</th>
<td mat-cell *matCellDef="let eval"> {{ parseDate(eval.result_date) | date: "yyyy-MM-dd" }} </td>
</ng-container>

<ng-container matColumnDef="testsystem_id">
<th mat-header-cell mat-sort-header *matHeaderCellDef>Testsystem</th>
<td mat-cell *matCellDef="let eval"> {{eval.testsystem_id}} </td>
</ng-container>

<ng-container matColumnDef="passed">
<th mat-header-cell mat-sort-header *matHeaderCellDef>Passed</th>
<td mat-cell *matCellDef="let eval"> {{eval.passed}} </td>
</ng-container>



<tr mat-header-row *matHeaderRowDef="columns"></tr>
<tr mat-row *matRowDef="let row; columns: columns;"></tr>
</table>



</div>

</mat-expansion-panel>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CourseResultDetailTableComponent } from './course-result-detail-table.component';

describe('CourseResultDetailTableComponent', () => {
let component: CourseResultDetailTableComponent;
let fixture: ComponentFixture<CourseResultDetailTableComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CourseResultDetailTableComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CourseResultDetailTableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,30 @@
import {Component, Input, OnInit} from '@angular/core';
import {MatTableDataSource} from "@angular/material/table";
import {CourseTaskEvaluation, TaskSubmission} from "../../../interfaces/HttpInterfaces";

@Component({
selector: 'app-course-result-detail-table',
templateUrl: './course-result-detail-table.component.html',
styleUrls: ['./course-result-detail-table.component.scss']
})
export class CourseResultDetailTableComponent implements OnInit {

@Input() taskSubmission: TaskSubmission;

constructor() { }

columns = ['result', 'choice_best_result_fit', 'result_date', 'testsystem_id', 'passed'];

dataSource = new MatTableDataSource<CourseTaskEvaluation>();


ngOnInit() {
this.dataSource.data = this.taskSubmission.evaluation
}

parseDate(datestring){
return new Date(datestring)
}


}
@@ -0,0 +1,39 @@
<div class="flex-container">

<h2>Submission Details</h2>


<form class="example-form">
<mat-form-field class="example-full-width" style="width: 100%;">
<input type="text" placeholder="Pick one user" aria-label="Number" matInput [formControl]="userControl" [matAutocomplete]="students">
<mat-autocomplete #students="matAutocomplete">
<mat-option *ngFor="let student of filteredOptions | async" [value]="student.username">
{{student.surname}}, {{student.prename}} ({{student.username}}) [{{student.user_id}}]
</mat-option>
</mat-autocomplete>
</mat-form-field>


<mat-form-field class="example-full-width" style="width: 100%;">
<input type="text" placeholder="Task ID" aria-label="Number" matInput [formControl]="taskControl" [matAutocomplete]="tasks">
<mat-autocomplete #tasks="matAutocomplete">
<mat-option *ngFor="let task of filteredTasks | async" [value]="task.task_id">
{{task.task_name}} ({{task.task_id}})
</mat-option>
</mat-autocomplete>
</mat-form-field>


<button mat-flat-button color="accent" (click)="showResultComparision()">Anzeigen</button>
</form>

<br>
<mat-divider></mat-divider>
<br>
<app-course-result-detail-table [taskSubmission]="eval" *ngFor="let eval of allSubmissions" ></app-course-result-detail-table>





</div>
@@ -0,0 +1,5 @@
.flex-container {
display: flex;
flex-direction: column;
align-items: center;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CourseResultDetailsComponent } from './course-result-details.component';

describe('CourseResultDetailsComponent', () => {
let component: CourseResultDetailsComponent;
let fixture: ComponentFixture<CourseResultDetailsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CourseResultDetailsComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CourseResultDetailsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});