Spaces:
Runtime error
Runtime error
File size: 8,850 Bytes
32f0b26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
<script lang="ts">
import { onMount } from "svelte";
import ClusterResults from "./ClusterResults.svelte";
import Button, { Label } from "@smui/button";
import LinearProgress from "@smui/linear-progress";
import Checkbox from '@smui/checkbox';
import DataTable, {
Head,
Body,
Row,
Cell,
Label,
SortValue,
} from "@smui/data-table";
import FormField from "@smui/form-field";
let cur_examples = [];
let promise = Promise.resolve(null);
let scaffold_methods = ["personal", "personal_group", "prompts"];
let all_users = [];
async function getUsers() {
const response = await fetch("./get_users");
const text = await response.text();
const data = JSON.parse(text);
all_users = data["users"];
promise = getResults();
}
onMount(async () => {
getUsers()
});
async function getResults() {
let req_params = {
users: all_users
};
let params = new URLSearchParams(req_params).toString();
const response = await fetch("./get_results?" + params);
const text = await response.text();
const data = JSON.parse(text);
let results = data["results"];
return results;
}
function get_complete_ratio(reports) {
let total = reports.length;
let complete = reports.filter(item => item.complete_status).length;
return "" + complete + "/" + total + " complete";
}
function get_complete_count(reports) {
return reports.filter(item => item.complete_status).length;
}
function get_summary(reports) {
let summary = "";
let total_audits = 0
for (const scaffold_method of scaffold_methods) {
if (reports[scaffold_method]) {
let cur_reports = reports[scaffold_method];
let cur_ratio = get_complete_ratio(cur_reports);
let cur_result = "<li><b>" + scaffold_method + "</b>: " + cur_ratio + "</li>";
summary += cur_result;
let cur_complete = get_complete_count(cur_reports);
total_audits += cur_complete;
}
}
let top_summary = ": " + total_audits + "</li>";
summary = "";
return summary;
}
function get_url(user, scaffold_method) {
return "http://localhost:5001/?user=" + user + "&scaffold=" + scaffold_method;
}
</script>
<svelte:head>
<title>Results</title>
</svelte:head>
<div class="panel">
<div class="panel_contents">
<div>
<h3>Results</h3>
</div>
<div style="padding-top:50px">
{#await promise}
<div class="app_loading">
<LinearProgress indeterminate />
</div>
{:then results}
{#if results}
{#each results as user_report}
<div class="head_3">{user_report["user"]}</div>
<div class="section_indent">
<div class="head_5">Summary</div>
<div>{@html get_summary(user_report)}</div>
<ul>
<li>Labeling pages
<ul>
<li>
<a href="http://localhost:5001/?user={user_report["user"]}&tab=labeling&label_mode=3" target="_blank">Group-based model</a>
</li>
<li>
<a href="http://localhost:5001/?user={user_report["user"]}&tab=labeling&label_mode=0" target="_blank">Personalized model</a>
</li>
</ul>
</li>
<li>Auditing pages
<ul>
<li>
<a href="http://localhost:5001/?user={user_report["user"]}&scaffold=personal_group" target="_blank">Group-based audit - personal scaffold</a>
</li>
<li>
<a href="http://localhost:5001/?user={user_report["user"]}&scaffold=personal" target="_blank">Individual audit - personal scaffold</a>
</li>
<li>
<a href="http://localhost:5001/?user={user_report["user"]}&scaffold=prompts" target="_blank">Individual audit - prompt scaffold</a>
</li>
</ul>
</li>
</ul>
</div>
{#each scaffold_methods as scaffold_method}
{#if user_report[scaffold_method]}
<div class="spacing_vert_60 section_indent">
<div class="head_5">
{scaffold_method} ({get_complete_ratio(user_report[scaffold_method])})
[<a href={get_url(user_report["user"], scaffold_method)} target="_blank">link</a>]
</div>
{#each user_report[scaffold_method] as report}
<div class="spacing_vert_40 section_indent">
<div class="head_6_non_cap">
{report["title"]}
</div>
<div class="spacing_vert_20">
<div class="">
<b>Error type</b>
</div>
{report["error_type"]}
</div>
<div class="spacing_vert_20">
<div class="">
<b>Evidence</b>
</div>
{#if report["evidence"].length > 0}
<ClusterResults
cluster={null}
model={null}
data={{"cluster_comments": report["evidence"]}}
show_vis={false}
show_checkboxes={false}
table_width_pct={100}
rowsPerPage={10}
table_id={"panel"}
/>
{:else}
<p class="grey_text">
No examples added
</p>
{/if}
</div>
<div class="spacing_vert_20">
<div class="">
<b>Summary/Suggestions</b>
</div>
{report["text_entry"]}
</div>
<div class="spacing_vert_20">
<b>Completed</b>
<FormField>
<Checkbox checked={report["complete_status"]} disabled/>
</FormField>
</div>
</div>
{/each}
</div>
{/if}
{/each}
{/each}
{/if}
{:catch error}
<p style="color: red">{error.message}</p>
{/await}
</div>
</div>
</div>
<style>
.panel {
width: 80%;
padding: 50px;
}
</style>
|