Skip to content

Commit

Permalink
Merge pull request #361 from fujaba/fix/remove-scenario-solutions
Browse files Browse the repository at this point in the history
Remove fulibScenarios Solutions from Assignments
  • Loading branch information
Clashsoft authored Sep 24, 2023
2 parents 3a41b81 + f7f8e5b commit 717f3d4
Show file tree
Hide file tree
Showing 41 changed files with 148 additions and 513 deletions.
26 changes: 13 additions & 13 deletions frontend/src/app/assignment/model/assignment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import Task from './task';

export interface ClassroomInfo {
org?: string;
prefix?: string;
token?: string;
webhook?: string;
codeSearch?: boolean;
mossId?: number;
mossLanguage?: string;
mossResult?: string;
openaiApiKey?: string;
}

export default class Assignment {
_id: string;
archived?: boolean;
Expand All @@ -13,21 +25,9 @@ export default class Assignment {
issuance?: Date | string;
deadline?: Date | string;

classroom?: {
org?: string;
prefix?: string;
token?: string;
webhook?: string;
codeSearch?: boolean;
mossId?: number;
mossLanguage?: string;
mossResult?: string;
openaiApiKey?: string;
};
classroom?: ClassroomInfo;

tasks: Task[];
solution: string;
templateSolution: string;
}

export type CreateAssignmentDto = Omit<Assignment, '_id' | 'token' | 'createdBy'>;
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/assignment/model/solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default class Solution {

createdBy?: string;
author: AuthorInfo;
solution: string;
commit?: string;
consent?: Consent;

Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/assignment/model/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export default class Task {
description: string;
points: number;
note?: string;
verification: string;
glob?: string;
children: Task[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {SubmitModalComponent} from './submit-modal/submit-modal.component';
import {AssignmentTasksComponent} from './tasks/tasks.component';

export const assignmentChildRoutes = [
{path: 'tasks', component: AssignmentTasksComponent, data: {title: 'Tasks & Sample Solution'}},
{path: 'tasks', component: AssignmentTasksComponent, data: {title: 'Tasks'}},
{path: 'share', component: ShareComponent, data: {title: 'Sharing'}},
{
path: 'solutions',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
<div class="container">
<div class="row">
<div class="col-md-6" *ngIf="$any(assignment)?.solution as solution">
<div class="position-sticky" style="top: 4rem">
<div class="mb-3">
<label class="form-label" for="solutionInput">Sample Solution</label>
<app-scenario-codemirror
id="solutionInput"
[content]="solution"
[readOnly]="true"
></app-scenario-codemirror>
</div>
</div>
</div>
<div class="col-12" [class.col-md-6]="$any(assignment)?.solution">
Tasks
<app-task-list [tasks]="assignment?.tasks"></app-task-list>
</div>
</div>
<app-task-list [tasks]="assignment?.tasks"></app-task-list>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<div class="input-group">
<span class="input-group-text">https://github.com/</span>
<input type="text" class="form-control" id="classroomOrgInput" placeholder="my-awesome-org"
[(ngModel)]="assignment.classroom!.org" (change)="saveDraft()">
[(ngModel)]="classroom.org" (change)="context.saveDraft()">
<span class="input-group-text">/</span>
<input type="text" class="form-control" id="classroomPrefixInput" placeholder="prefix"
[(ngModel)]="assignment.classroom!.prefix" (change)="saveDraft()">
[(ngModel)]="classroom.prefix" (change)="context.saveDraft()">
<span class="input-group-text">-Student</span>
</div>
<div class="form-text">
Expand All @@ -24,19 +24,19 @@
<app-masked-input
id="tokenInput"
type="password"
[(value)]="assignment.classroom!.token"
[(value)]="classroom.token"
placeholder="ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
></app-masked-input>
<div class="form-text">
Required for importing solutions from GitHub Classroom.
You can generate a token in the
<a
href="https://github.com/settings/tokens/new?description={{encodeURIComponent(assignment.title)}}&scopes=repo"
href="https://github.com/settings/tokens/new?description={{encodeURIComponent(context.assignment.title)}}&scopes=repo"
target="_blank">
GitHub Settings
</a>.
Make sure your account has access to the
<b>{{ assignment.classroom!.org }}</b>
<b>{{ classroom.org }}</b>
organisation and select the
<code>repo</code>
scope.
Expand All @@ -47,7 +47,7 @@
<app-masked-input
id="webhookInput"
type="url"
[(value)]="assignment.classroom!.webhook"
[(value)]="classroom.webhook"
placeholder="https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXX"
></app-masked-input>
<div class="form-text">
Expand All @@ -56,58 +56,4 @@
or an error in case of a problem.
</div>
</div>
<div class="mb-3">
<label class="form-label" for="codeSearchCheck">Code Search</label>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="codeSearchCheck"
[(ngModel)]="assignment.classroom!.codeSearch" (change)="saveDraft()">
<label class="form-check-label" for="codeSearchCheck">Enable Code Search</label>
</div>
<div class="form-text">
Code Search will import the source code from Classroom repositories and index it.
It can be used to find code duplicates across submissions and allows grading multiple students at the same time.
</div>
</div>
<div class="mb-3" *ngIf="assignment.classroom!.codeSearch">
<label class="form-label" for="openaiApiKeyInput">OpenAI API Key</label>
<app-masked-input
id="openaiApiKeyInput"
type="text"
[(value)]="assignment.classroom!.openaiApiKey"
placeholder="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
></app-masked-input>
<div class="form-text">
Your OpenAI API key for advanced Code Search. Generate one in the
<a href="https://platform.openai.com/account/api-keys" target="_blank">OpenAI API Keys</a>.
</div>
</div>
<div class="mb-3">
<label class="form-label" for="mossCheck">Plagiarism Detection</label>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="mossCheck" [(ngModel)]="showMoss">
<label class="form-check-label" for="mossCheck">Enable Moss Integration</label>
</div>
<div class="form-text">
Use
<a href="https://theory.stanford.edu/~aiken/moss/" target="_blank">Moss</a>
to detect code duplicates across submissions.
</div>
</div>
<div class="mb-3" *ngIf="showMoss">
<label class="form-label" for="mossIdInput">Moss User ID</label>
<input type="number" class="form-control" id="mossIdInput" placeholder="123456789"
[(ngModel)]="assignment.classroom!.mossId" (change)="saveDraft()">
<div class="form-text">
Your Moss User ID. See "Registering for Moss" in the Moss documentation to obtain it.
</div>
</div>
<div class="mb-3" *ngIf="showMoss">
<label class="form-label" for="mossIdInput">Moss Language</label>
<select class="form-control" id="mossLanguageInput" [(ngModel)]="assignment.classroom!.mossLanguage" (change)="saveDraft()">
<option *ngFor="let lang of mossLanguages | keyvalue" [value]="lang.key">{{ lang.value }}</option>
</select>
<div class="form-text">
Language to use for Moss duplicate analysis.
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component} from '@angular/core';
import {CreateAssignmentDto} from '../../../model/assignment';
import {ClassroomInfo} from '../../../model/assignment';
import {AssignmentContext} from '../../../services/assignment.context';

@Component({
Expand All @@ -8,26 +8,13 @@ import {AssignmentContext} from '../../../services/assignment.context';
styleUrls: ['./classroom.component.scss'],
})
export class ClassroomComponent {
assignment: CreateAssignmentDto;
showMoss = false;
saveDraft: () => void;
classroom: ClassroomInfo;

encodeURIComponent = encodeURIComponent;
mossLanguages = {
java: 'Java',
javascript: 'JavaScript',
python: 'Python',
c: 'C',
cc: 'C++',
csharp: 'C#',
};

constructor(
context: AssignmentContext,
readonly context: AssignmentContext,
) {
this.assignment = context.assignment;
this.assignment.classroom ||= {};
this.showMoss = !!this.assignment.classroom.mossId;
this.saveDraft = context.saveDraft;
this.classroom = context.assignment.classroom ||= {};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="mb-3">
<label class="form-label" for="codeSearchCheck">Code Search</label>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="codeSearchCheck"
[(ngModel)]="classroom.codeSearch" (change)="context.saveDraft()">
<label class="form-check-label" for="codeSearchCheck">Enable Code Search</label>
</div>
<div class="form-text">
Code Search will import the source code from Classroom repositories and index it.
It can be used to find code duplicates across submissions and allows grading multiple students at the same time.
</div>
</div>
<div class="mb-3" *ngIf="classroom.codeSearch">
<label class="form-label" for="openaiApiKeyInput">OpenAI API Key</label>
<app-masked-input
id="openaiApiKeyInput"
type="password"
[(value)]="classroom.openaiApiKey"
(change)="context.saveDraft()"
placeholder="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
></app-masked-input>
<div class="form-text">
Your OpenAI API key for advanced Code Search. Generate one in the
<a href="https://platform.openai.com/account/api-keys" target="_blank">OpenAI API Keys</a>.
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {Component} from '@angular/core';
import {AssignmentContext} from "../../../services/assignment.context";
import {ClassroomInfo} from "../../../model/assignment";

@Component({
selector: 'app-code-search',
templateUrl: './code-search.component.html',
styleUrls: ['./code-search.component.scss']
})
export class CodeSearchComponent {
classroom: ClassroomInfo;

constructor(
readonly context: AssignmentContext,
) {
this.classroom = this.context.assignment.classroom ||= {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import {EditAssignmentComponent} from './edit-assignment/edit-assignment.compone
import {EditTaskModalComponent} from './edit-task-modal/edit-task-modal.component';
import {InfoComponent} from './info/info.component';
import {PreviewComponent} from './preview/preview.component';
import {SampleComponent} from './sample/sample.component';
import {TasksComponent} from './tasks/tasks.component';
import {TemplateComponent} from './template/template.component';
import {PlagiarismDetectionComponent} from "./plagiarism-detection/plagiarism-detection.component";
import {CodeSearchComponent} from "./code-search/code-search.component";

export const editAssignmentChildRoutes: Routes = [
{path: 'info', component: InfoComponent, data: {title: 'Info'}},
{path: 'classroom', component: ClassroomComponent, data: {icon: 'github', title: 'Classroom'}},
{
path: 'tasks',
component: TasksComponent,
Expand All @@ -20,15 +19,9 @@ export const editAssignmentChildRoutes: Routes = [
{path: ':task', component: EditTaskModalComponent},
],
},
{path: 'template', component: TemplateComponent, data: {title: 'Template'}},
{
path: 'sample',
component: SampleComponent,
data: {title: 'Sample'},
children: [
{path: ':task', component: EditTaskModalComponent},
],
},
{path: 'classroom', component: ClassroomComponent, data: {icon: 'bi-github', title: 'Classroom'}},
{path: 'code-search', component: CodeSearchComponent, data: {icon: 'bi-robot', title: 'Code Search'}},
{path: 'plagiarism-detection', component: PlagiarismDetectionComponent, data: {icon: 'bi-incognito', title: 'Plagiarism Detection'}},
{path: 'preview', component: PreviewComponent, data: {title: 'Preview'}},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {EditTaskListComponent} from './edit-task-list/edit-task-list.component';
import {EditTaskModalComponent} from './edit-task-modal/edit-task-modal.component';
import {InfoComponent} from './info/info.component';
import {PreviewComponent} from './preview/preview.component';
import {SampleComponent} from './sample/sample.component';
import {TasksComponent} from './tasks/tasks.component';
import {TemplateComponent} from './template/template.component';
import {TaskMarkdownService} from "./task-markdown.service";
import { CodeSearchComponent } from './code-search/code-search.component';
import { PlagiarismDetectionComponent } from './plagiarism-detection/plagiarism-detection.component';


@NgModule({
Expand All @@ -28,9 +28,9 @@ import {TaskMarkdownService} from "./task-markdown.service";
EditTaskModalComponent,
InfoComponent,
PreviewComponent,
SampleComponent,
TasksComponent,
TemplateComponent,
CodeSearchComponent,
PlagiarismDetectionComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export class EditAssignmentComponent implements OnInit {
deadline: new Date(),
description: '',
tasks: [],
solution: '',
templateSolution: '',
classroom: {},
};
}
Expand All @@ -73,7 +71,6 @@ export class EditAssignmentComponent implements OnInit {
this.assignmentService.upload(file).subscribe(result => {
const {_id, token, createdBy, ...rest} = result;
this.context.assignment = rest as Assignment;
this.context.evaluations = undefined;
this.saveDraft();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@
Example: <code>src/**/model/*.java</code>
</div>
</div>
<div class="mb-3">
<label for="verificationInput" class="form-label">Verification</label>
<app-scenario-codemirror
id="verificationInput"
[(content)]="task.verification"
[autoSubmit]="true"
></app-scenario-codemirror>
</div>
<div class="mb-3" *ngIf="context.evaluations?.[task._id]?.remark as remark">
<label for="output" class="form-label">Output</label>
<app-autotheme-codemirror id="output" [content]="remark" [options]="{
autoRefresh: true,
lineNumbers: true,
styleActiveLine: true
}"></app-autotheme-codemirror>
</div>
</div>
</ng-container>
<ng-container modal-footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class EditTaskModalComponent implements OnInit {
_id,
description: '',
points: 0,
verification: '',
children: [],
};
}
Expand Down
Loading

0 comments on commit 717f3d4

Please sign in to comment.