public JsonResult SetMark(long userId, UserLanguages userLanguages, KnowledgeMark mark, TrainerItem item, RepetitionType repetitionType = RepetitionType.All) { var itemDataType = (KnowledgeDataType)(item != null ? item.DataType : int.MinValue); if (IsInvalid(userId, userLanguages) || EnumValidator.IsInvalid(mark) || item == null || IdValidator.IsInvalid(item.DataId) || EnumValidator.IsInvalid(itemDataType) || EnumValidator.IsInvalid(repetitionType)) { //TODO: писать сообщение return(JsonResultHelper.Error()); } IUserRepetitionIntervalQuery userRepetitionIntervalQuery = CreateUserRepetitionIntervalQuery(userId, repetitionType); var repetitionInterval = new UserRepetitionIntervalItem { DataId = item.DataId, DataType = itemDataType, SourceType = KnowledgeSourceType }; var trainerHelper = new TrainerHelper(userRepetitionIntervalQuery, userLanguages); return(trainerHelper.SetMark(Request, mark, repetitionInterval)); }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] RepetitionType repetitionType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != repetitionType.Id) { return(BadRequest()); } repetitionType.ModifiedUserId = Convert.ToInt32(((ClaimsIdentity)HttpContext.User.Identity).FindFirst(ClaimTypes.Sid).Value); repetitionType.ModifiedDate = DateTime.Now; _context.Entry(repetitionType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(id)) { return(NotFound()); } else { throw; } } return(Ok(repetitionType)); }
private IUserRepetitionIntervalQuery CreateUserRepetitionIntervalQuery(long userId, RepetitionType repetitionType) { //TODO: создавать с помощью IoCModule long languageId = WebSettingsConfig.Instance.GetLanguageFromId(); IUserRepetitionKnowledgeQuery repetitionQuery = new UserRepetitionKnowledgeQuery(userId, languageId, KnowledgeDataType); return(new UserRepetitionIntervalQuery(userId, languageId, KnowledgeSourceType, repetitionQuery, repetitionType)); }
public UserRepetitionIntervalQuery(long userId, long languageId, KnowledgeSourceType sourceType, IUserRepetitionKnowledgeQuery repetitionQuery, RepetitionType repetitionType) { _userId = userId; _languageId = languageId; _sourceType = (int)sourceType; _userKnowledgeQuery = new UserKnowledgeQuery(userId, languageId); _repetitionQuery = repetitionQuery; _repetitionType = repetitionType; }
private static string UpdateRepetitionTypes(RepetitionType currentRepetitionType, string usedRepetitionType) { if (!HaveRepetitionType(usedRepetitionType)) { var repetitionTypes = usedRepetitionType == null ? new List <RepetitionType>() : JsonConvert.DeserializeObject <List <RepetitionType> >(usedRepetitionType); return(repetitionTypes.Count == _numberOfRepetitionTypes ? CreateNewRepetitionType(currentRepetitionType) : AddRepetitionType(currentRepetitionType, repetitionTypes)); } return(CreateNewRepetitionType(currentRepetitionType)); }
public static DateTime CalculateNextOccurrence(this DateTime baseDateTime, RepetitionType repetitionType, int repetitionValue, DateTime?expirationDate) { DateTime result; switch (repetitionType) { case RepetitionType.NoRepeat: result = DateTime.MaxValue; break; case RepetitionType.EveryMillisecond: result = baseDateTime.AddMilliseconds(repetitionValue); break; case RepetitionType.EverySecond: result = baseDateTime.AddSeconds(repetitionValue); break; case RepetitionType.EveryMinute: result = baseDateTime.AddMinutes(repetitionValue); break; case RepetitionType.Hourly: result = baseDateTime.AddHours(repetitionValue); break; case RepetitionType.Daily: result = baseDateTime.AddDays(repetitionValue); break; case RepetitionType.Weekly: result = baseDateTime.AddDays(7 * repetitionValue); break; case RepetitionType.Monthly: result = baseDateTime.AddMonths(repetitionValue); break; case RepetitionType.Yearly: result = baseDateTime.AddYears(repetitionValue); break; default: throw new NotImplementedException($"Repetition type not found: {repetitionType}"); } return(!expirationDate.HasValue || result < expirationDate ? result : DateTime.MaxValue); }
public async Task <IActionResult> Post([FromBody] RepetitionType repetitionType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var x = HttpContext.User.Identity.Name; repetitionType.ModifiedUserId = Convert.ToInt32(((ClaimsIdentity)HttpContext.User.Identity).FindFirst(ClaimTypes.Sid).Value); repetitionType.ModifiedDate = DateTime.Now; _context.RepetitionType.Add(repetitionType); await _context.SaveChangesAsync(); return(CreatedAtAction("Get", new { id = repetitionType.Id }, repetitionType)); }
public static bool IsRepeatedOnDate(this DateTime firstOccurrence, DateTime testedDateTime, RepetitionType repetitionType, int repetitionValue, DateTime?expirationDate) { if (firstOccurrence.IsOnSameDate(testedDateTime)) { return(true); } else { if (repetitionType == RepetitionType.NoRepeat) { return(false); } } if (expirationDate == null) { expirationDate = DateTime.Now.AddYears(3); } var actualDateTime = firstOccurrence; while (actualDateTime < expirationDate) { actualDateTime = actualDateTime.CalculateNextOccurrence(repetitionType, repetitionValue, expirationDate); if (actualDateTime.IsOnSameDate(testedDateTime)) { return(true); } if (actualDateTime > testedDateTime) { break; } } return(false); }
private static string AddRepetitionType(RepetitionType currentRepetitionType, List <RepetitionType> repetitionTypes) { repetitionTypes.Add(currentRepetitionType); return(JsonConvert.SerializeObject(repetitionTypes)); }
public Utterance(string id, string library, string text, string category, string subcategory, bool isQuestion, RepetitionType repetitions) { _id = id.Equals("") ? "Undefined" : id; _library = library; _text = text; _category = category; _subcategory = subcategory; _isQuestion = isQuestion; _repetitions = repetitions; _textArray = new string[1] { text }; _bookmarkArray = new string[0]; }
public void Repeat(RepetitionType type) { throw new NotImplementedException (); }
public async Task <PostLearningRepetitionResponseModel> PostLearningRepetition(int wordId, string userResponse, RepetitionType repetitionType) => await $"{url}api/Learning/PostLearningRepetition" .PostJsonAsync(new PostLearningRepetitionRequestModel { WordId = wordId, UserResponse = userResponse, RepetitionType = repetitionType }) .ReceiveJson <PostLearningRepetitionResponseModel>();
/// <summary> /// A sequence that repeats its sub-tasks a number of times. /// </summary> public RepeatSequence(uint worldStateIndex, RepetitionType type = RepetitionType.Interleaved) { WorldStateIndex = worldStateIndex; _type = type; }
public void Repeat(RepetitionType type) { throw new NotImplementedException(); }
public CalculateDatesTestDataBuilder SetCancellationType(RepetitionType type) { this.repetitionType = type; return(this); }
public abstract void Repeat(RepetitionType type);