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 ExamDto dto)
		{
			dto.ExamStruct.SeqQGroupIndex();
		}


		public static void SeqQGroupIndex(this ExamQuestionDto dto)
		{

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

			}
		}

	}
}
