public async Task <VocabularyExercise> EditVocabularyExerciseAsync(VocabularyExercise vocabularyExercise) { var dbVocabularyExercise = _mapper.Map <DbVocabularyExercise>(vocabularyExercise); return(_mapper.Map <VocabularyExercise>( await _exerciseRepository.EditVocabularyExerciseAsync(dbVocabularyExercise))); }
public ChooseOneExerciseViewModel(VocabularyExercise vocabularyExercise, ICommand nextCommand) { Exercise = vocabularyExercise; NextCommand = nextCommand; State = ExerciseState.NotAnswered; SetExerciseType(); Answers = new List <string>(); SetAnswersRandom(Answers, Exercise, TranslatedExpression, _isKnownToLearnig); Answer_Click = new RelayCommand <string>(CheckAnswer); }
public async Task ProcessExercisesAsync() { var service = new ExerciseService(); VocabularyExercises = await service.GetVocabularyExercises(Test); if (VocabularyExercises.Count != 0) { CurrentExercise = VocabularyExercises[0]; } }
public PictureExerciseViewModel(VocabularyExercise vocabularyExercise, ICommand nextCommand) { Exercise = vocabularyExercise; NextCommand = nextCommand; Answers = new List <string>(); SetAnswersRandom(Answers, Exercise, Exercise.CorrectAnswer, true); var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); string baseurl = resourceLoader.GetString("BaseUri"); PictureLocation = $"{baseurl}/api/pictures/{Exercise.Picture}"; Answer_Click = new RelayCommand <string>(CheckAnswer); }
private void VocabularyGridView_ItemClick(object sender, ItemClickEventArgs e) { VocabularyExercise parameter; if (e.ClickedItem.GetType() == typeof(NewVocabularyExercise)) { parameter = new VocabularyExercise { TestID = ViewModel.Test.ID }; } else { parameter = (VocabularyExercise)e.ClickedItem; } NavigationService.Navigate(typeof(EditVocabularyExercisePage), parameter); }
private IExerciseView SetExerciseType(VocabularyExercise exercise) { Random random = new Random(); int randomNumber = random.Next(exercise.Picture == null ? 2 : 3); var nextCommand = new RelayCommand(NextExercise); if (randomNumber == 0) { return(new ChooseOneExerciseView(exercise, nextCommand)); } else if (randomNumber == 1) { return(new TranslationExerciseView(exercise, nextCommand)); } else { return(new PictureExerciseView(exercise, nextCommand)); } }
protected void SetAnswersRandom(List <string> answers, VocabularyExercise exercise, string translatedExpression, bool isKnownToLearnig) { answers.Add(translatedExpression); answers.Add(isKnownToLearnig ? exercise.WrongAnswer1 : exercise.TranslatedWrongAnswer1); answers.Add(isKnownToLearnig ? exercise.WrongAnswer2 : exercise.TranslatedWrongAnswer2); answers.Add(isKnownToLearnig ? exercise.WrongAnswer3 : exercise.TranslatedWrongAnswer3); Random random = new Random(); int n = answers.Count; while (n > 1) { n--; int k = random.Next(n + 1); string value = answers[k]; answers[k] = answers[n]; answers[n] = value; } }
public async Task <VocabularyExercise> PutVocabularyExerciseAsync(VocabularyExercise vocabularyExercise) { using (var client = new HttpClient()) { InitializeClient(client); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("api/exercise")); HttpResponseMessage response = await client.PutAsJsonAsync("api/exercise/vocabulary", vocabularyExercise); if (response.IsSuccessStatusCode) { var serializer = new DataContractJsonSerializer(typeof(VocabularyExercise)); return(serializer.ReadObject(await response.Content.ReadAsStreamAsync()) as VocabularyExercise); } else { return(null); } } }
public async Task <bool> DeleteVocabularyExerciseAsync(VocabularyExercise vocabularyExercise) { using (var client = new HttpClient()) { InitializeClient(client); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("api/exercise")); HttpResponseMessage response = await client .DeleteAsync($"{BaseUrl}/api/exercise/vocabulary/{vocabularyExercise.ID}"); if (response.IsSuccessStatusCode) { return(true); } else { return(false); } } }
public PictureExerciseView(VocabularyExercise vocabularyExercise, ICommand nextCommand) { this.InitializeComponent(); ViewModel = new PictureExerciseViewModel(vocabularyExercise, nextCommand); DataContext = ViewModel; }
public async Task <IActionResult> EditVocabularyExerciseAsync([FromBody] VocabularyExercise vocabularyExercise) { return(Ok(await _exerciseManager.EditVocabularyExerciseAsync(vocabularyExercise))); }
public TranslationExerciseViewModel(VocabularyExercise vocabularyExercise, ICommand nextCommand) { Exercise = vocabularyExercise; NextCommand = nextCommand; SetExerciseType(); }