diff --git a/Clean CaDET/Clean CaDET.csproj b/Clean CaDET/Clean CaDET.csproj
index ebae09a..c5d3177 100644
--- a/Clean CaDET/Clean CaDET.csproj
+++ b/Clean CaDET/Clean CaDET.csproj
@@ -47,6 +47,10 @@
8.0
+
+
+
+
diff --git a/Clean CaDET/Model/PlatformConnection/CaDETConnection.cs b/Clean CaDET/Model/PlatformConnection/CaDETConnection.cs
index ac28a7b..e217ccf 100644
--- a/Clean CaDET/Model/PlatformConnection/CaDETConnection.cs
+++ b/Clean CaDET/Model/PlatformConnection/CaDETConnection.cs
@@ -1,4 +1,7 @@
-using System.Net.Http;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Clean_CaDET.Model.PlatformConnection.DTOs;
@@ -6,18 +9,62 @@
namespace Clean_CaDET.Model.PlatformConnection
{
- public sealed class CaDETConnection: IPlatformConnection
+ public sealed class CaDETConnection : IPlatformConnection
{
private readonly HttpClient _httpClient = new HttpClient();
//TODO:Refactor to be read from configuration
- private readonly string codeUrl = "https://localhost:44325/api/repository/education/class";
+ private readonly string codeUrlRepositoryCompiler = "https://localhost:44325/api/repository/education/class";
+ private readonly string codeUrlSmartTutor = "https://localhost:44333/api/smarttutor/education/class";
+
+ //TODO: Delete this two Lists and Logic about them in this method, only testing purposes
+ List sentRequests = new List();
+ List recivedRequests = new List();
public async Task GetClassQualityAnalysisAsync(string sourceCode)
{
- StringContent request = new StringContent(JsonConvert.SerializeObject(sourceCode), Encoding.UTF8, "application/json");
- HttpResponseMessage response = await _httpClient.PostAsync(codeUrl, request);
- string content = await response.Content.ReadAsStringAsync();
- return JsonConvert.DeserializeObject(content);
+ StringContent requestRepositoryCompiler = new StringContent(JsonConvert.SerializeObject(sourceCode), Encoding.UTF8, "application/json");
+ HttpResponseMessage responseRepositoryCompiler = await _httpClient.PostAsync(codeUrlRepositoryCompiler, requestRepositoryCompiler);
+ string contentRepositoryCompiler = await responseRepositoryCompiler.Content.ReadAsStringAsync();
+
+ ClassQualityAnalysisResponse repositoryCompilerResponse = JsonConvert.DeserializeObject(contentRepositoryCompiler);
+
+
+
+ ClassQualityAnalysisResponse analysis = await SendRequestToSmartTutor(repositoryCompilerResponse);
+
+ var EmptyGuid = new Guid(new Byte[16]);
+ Guid sentRequest = repositoryCompilerResponse.Id;
+ Guid recivedRequest = analysis.Id;
+
+ sentRequests.Add(sentRequest);
+ recivedRequests.Add(recivedRequest);
+
+ while (recivedRequest.Equals(EmptyGuid) || !(sentRequest.Equals(recivedRequest)))
+ {
+ analysis = await SendRequestToSmartTutor(repositoryCompilerResponse);
+ }
+
+
+ if (sentRequests.All(recivedRequests.Contains) && sentRequests.Count == recivedRequests.Count)
+ {
+ System.Diagnostics.Debug.WriteLine("All sent messages have arrived");
+ }
+ else
+ {
+ System.Diagnostics.Debug.WriteLine("Not all sent messages have arrived");
+ }
+
+ return analysis;
+ }
+
+ private async Task SendRequestToSmartTutor(ClassQualityAnalysisResponse repositoryCompilerResponse)
+ {
+ StringContent requestSmartTutor = new StringContent(JsonConvert.SerializeObject(repositoryCompilerResponse.Id), Encoding.UTF8, "application/json");
+ HttpResponseMessage responseSmartTutor = await _httpClient.PostAsync(codeUrlSmartTutor, requestSmartTutor);
+ string contentSmartTutor = await responseSmartTutor.Content.ReadAsStringAsync();
+
+ var analysis = JsonConvert.DeserializeObject(contentSmartTutor);
+ return analysis;
}
}
}
\ No newline at end of file
diff --git a/Clean CaDET/Model/PlatformConnection/DTOs/ClassQualityAnalysisResponse.cs b/Clean CaDET/Model/PlatformConnection/DTOs/ClassQualityAnalysisResponse.cs
index 4b494be..e0c6681 100644
--- a/Clean CaDET/Model/PlatformConnection/DTOs/ClassQualityAnalysisResponse.cs
+++ b/Clean CaDET/Model/PlatformConnection/DTOs/ClassQualityAnalysisResponse.cs
@@ -1,8 +1,10 @@
-namespace Clean_CaDET.Model.PlatformConnection.DTOs
+using System;
+
+namespace Clean_CaDET.Model.PlatformConnection.DTOs
{
public class ClassQualityAnalysisResponse
{
- public ClassMetricsDTO Metrics { get; set; }
- public EducationalContentDTO Content { get; set; }
+ public Guid Id { get; set; }
+ public NewEducationContentDTO NewContent { get; set; }
}
}
diff --git a/Clean CaDET/Model/PlatformConnection/DTOs/NewEducationContentDTO.cs b/Clean CaDET/Model/PlatformConnection/DTOs/NewEducationContentDTO.cs
new file mode 100644
index 0000000..41149c2
--- /dev/null
+++ b/Clean CaDET/Model/PlatformConnection/DTOs/NewEducationContentDTO.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Clean_CaDET.Model.PlatformConnection.DTOs
+{
+ public class NewEducationContentDTO
+ {
+ public int ContentQuality { get; set; }
+ public int ContentDifficulty { get; set; }
+ public ObservableCollection EducationSnippets { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Clean CaDET/Model/PlatformConnection/DTOs/NewEducationSnippetDTO.cs b/Clean CaDET/Model/PlatformConnection/DTOs/NewEducationSnippetDTO.cs
new file mode 100644
index 0000000..2ac5769
--- /dev/null
+++ b/Clean CaDET/Model/PlatformConnection/DTOs/NewEducationSnippetDTO.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Clean_CaDET.Model.PlatformConnection.DTOs
+{
+ public class NewEducationSnippetDTO
+ {
+ public int SnippetQuality { get; set; }
+ public int SnippetDifficulty { get; set; }
+ public SnippetType SnippetType { get; set; }
+ public List Tags { get; set; }
+ public string Content { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Clean CaDET/Model/PlatformConnection/DTOs/SnippetType.cs b/Clean CaDET/Model/PlatformConnection/DTOs/SnippetType.cs
new file mode 100644
index 0000000..faa1f67
--- /dev/null
+++ b/Clean CaDET/Model/PlatformConnection/DTOs/SnippetType.cs
@@ -0,0 +1,12 @@
+namespace Clean_CaDET.Model.PlatformConnection.DTOs
+{
+ public enum SnippetType
+ {
+ CodeSnippet,
+ LongText,
+ ShortText,
+ Video,
+ Image,
+ Diagram
+ }
+}
\ No newline at end of file
diff --git a/Clean CaDET/Model/PlatformConnection/DTOs/Tag.cs b/Clean CaDET/Model/PlatformConnection/DTOs/Tag.cs
new file mode 100644
index 0000000..adfcf09
--- /dev/null
+++ b/Clean CaDET/Model/PlatformConnection/DTOs/Tag.cs
@@ -0,0 +1,9 @@
+namespace Clean_CaDET.Model.PlatformConnection.DTOs
+{
+ public enum Tag
+ {
+ Funny,
+ MustKnow,
+ Interesting
+ }
+}
\ No newline at end of file
diff --git a/Clean CaDET/View/Commands/ExamineProjectItemCommand.cs b/Clean CaDET/View/Commands/ExamineProjectItemCommand.cs
index 9d54f89..3bcc678 100644
--- a/Clean CaDET/View/Commands/ExamineProjectItemCommand.cs
+++ b/Clean CaDET/View/Commands/ExamineProjectItemCommand.cs
@@ -128,19 +128,23 @@ public static async Task InitializeAsync(AsyncPackage package)
}
private async void Execute(object sender, EventArgs e)
{
- ClassQualityAnalysisResponse codeQualityAnalysis = await _service.AnalyzeClassQualityAsync(_selectedFilePath);
+ /* Uncomment this for loop if you want to test sending more than one request*/
+/* for (int i = 0; i < 100; i++)
+ {*/
+ ClassQualityAnalysisResponse codeQualityAnalysis = await _service.AnalyzeClassQualityAsync(_selectedFilePath);
- ToolWindowPane window = _package.FindToolWindow(typeof(TutoringWindow), 0, true);
- if (window?.Frame == null)
- {
- throw new NotSupportedException("Cannot create tool window");
- }
+ ToolWindowPane window = _package.FindToolWindow(typeof(TutoringWindow), 0, true);
+ if (window?.Frame == null)
+ {
+ throw new NotSupportedException("Cannot create tool window");
+ }
- var tutoringWindow = window as TutoringWindow;
- tutoringWindow?.UpdateVMContent(codeQualityAnalysis.Content, codeQualityAnalysis.Metrics);
+ var tutoringWindow = window as TutoringWindow;
+ tutoringWindow?.UpdateVMContent(codeQualityAnalysis.NewContent);
- IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
- ErrorHandler.ThrowOnFailure(windowFrame.Show());
+ IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
+ ErrorHandler.ThrowOnFailure(windowFrame.Show());
+/* }*/
}
}
}
diff --git a/Clean CaDET/View/TutoringWindow.cs b/Clean CaDET/View/TutoringWindow.cs
index ad8fb12..39cd90b 100644
--- a/Clean CaDET/View/TutoringWindow.cs
+++ b/Clean CaDET/View/TutoringWindow.cs
@@ -13,11 +13,10 @@ public TutoringWindow() : base(null)
Content = new TutoringWindowControl();
}
- public void UpdateVMContent(EducationalContentDTO content, ClassMetricsDTO metrics)
+ public void UpdateVMContent(NewEducationContentDTO newEducationContent)
{
var windowControl = Content as TutoringWindowControl;
- windowControl.ViewModel.Content = content;
- windowControl.ViewModel.Metrics = metrics;
+ windowControl.ViewModel.NewContent = newEducationContent;
}
}
}
diff --git a/Clean CaDET/View/TutoringWindowControl.xaml b/Clean CaDET/View/TutoringWindowControl.xaml
index a2feef3..f7a18cb 100644
--- a/Clean CaDET/View/TutoringWindowControl.xaml
+++ b/Clean CaDET/View/TutoringWindowControl.xaml
@@ -29,14 +29,96 @@
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Clean CaDET/View/TutoringWindowControl.xaml.cs b/Clean CaDET/View/TutoringWindowControl.xaml.cs
index 2da686f..91a7d3e 100644
--- a/Clean CaDET/View/TutoringWindowControl.xaml.cs
+++ b/Clean CaDET/View/TutoringWindowControl.xaml.cs
@@ -1,4 +1,6 @@
-using Clean_CaDET.Model;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Clean_CaDET.Model;
using Clean_CaDET.View.ViewModel;
using System.Windows;
using System.Windows.Controls;
@@ -27,7 +29,40 @@ public TutoringWindowControl()
"Our analysis shows that this class has low cohesion. This signals that there might be two or more concepts represented by this class. Looking at the figure, we see how the class can be split into three classes, each containing a method and related field. Importantly, we presume the methods are not accessors (getters and setters).",
Recommendations =
"See if you can split the class by grouping the fields (or their subset) with methods that utilize them. If you can find suitable names for the two groups than you should perform the Extract Class refactoring. If one group is hard to define and sufficiently large, this might mean you have even more classes to extract."
- }
+ },
+ NewContent = new NewEducationContentDTO()
+ {
+ ContentDifficulty = 4,
+ ContentQuality = 3,
+ EducationSnippets = new ObservableCollection()
+ {
+ new NewEducationSnippetDTO()
+ {
+ SnippetType = SnippetType.ShortText,
+ Content = "Some short text",
+ SnippetDifficulty = 3,
+ SnippetQuality = 2,
+ Tags = new List()
+ {
+ Model.PlatformConnection.DTOs.Tag.Funny,
+ Model.PlatformConnection.DTOs.Tag.Interesting
+ }
+ },
+ new NewEducationSnippetDTO()
+ {
+ SnippetType = SnippetType.LongText,
+ Content = "Some must know long text",
+ SnippetDifficulty = 5,
+ SnippetQuality = 5,
+ Tags = new List()
+ {
+ Model.PlatformConnection.DTOs.Tag.MustKnow
+ }
+ }
+ }
+ }
+
+
};
DataContext = ViewModel;
diff --git a/Clean CaDET/View/ViewModel/TutoringWindowVM.cs b/Clean CaDET/View/ViewModel/TutoringWindowVM.cs
index c627629..fb73cbc 100644
--- a/Clean CaDET/View/ViewModel/TutoringWindowVM.cs
+++ b/Clean CaDET/View/ViewModel/TutoringWindowVM.cs
@@ -3,11 +3,24 @@
namespace Clean_CaDET.View.ViewModel
{
- public class TutoringWindowVM: INotifyPropertyChanged
+ public class TutoringWindowVM : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
//TODO: Should create a ViewModel class eventually, for basic examples this will suffice.
private EducationalContentDTO _content;
+ private ClassMetricsDTO _metrics;
+ private NewEducationContentDTO _newContent;
+
+ public NewEducationContentDTO NewContent
+ {
+ get => _newContent;
+ set
+ {
+ _newContent = value;
+ OnPropertyChanged("NewContent");
+ }
+ }
+
public EducationalContentDTO Content
{
get => _content;
@@ -18,8 +31,6 @@ public EducationalContentDTO Content
}
}
- private ClassMetricsDTO _metrics;
-
public ClassMetricsDTO Metrics
{
get => _metrics;
@@ -35,4 +46,4 @@ private void OnPropertyChanged(string propertyName)
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
-}
+}
\ No newline at end of file