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

Slight changes to the report json format #1189

Merged
merged 21 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Redo Overview
  • Loading branch information
Kr0nox committed Jul 13, 2023
commit 3d403033ac39af836356001060d13d9db481eb99
9 changes: 7 additions & 2 deletions report-viewer/src/components/ComparisonsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@

<!-- Similarities -->
<div class="tableCellSimilarity">
<div class="w-1/2">{{ (item.averageSimilarity * 100).toFixed(2) }}%</div>
<div class="w-1/2">{{ (item.maximumSimilarity * 100).toFixed(2) }}%</div>
<div class="w-1/2">
{{ (item.similarities[MetricType.AVERAGE] * 100).toFixed(2) }}%
</div>
<div class="w-1/2">
{{ (item.similarities[MetricType.MAXIMUM] * 100).toFixed(2) }}%
</div>
</div>
</RouterLink>

Expand Down Expand Up @@ -133,6 +137,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faUserGroup } from '@fortawesome/free-solid-svg-icons'
import { generateColors } from '@/utils/ColorUtils'
import MetricType from '@/model/MetricType'

library.add(faUserGroup)

Expand Down
5 changes: 3 additions & 2 deletions report-viewer/src/model/ComparisonListElement.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type MetricType from './MetricType'

/**
* Comparison model used by the Comparison Table in Overview. Only the needed attributes to display are included.
* For full comparison model see Comparison.ts
Expand All @@ -13,6 +15,5 @@ export type ComparisonListElement = {
id: number
firstSubmissionId: string
secondSubmissionId: string
averageSimilarity: number
maximumSimilarity: number
similarities: Record<MetricType, number>
}
17 changes: 0 additions & 17 deletions report-viewer/src/model/Metric.ts

This file was deleted.

4 changes: 2 additions & 2 deletions report-viewer/src/model/MetricType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* This enum maps the metric type to the index they have in the generated JSON and respectivly in the store.
*/
enum MetricType {
AVERAGE = 0,
MAXIMUM = 1
AVERAGE = 'AVG',
MAXIMUM = 'MAX'
}

export default MetricType
20 changes: 5 additions & 15 deletions report-viewer/src/model/Overview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type Distribution from './Distribution'
import type { Cluster } from '@/model/Cluster'
import type { ComparisonListElement } from './ComparisonListElement'
import type MetricType from './MetricType'

/**
* Model of the Overview file generated by JPlag
Expand All @@ -11,11 +12,10 @@ export class Overview {
private readonly _language: string
private readonly _fileExtensions: Array<string>
private readonly _matchSensitivity: number
private readonly _submissionIdsToComparisonFileName: Map<string, Map<string, string>>
private readonly _dateOfExecution: string
private readonly _durationOfExecution: number
private readonly _topComparisons: Array<ComparisonListElement>
private readonly _distributions: Array<Distribution>
private readonly _distributions: Record<MetricType, Distribution>
private readonly _clusters: Array<Cluster>
private readonly _totalComparisons: number

Expand All @@ -28,10 +28,9 @@ export class Overview {
dateOfExecution: string,
durationOfExecution: number,
topComparisons: Array<ComparisonListElement>,
distributions: Array<Distribution>,
distributions: Record<MetricType, Distribution>,
clusters: Array<Cluster>,
totalComparisons: number,
submissionIdsToComparisonFileName: Map<string, Map<string, string>>
totalComparisons: number
) {
this._submissionFolderPath = submissionFolderPath
this._baseCodeFolderPath = baseCodeFolderPath
Expand All @@ -42,16 +41,7 @@ export class Overview {
this._durationOfExecution = durationOfExecution
this._topComparisons = topComparisons
this._distributions = distributions
this._clusters = clusters
this._submissionIdsToComparisonFileName = submissionIdsToComparisonFileName
this._totalComparisons = totalComparisons
}

/**
* @return Map of submission ids to the name of the comparison file and their content
*/
get submissionIdsToComparisonFileName() {
return this._submissionIdsToComparisonFileName
;(this._clusters = clusters), (this._totalComparisons = totalComparisons)
Kr0nox marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
49 changes: 49 additions & 0 deletions report-viewer/src/model/factories/BaseFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import store from '@/stores/store'

/**
* This class provides some basic functionality for the factories.
*/
export class BaseFactory {
/**
* Returns the content of a file through the stored loading type.
* @param path - Path to the file
* @return Content of the file
* @throws Error if the file could not be found
*/
protected static getFile(path: string): string {
if (store().state.localModeUsed) {
return this.getLocalFile(path)
} else if (store().state.zipModeUsed) {
const index = Object.keys(store().state.files).find((name) => name.endsWith(path))
if (index != undefined) {
const file = store().state.files[index]
if (file != undefined) {
return file
}
}
throw new Error(`Could not find ${path} in zip file.`)
Kr0nox marked this conversation as resolved.
Show resolved Hide resolved
} else if (store().state.singleModeUsed) {
return store().state.singleFillRawContent
}

throw new Error('No loading type specified')
}

/**
* Returns the content of a file from the local files.
* @param path - Path to the file
* @return Content of the file
* @throws Error if the file could not be found
*/
protected static getLocalFile(path: string): string {
const request = new XMLHttpRequest()
request.open('GET', `/files/${path}`, false)
request.send()

if (request.status == 200) {
return request.response
} else {
throw new Error(`Could not find ${path} in local files.`)
}
}
}
Loading