using Entities.DTO;
using System.Text.Json.Serialization;
using System.Text.Json;
using Entities.Contracts;
using Microsoft.Extensions.Options;
using AutoMapper;

namespace TechHelper.Client.Exam
{
	public static class AssignmentExtensions
	{

		public static List<string> ParseOptionsFromText(this string optionsText)
		{
			return optionsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)
				.Where(line => !string.IsNullOrWhiteSpace(line)).ToList();
		}

		public static void SeqIndex(this AssignmentDto dto)
		{
			dto.ExamStruct.SeqQGroupIndex();
		}


		public static void SeqQGroupIndex(this AssignmentQuestionDto dto)
		{

			foreach (var sqg in dto.ChildrenAssignmentQuestion)
			{
				sqg.Index = (byte)(dto.ChildrenAssignmentQuestion.IndexOf(sqg) + 1);
				sqg.SeqQGroupIndex();

			}
		}

	}
}
