Compare commits
5 Commits
7aa40c171b
...
ebdb75e38e
Author | SHA1 | Date |
---|---|---|
BOT Alex | ebdb75e38e | |
BOT Alex | 1a0c59af3a | |
BOT Alex | 2a49117995 | |
BOT Alex | dab3cb47b7 | |
BOT Alex | f634474923 |
|
@ -9,6 +9,9 @@ namespace LearningChineseFixed
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static int CCharsLeft = 0;
|
||||
public static Action UpdateUiEvent;
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
@ -20,10 +23,14 @@ namespace LearningChineseFixed
|
|||
{
|
||||
config.SnackbarConfiguration.ShowTransitionDuration = 100;
|
||||
config.SnackbarConfiguration.HideTransitionDuration = 100;
|
||||
config.SnackbarConfiguration.VisibleStateDuration = 7500;
|
||||
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomCenter;
|
||||
});
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
}
|
||||
|
||||
public static void InvokeUiUpdate() => UpdateUiEvent?.Invoke();
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@
|
|||
</MudContainer>
|
||||
|
||||
@code{
|
||||
int numOfChunks = 100; //Exclusive index 0
|
||||
int numOfChunks = 197; //Exclusive index 0
|
||||
int selectedChunk = 0;
|
||||
|
||||
protected override void OnInitialized()
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
<MudContainer Class="justify-center d-flex ma-0" Style="height: 100%;">
|
||||
<MudStack Class="d-flex">
|
||||
<MudStack Row=true Class="pt-2 d-flex justify-center">
|
||||
<MudButton Color="Color.Default" OnClick="RemoveCCharFromSelection" Variant="Variant.Outlined">Skip</MudButton>
|
||||
<MudButton Color="Color.Default" OnClick="RemoveCCharFromSelection" Variant="Variant.Outlined">Avoid</MudButton>
|
||||
<MudButton Color="Color.Default" Variant="Variant.Outlined" OnClick="ShowMeaning">Meaning</MudButton>
|
||||
<MudButton Color="Color.Default" Variant="Variant.Outlined" OnClick="ShowPinyin">Pinyin</MudButton>
|
||||
</MudStack>
|
||||
<MudContainer>
|
||||
<MudPaper Class="pa-16 ma-2 rounded-xl mud-dark" Elevation="1">
|
||||
|
@ -105,29 +107,58 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Program.UpdateUiEvent += OnUiUpdate;
|
||||
|
||||
int selectedChunk = await localStorage.GetItemAsync<int>("SelectedChunk");
|
||||
|
||||
//Charecters = await httpClient.GetFromJsonAsync<CChar[]>("Data/NormalizedDataset.json");
|
||||
Charecters = await httpClient.GetFromJsonAsync<CChar[]>($"Data/Normalized_chunk_{selectedChunk.ToString("000")}.json");
|
||||
|
||||
DontSkipTheseCChar = Charecters.ToList();
|
||||
Program.CCharsLeft = DontSkipTheseCChar.Count;
|
||||
Program.InvokeUiUpdate();
|
||||
|
||||
GenerateQuestion();
|
||||
}
|
||||
|
||||
void OnUiUpdate() => StateHasChanged();
|
||||
|
||||
void GenerateQuestion()
|
||||
{
|
||||
if (DontSkipTheseCChar.Count < 3) throw new Exception("Finished this chunk of CChars");
|
||||
if (DontSkipTheseCChar.Count < 5)
|
||||
{
|
||||
FinishAndKickBackToLearn();
|
||||
return;
|
||||
}
|
||||
|
||||
int correctIndex = Random.Shared.Next(0, Answers.Length);
|
||||
|
||||
for (int i = 0; i < Answers.Length; i++)
|
||||
{
|
||||
bool isCorrect = i == correctIndex;
|
||||
Answers[i] = new Answer(DontSkipTheseCChar[Random.Shared.Next(0, DontSkipTheseCChar.Count)], isCorrect);
|
||||
CChar randomCChar;
|
||||
|
||||
repickRandomCChar:
|
||||
randomCChar = DontSkipTheseCChar[Random.Shared.Next(0, DontSkipTheseCChar.Count)];
|
||||
if (Answers.Any(x =>x != null && x.cchar == randomCChar)) goto repickRandomCChar;
|
||||
|
||||
Answers[i] = new Answer(randomCChar, isCorrect);
|
||||
}
|
||||
}
|
||||
|
||||
void FinishAndKickBackToLearn()
|
||||
{
|
||||
Snackbar.Add("Congrats, you have compleated this chunk!", Severity.Success, config =>
|
||||
{
|
||||
config.RequireInteraction = true;
|
||||
config.CloseAfterNavigation = false;
|
||||
});
|
||||
Program.UpdateUiEvent -= OnUiUpdate;
|
||||
Program.CCharsLeft = 0;
|
||||
|
||||
navigator.NavigateTo("");
|
||||
}
|
||||
|
||||
async void Submit()
|
||||
{
|
||||
bool isCorrect = Answers.Any(x => x.isCorrect && x.isSelected);
|
||||
|
@ -146,8 +177,8 @@
|
|||
<li>Correct answer: @correctCChar.pinyin.ToTitleCase()</li>
|
||||
<li>Meaning: @correctCChar.definition</li>
|
||||
</ul>
|
||||
</div>
|
||||
, Severity.Error);
|
||||
</div>
|
||||
, Severity.Error);
|
||||
}
|
||||
|
||||
GenerateQuestion();
|
||||
|
@ -188,6 +219,18 @@
|
|||
CChar correctChar = GetCorrectCChar();
|
||||
DontSkipTheseCChar.Remove(correctChar);
|
||||
Console.WriteLine("Remaining CChars: " + DontSkipTheseCChar);
|
||||
Program.CCharsLeft = DontSkipTheseCChar.Count;
|
||||
Program.InvokeUiUpdate();
|
||||
GenerateQuestion();
|
||||
}
|
||||
|
||||
public void ShowMeaning()
|
||||
{
|
||||
Snackbar.Add($"<b>Definition:</b> {GetCorrectCChar().definition}", Severity.Info);
|
||||
}
|
||||
|
||||
public void ShowPinyin()
|
||||
{
|
||||
Snackbar.Add($"<b>Pinyin:</b> {GetCorrectCChar().pinyin.ToTitleCase()}", Severity.Info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
},
|
||||
"dotnetRunMessages": true,
|
||||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
|
||||
"applicationUrl": "http://localhost:5198;http:/0.0.0.0:420/"
|
||||
"applicationUrl": "http://localhost:5198;http://0.0.0.0:420/"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
|
@ -23,7 +23,7 @@
|
|||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:24989",
|
||||
"applicationUrl": "http://localhost:7860",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
|
||||
<MudLayout>
|
||||
<MudAppBar Elevation="0">
|
||||
@if (Program.CCharsLeft > 0)
|
||||
{
|
||||
<MudText>@("CChars left: " + Program.CCharsLeft)</MudText>
|
||||
}
|
||||
<MudSpacer />
|
||||
<MudIconButton Icon="@Icons.Custom.Brands.MudBlazor" Color="Color.Inherit" Link="https://mudblazor.com/" Target="_blank" />
|
||||
<MudIconButton Icon="@Icons.Custom.Brands.LinkedIn" Color="Color.Inherit" Link="https://www.linkedin.com/in/zhentao-wei-3a3a0a182/" Target="_blank" />
|
||||
|
@ -17,5 +21,10 @@
|
|||
</MudLayout>
|
||||
|
||||
@code {
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Program.UpdateUiEvent += OnUiUpdate;
|
||||
}
|
||||
|
||||
void OnUiUpdate() => StateHasChanged();
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<base href="/" />
|
||||
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="css/app.css" rel="stylesheet" />
|
||||
<link href="LearningChineseFixed.styles.css" rel="stylesheet" />
|
||||
<!--<link href="LearningChineseFixed.styles.css" rel="stylesheet" />-->
|
||||
<link href="manifest.json" rel="manifest" />
|
||||
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
|
||||
<link rel="apple-touch-icon" sizes="192x192" href="icon-192.png" />
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.19" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.19" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.19" />
|
||||
<PackageReference Include="MudBlazor" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
|
||||
},
|
||||
"Mudblazor.Template": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": "true",
|
||||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
|
||||
"applicationUrl": "https://localhost:5001;http://0.0.0.0:420"
|
||||
}
|
||||
},
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:65283",
|
||||
"sslPort": 44398
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue