From ed8bf3bbe65e89534082fea2df1daaff1f262049 Mon Sep 17 00:00:00 2001 From: sergiollende Date: Thu, 7 Mar 2024 16:41:42 +0100 Subject: [PATCH 1/4] Adding .gitignore to wikidata_service --- wikidata_service/.gitignore | 405 ++++++++++++++++++++++++++++++++++++ 1 file changed, 405 insertions(+) create mode 100644 wikidata_service/.gitignore diff --git a/wikidata_service/.gitignore b/wikidata_service/.gitignore new file mode 100644 index 0000000..58d4acc --- /dev/null +++ b/wikidata_service/.gitignore @@ -0,0 +1,405 @@ +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# content below from: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ \ No newline at end of file From 1589342dcee4badb7fd0b965a507b6343f0995b9 Mon Sep 17 00:00:00 2001 From: sergiollende Date: Thu, 7 Mar 2024 17:56:36 +0100 Subject: [PATCH 2/4] WikiData Service revamped --- .../Controllers/WikiDataController.cs | 136 +++--------------- .../WikiDataTest/Models/CapitalCountry.cs | 14 ++ wikidata_service/WikiDataTest/Models/Label.cs | 8 ++ .../WikiDataTest/Models/Question.cs | 26 ++++ .../WikiDataTest/Models/Results.cs | 7 + .../WikiDataTest/Models/RootObject.cs | 7 + wikidata_service/WikiDataTest/Program.cs | 6 + .../WikiDataTest/Services/QueryService.cs | 10 ++ .../WikiDataTest/Services/QuestionService.cs | 67 +++++++++ .../WikiDataTest/Services/WikiDataService.cs | 32 +++++ 10 files changed, 194 insertions(+), 119 deletions(-) create mode 100644 wikidata_service/WikiDataTest/Models/CapitalCountry.cs create mode 100644 wikidata_service/WikiDataTest/Models/Label.cs create mode 100644 wikidata_service/WikiDataTest/Models/Question.cs create mode 100644 wikidata_service/WikiDataTest/Models/Results.cs create mode 100644 wikidata_service/WikiDataTest/Models/RootObject.cs create mode 100644 wikidata_service/WikiDataTest/Services/QueryService.cs create mode 100644 wikidata_service/WikiDataTest/Services/QuestionService.cs create mode 100644 wikidata_service/WikiDataTest/Services/WikiDataService.cs diff --git a/wikidata_service/WikiDataTest/Controllers/WikiDataController.cs b/wikidata_service/WikiDataTest/Controllers/WikiDataController.cs index 513b70c..93c7149 100644 --- a/wikidata_service/WikiDataTest/Controllers/WikiDataController.cs +++ b/wikidata_service/WikiDataTest/Controllers/WikiDataController.cs @@ -1,5 +1,7 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; +using WikiDataTest.Models; +using WikiDataTest.Services; namespace WikiDataTest.Controllers { @@ -8,138 +10,34 @@ namespace WikiDataTest.Controllers public class WikiDataController : ControllerBase { private readonly ILogger _logger; + private readonly QueryService _queryService; + private readonly WikiDataService _wikiDataService; + private readonly QuestionService _questionService; - public WikiDataController(ILogger logger) + + public WikiDataController(ILogger logger, + QueryService queryService, WikiDataService wikiDataService, QuestionService questionService) { _logger = logger; + _queryService = queryService; + _wikiDataService = wikiDataService; + _questionService = questionService; } [HttpGet("GetQuestions")] public async Task GetQuestions() { - string endpointUrl = "https://query.wikidata.org/sparql?query="; - string sparqlQuery = "SELECT ?capitalLabel ?countryLabel WHERE { ?capital wdt:P1376 ?country. ?capital wdt:P31 wd:Q5119. ?country wdt:P31 wd:Q3624078. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],en\". }} LIMIT 400"; + RootObject jsonQuestions = await _wikiDataService.GetQuestions(_queryService.GetCapitalsQuery()); - var fullUrl = endpointUrl + sparqlQuery; + Question[] questions = _questionService.GenerateQuestionsCapitalsOf(jsonQuestions.results.bindings.ToArray()); - using (var client = new HttpClient()) + foreach (var item in questions) { - client.DefaultRequestHeaders.Add("User-Agent", "Sergiollende/1.0"); - client.DefaultRequestHeaders.Add("Accept", "application/sparql-results+json"); - - HttpResponseMessage response = await client.GetAsync(fullUrl); - - string responseBody = await response.Content.ReadAsStringAsync(); - - RootObject jsonResult = JsonConvert.DeserializeObject(responseBody); - foreach(CapitalCountry c in jsonResult.results.bindings) - { - Console.WriteLine(c.ToString()); - } - - Question[] questions = GenerateQuestionsCapitalsOf(jsonResult.results.bindings.ToArray()); - - foreach (var item in questions) - { - Console.WriteLine(item.ToString()); - } - - return Ok(jsonResult); + Console.WriteLine(item.ToString()); } - - } - - private Question[] GenerateQuestionsCapitalsOf(CapitalCountry[] capitalCountries) - { - Question[] questions = new Question[10]; - - ISet ids = new HashSet(); - Random r = new Random(); - while (ids.Count < 10) { - ids.Add(r.Next(capitalCountries.Length)); - } - - int[] idsList = new int[10]; - int i = 0; - foreach (int id in ids) - { - idsList[i++] = id; - } - - for (int j = 0; j < idsList.Length; j++) - { - string text = "What is the capital of " + capitalCountries[idsList[j]].countryLabel.value; - string[] answers = new string[4]; - answers[0] = capitalCountries[idsList[j]].capitalLabel.value; - int[] wrongIds = new int[3]; - for (int w = 1; w < 4; w++) - { - int wrongId = r.Next(capitalCountries.Length); - while (idsList.Contains(wrongId) || wrongIds.Contains(wrongId) ) - { - wrongId = r.Next(capitalCountries.Length); - } - answers[w] = capitalCountries[wrongId].capitalLabel.value; - } - int correctAnswer = 0; - - questions[j] = new Question(text, answers, correctAnswer); - } - - return questions; - } - + return Ok(questions); + } } - public class CapitalCountry - { - public Label capitalLabel { get; set; } - public Label countryLabel { get; set; } - - public string ToString() - { - return countryLabel.value + ": " + capitalLabel.value; - } - } - - public class Label - { - public string value { get; set; } - } - - - public class Results - { - public List bindings { get; set; } - } - - public class RootObject - { - public Results results { get; set; } - } - - public class Question - { - public string text { get; set; } - public string[] answers; - public int correctAnswer; - - public Question(string text, string[] answers, int correctAnswer) - { - this.text = text; - this.answers = answers; - this.correctAnswer = correctAnswer; - } - - public string ToString() - { - string aux = "text: " + text; - aux += "\ncorrectAnswer: " + answers[0]; - aux += "\nAnswer: " + answers[1]; - aux += "\nAnswer: " + answers[2]; - aux += "\nAnswer: " + answers[3]; - return aux ; - } - } } diff --git a/wikidata_service/WikiDataTest/Models/CapitalCountry.cs b/wikidata_service/WikiDataTest/Models/CapitalCountry.cs new file mode 100644 index 0000000..32e6348 --- /dev/null +++ b/wikidata_service/WikiDataTest/Models/CapitalCountry.cs @@ -0,0 +1,14 @@ +namespace WikiDataTest.Models +{ + + public class CapitalCountry + { + public Label capitalLabel { get; set; } + public Label countryLabel { get; set; } + + public string ToString() + { + return countryLabel.value + ": " + capitalLabel.value; + } + } +} diff --git a/wikidata_service/WikiDataTest/Models/Label.cs b/wikidata_service/WikiDataTest/Models/Label.cs new file mode 100644 index 0000000..4b0fad0 --- /dev/null +++ b/wikidata_service/WikiDataTest/Models/Label.cs @@ -0,0 +1,8 @@ +namespace WikiDataTest.Models +{ + public class Label + { + public string value { get; set; } + } + +} diff --git a/wikidata_service/WikiDataTest/Models/Question.cs b/wikidata_service/WikiDataTest/Models/Question.cs new file mode 100644 index 0000000..424843f --- /dev/null +++ b/wikidata_service/WikiDataTest/Models/Question.cs @@ -0,0 +1,26 @@ +namespace WikiDataTest.Models +{ + public class Question + { + public string text { get; set; } + public string[] answers { get; set; } + public int correctAnswer { get; set; } + + public Question(string text, string[] answers, int correctAnswer) + { + this.text = text; + this.answers = answers; + this.correctAnswer = correctAnswer; + } + + public string ToString() + { + string aux = "text: " + text; + aux += "\ncorrectAnswer: " + answers[0]; + aux += "\nAnswer: " + answers[1]; + aux += "\nAnswer: " + answers[2]; + aux += "\nAnswer: " + answers[3]; + return aux; + } + } +} diff --git a/wikidata_service/WikiDataTest/Models/Results.cs b/wikidata_service/WikiDataTest/Models/Results.cs new file mode 100644 index 0000000..f6b9198 --- /dev/null +++ b/wikidata_service/WikiDataTest/Models/Results.cs @@ -0,0 +1,7 @@ +namespace WikiDataTest.Models +{ + public class Results + { + public List bindings { get; set; } + } +} diff --git a/wikidata_service/WikiDataTest/Models/RootObject.cs b/wikidata_service/WikiDataTest/Models/RootObject.cs new file mode 100644 index 0000000..10da15c --- /dev/null +++ b/wikidata_service/WikiDataTest/Models/RootObject.cs @@ -0,0 +1,7 @@ +namespace WikiDataTest.Models +{ + public class RootObject + { + public Results results { get; set; } + } +} diff --git a/wikidata_service/WikiDataTest/Program.cs b/wikidata_service/WikiDataTest/Program.cs index 48863a6..447cb60 100644 --- a/wikidata_service/WikiDataTest/Program.cs +++ b/wikidata_service/WikiDataTest/Program.cs @@ -1,3 +1,5 @@ +using WikiDataTest.Services; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -6,6 +8,10 @@ // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); +builder.Services.AddSingleton(new QueryService()); +builder.Services.AddSingleton(new WikiDataService()); +builder.Services.AddSingleton(new QuestionService()); + var app = builder.Build(); diff --git a/wikidata_service/WikiDataTest/Services/QueryService.cs b/wikidata_service/WikiDataTest/Services/QueryService.cs new file mode 100644 index 0000000..8d99759 --- /dev/null +++ b/wikidata_service/WikiDataTest/Services/QueryService.cs @@ -0,0 +1,10 @@ +namespace WikiDataTest.Services +{ + public class QueryService + { + public string GetCapitalsQuery() + { + return "SELECT ?capitalLabel ?countryLabel WHERE { ?capital wdt:P1376 ?country. ?capital wdt:P31 wd:Q5119. ?country wdt:P31 wd:Q3624078. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],en\". }} LIMIT 400"; + } + } +} diff --git a/wikidata_service/WikiDataTest/Services/QuestionService.cs b/wikidata_service/WikiDataTest/Services/QuestionService.cs new file mode 100644 index 0000000..e6ff378 --- /dev/null +++ b/wikidata_service/WikiDataTest/Services/QuestionService.cs @@ -0,0 +1,67 @@ +using System; +using WikiDataTest.Controllers; +using WikiDataTest.Models; + +namespace WikiDataTest.Services +{ + public class QuestionService + { + /// + /// Generate the questions from the capital/countries passed as parameter + /// + /// all the countries obtained + /// number of questions to generate + /// + public Question[] GenerateQuestionsCapitalsOf(CapitalCountry[] capitalCountries, int numberQuestions = 10) + { + Question[] questions = new Question[numberQuestions]; + + ISet ids = new HashSet(); + Random r = new Random(); + + while (ids.Count < numberQuestions) + { + ids.Add(r.Next(capitalCountries.Length)); + } + + int[] idsList = new int[numberQuestions]; + int i = 0; + foreach (int id in ids) + { + idsList[i++] = id; + } + + // Generate questions + for (int j = 0; j < idsList.Length; j++) + { + // Generate the questions + string countryName = capitalCountries[idsList[j]].countryLabel.value; + string questionText = $"What is the capital of {countryName}?"; + string[] answers = new string[4]; + + // Place of the correct answer + int correctAnswer = 0; + + // Save the capital of the specific country on first place + answers[correctAnswer] = capitalCountries[idsList[j]].capitalLabel.value; + + // Get 3 random wrong answers from all the capitals + int[] wrongIds = new int[3]; + for (int w = 1; w < 4; w++) + { + int wrongId = r.Next(capitalCountries.Length); + while (idsList[j] == wrongId || wrongIds.Contains(wrongId)) + { + wrongId = r.Next(capitalCountries.Length); + } + wrongIds[w - 1] = wrongId; + answers[w] = capitalCountries[wrongId].capitalLabel.value; + } + + questions[j] = new Question(questionText, answers, correctAnswer); + } + + return questions; + } + } +} diff --git a/wikidata_service/WikiDataTest/Services/WikiDataService.cs b/wikidata_service/WikiDataTest/Services/WikiDataService.cs new file mode 100644 index 0000000..5611a01 --- /dev/null +++ b/wikidata_service/WikiDataTest/Services/WikiDataService.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json; +using WikiDataTest.Controllers; +using WikiDataTest.Models; + +namespace WikiDataTest.Services +{ + public class WikiDataService + { + public WikiDataService() { } + + public async Task GetQuestions(string sparqlQuery) + { + string endpointUrl = "https://query.wikidata.org/sparql?query="; + + var fullUrl = endpointUrl + sparqlQuery; + + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Add("User-Agent", "Sergiollende/1.0"); + client.DefaultRequestHeaders.Add("Accept", "application/sparql-results+json"); + + HttpResponseMessage response = await client.GetAsync(fullUrl); + + string responseBody = await response.Content.ReadAsStringAsync(); + + RootObject jsonResult = JsonConvert.DeserializeObject(responseBody); + + return jsonResult; + } + } + } +} From 0abb2fe05f3b80a6a7957d579f96819db33f060c Mon Sep 17 00:00:00 2001 From: sergiollende Date: Thu, 7 Mar 2024 17:57:25 +0100 Subject: [PATCH 3/4] .gitignore improved --- .gitignore | 408 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 407 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8bbe72a..dea44f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,409 @@ node_modules coverage -docs/build \ No newline at end of file +docs/build + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# content below from: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ \ No newline at end of file From 3ad11b0f8190fc60e4a3b00cdea538d9a5a85ce4 Mon Sep 17 00:00:00 2001 From: sergiollende Date: Thu, 7 Mar 2024 18:09:22 +0100 Subject: [PATCH 4/4] Adding comments to the code --- wikidata_service/WikiDataTest/Services/QuestionService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/wikidata_service/WikiDataTest/Services/QuestionService.cs b/wikidata_service/WikiDataTest/Services/QuestionService.cs index e6ff378..c386f5c 100644 --- a/wikidata_service/WikiDataTest/Services/QuestionService.cs +++ b/wikidata_service/WikiDataTest/Services/QuestionService.cs @@ -54,6 +54,7 @@ public Question[] GenerateQuestionsCapitalsOf(CapitalCountry[] capitalCountries, { wrongId = r.Next(capitalCountries.Length); } + // Adding the id of the wrongAnswer to the array wrongIds[w - 1] = wrongId; answers[w] = capitalCountries[wrongId].capitalLabel.value; }