Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
20e7938
[csharp] [courses_steps_csv] Kickstart base
JavierCane Apr 22, 2021
60ae8c8
[csharp] [courses_steps_csv] Test execution works 🎉
JavierCane Apr 22, 2021
22297c6
[csharp] [courses_steps_csv] Test execution with mock works ✨
JavierCane Apr 22, 2021
f96cfbe
[csharp] [courses_steps_csv] Implement 01 base
ismanapa Apr 26, 2021
d881a3a
[csharp] [courses_steps_csv] Add 02 semantics
ismanapa Apr 26, 2021
127aab0
[csharp] [courses_steps_csv] Provide semantics to video step type
JavierCane Apr 26, 2021
a34e08d
[csharp] [courses_steps_csv] Provide semantics to the overall CourseS…
JavierCane Apr 26, 2021
76559e1
[csharp] [courses_steps_csv] [03_split_parsing_phase] Add base code r…
JavierCane Apr 26, 2021
b5c5410
[csharp] [courses_steps_csv] [03_split_parsing_phase] Duplicate loop …
JavierCane Apr 26, 2021
844007c
[csharp] [courses_steps_csv] Fix mini-typo in file name
JavierCane Apr 26, 2021
8508df1
[csharp] [courses_steps_csv] [03_split_parsing_phase] Clean out the f…
JavierCane Apr 26, 2021
326099d
[csharp] [courses_steps_csv] [03_split_parsing_phase] Refactor the se…
JavierCane Apr 26, 2021
78123d8
[csharp] [courses_steps_csv] [03_split_parsing_phase] Encapsulate `St…
JavierCane Apr 26, 2021
8ed79de
[csharp] [courses_steps_csv] [03_split_parsing_phase] Extract method …
JavierCane Apr 26, 2021
67e5ba0
[csharp] [courses_steps_csv] [04_split_serialization_phase] Add base …
ismanapa Apr 26, 2021
d174ca5
[csharp] [courses_steps_csv] [04_split_serialization_phase] Change se…
ismanapa Apr 26, 2021
83f192f
[csharp] [courses_steps_csv] [04_split_serialization_phase] Extract m…
ismanapa Apr 26, 2021
25f413a
[csharp] [courses_steps_csv] Move FindCourseSteps from ParseCsv to Co…
ismanapa Apr 26, 2021
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[csharp] [courses_steps_csv] [03_split_parsing_phase] Clean out the f…
…irst loop only leaving the CSV parsing behaviour
  • Loading branch information
JavierCane committed Apr 26, 2021
commit 8508df15515c7b084fe3243c18eb6cf7124e9a7c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public string Get(string courseId)
{
var csv = platform.FindCourseSteps(courseId);

var results = "[";
var csvSteps = new List<CsvStep>();

var lines = csv.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);

Expand All @@ -38,55 +38,18 @@ public string Get(string courseId)
int? quizTotalQuestions = string.IsNullOrEmpty(row[2]) ? null : int.Parse(row[2]);
int? videoDuration = string.IsNullOrEmpty(row[3]) ? null : int.Parse(row[3]);

var stepDurationInMinutes = 0.0;
var points = 0.0;

if (type == STEP_TYPE_VIDEO)
{
stepDurationInMinutes = videoDuration.Value * VIDEO_DURATION_PAUSES_MULTIPLIER;
}

if (type == STEP_TYPE_QUIZ)
{
stepDurationInMinutes = quizTotalQuestions.Value * QUIZ_TIME_PER_QUESTION_MULTIPLIER;
}

if (type != STEP_TYPE_VIDEO && type != STEP_TYPE_QUIZ)
{
continue;
}

if (type == STEP_TYPE_VIDEO)
{
points = stepDurationInMinutes * VIDEO_POINTS_PER_MINUTE;
}
var csvStep = new CsvStep(id, type, quizTotalQuestions, videoDuration);

if (type == STEP_TYPE_QUIZ)
{
points = stepDurationInMinutes * QUIZ_POINTS_PER_MINUTE;
}

var step = new Step
{
Id = id,
Type = type,
Duration = stepDurationInMinutes,
Points = points
};

results += JsonSerializer.Serialize(step, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});

if (i != lines.Length - 1)
{
results += ",";
}
csvSteps.Add(csvStep);
}
results += "]";

results = "[";
var results = "[";

lines = csv.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

namespace CodelyTv.CoursesStepsCsv
{
public sealed class CsvStep
{
public string StepId { get; }
public string Type { get; }
public double? QuizTotalQuestions { get; }
public double? VideoDuration { get; }

public CsvStep(string stepId, string type, double? quizTotalQuestions, double? videoDuration)
{
StepId = stepId;
Type = type;
QuizTotalQuestions = quizTotalQuestions;
VideoDuration = videoDuration;
}
}
}