Skip to content

Commit

Permalink
Updated tests + Updated Model Visualiser to show student IDs instead …
Browse files Browse the repository at this point in the history
…of indices
  • Loading branch information
IvanRibakov committed Jun 7, 2018
1 parent 4ef206f commit c59da20
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1168,12 +1168,13 @@ public ActionResult GetIniNode(int modo, string strDomainName, int Cluster)
//return new JSONPResult { Data = re }; //返回 jsonp 数据,输出回调函数
}

public ActionResult GetNodeStudents(string strDomainName, int Cluster, int Student, int modo)
public ActionResult GetNodeStudents(string strDomainName, int Cluster, string StudentKey, int modo)
{
//PredictiveStudentModel model = MapService.getModelByDomain(modo,strDomainName);
StudentsCluster cluster = model.GetCluster(Cluster - 1);
dominio = model.Domain.Actions;
string student = cluster.GetStudentKeys()[Student-1];
//string student = cluster.GetStudentKeys()[Student-1];
string student = StudentKey;
Node<State, Event> nodo = null;
int lastC = 0;
SortedDictionary<int, Node<State, Event>> found = new SortedDictionary<int, Node<State, Event>>();
Expand Down Expand Up @@ -1533,11 +1534,19 @@ public ActionResult GetStudents(string strDomainName, int Cluster, int modo)
{
//PredictiveStudentModel model = MapService.getModelByDomain(modo,strDomainName);
StudentsCluster cluster = model.GetCluster(Cluster-1);
//cluster.GetStudentKeys();
List<string> studentKeys = cluster.GetStudentKeys();
studentKeys.Sort();
List<string> quotedStudentKeys = new List<string>();
foreach(string key in studentKeys)
{
quotedStudentKeys.Add("\"" + key + "\"");
}

var re = "[" + String.Join(", ", quotedStudentKeys.ToArray()) + "]";
//cluster.GetStudentNodes("id");
//cluster.GetStudentEvents("id");
int NumOfStudents = cluster.NumberOfStudents;
var re = "{\"NumOfStudents\":" + NumOfStudents + "}";
// int NumOfStudents = cluster.NumberOfStudents;
// var re = "{\"NumOfStudents\":" + NumOfStudents + "}";
return Json(re, JsonRequestBehavior.AllowGet);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ var selectStudent = function () {
var modo1 = modo();
$.post(href + "Map/GetStudents", { strDomainName: TxtPhaseSelection, Cluster: clusterSelection, modo: modo1 }, function (data) {
var dataObj = JSON.parse(data);
students = dataObj.NumOfStudents;
//students = dataObj.NumOfStudents;
studentSelection.options.add(new Option("", 0));
for (var i = 0; i < students; i++) {
studentSelection.options.add(new Option("student " + i, i + 1));
for (var i = 0; i < dataObj.length; i++) {
studentSelection.options.add(new Option("student " + dataObj[i], dataObj[i]));
}
});
}
Expand Down Expand Up @@ -363,7 +363,7 @@ function loadStudentMap() {
modeSelection = document.getElementById("mode").value;
var modo1 = modo();
totalStudent = 1;
$.post(href + "Map/GetNodeStudents", { strDomainName: TxtPhaseSelection, Cluster: clusterSelection, Student: studentSelection, modo: modo1 }, function (data) {
$.post(href + "Map/GetNodeStudents", { strDomainName: TxtPhaseSelection, Cluster: clusterSelection, StudentKey: studentSelection, modo: modo1 }, function (data) {
$.each(data, function (i, items) {
var newItem = JSON.parse(items);
var nElement = newItem.Element;
Expand Down

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
<ItemGroup>
<Compile Include="CMTutorTest.cs" />
<Compile Include="ErrorPreventionMessageTest.cs" />
<Compile Include="Group.cs" />
<Compile Include="LogGenerator.cs" />
<Compile Include="Util.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Its.ExpertModule;
using Its.ExpertModule.ObjectModel;
using Its.StudentModule;
using Its.StudentModule.ObjectModel;
using Its.TutoringModule.CMTutor.SBP;
using Its.TutoringModule.CMTutor.SBP.OM;
using Its.TutoringModule.CMTutor.SBP.OM.State;
using Its.TutoringModule.CMTutor.SBP.OM.Event;
using Its.TutoringModule.Common;
using Its.Utils.Config;
using Its.Utils.Math;
using Its.WorldModule;

namespace Its.TutoringModule.CMTutorTest
{
/// <summary>
/// Defines a group of students via a sequence of actions that they should perform and IDs of the students belonging to this group
/// </summary>
public class Group
{
public string[] StudentKeys;
public string[] ActionKeys;

public Group(string[] studentKeys, string[] actionKeys)
{
StudentKeys = studentKeys;
ActionKeys = actionKeys;
}

public string ToString()
{
string output = "";
output += "Students: [" + string.Join(", ", StudentKeys) + "]\n";
output += "Actions: [" + string.Join(", ", ActionKeys) + "]";

return output;
}
}

public class Util
{
public static void GenerateLogs(ITutor tutor, string domainName, string objectName, List<Group> groupConfiguration)
{
Console.OutputEncoding = System.Text.Encoding.UTF8;

foreach (Group group in groupConfiguration)
{
Console.WriteLine(group.ToString());
foreach (string studentKey in group.StudentKeys)
{
Console.Write(" - " + studentKey + " ");
foreach (string actionKey in group.ActionKeys)
{
List<string> errors;
tutor.Validate(actionKey, domainName, studentKey, objectName, out errors);
tutor.GetTutorMessages(actionKey, domainName, studentKey);
}
Console.Write('\u2714');
Console.WriteLine();
}
}
}

public static List<string> GetStudentNodeKeyListInSequence(StudentsCluster cluster, string studentKey)
{
List<string> nodeKeys = new List<string>();
List<Arc<State, Event>> studentEvents = cluster.GetStudentEvents(studentKey);
Node<State, Event> nextNode = cluster.StudentActionsModel.InitState;

while (nextNode != null)
{
var nodeQuery = from evt in studentEvents
where evt.NodeOut.Key == nextNode.Key
select evt.NodeIn;
if (nodeQuery.Count() == 0)
{
nextNode = null;
}
else
{
nextNode = nodeQuery.First();
nodeKeys.Add(nextNode.Key);
}
}

return nodeKeys;
}

public static void InitModel(ITutorConfig config, string strDomainName, ClusterMethod cluMet, bool includeNoPlanActions, bool inPhases)
{
string ontologyPath = config.OntologyPath.Replace('\\', Path.DirectorySeparatorChar);
string logsPath = config.LogsPath.Replace('\\', Path.DirectorySeparatorChar);
string expertConfPath = config.DomainConfigurationPath.Replace('\\', Path.DirectorySeparatorChar);
int initialCol = config.InitialColumn;
int intialRow = config.InitialRow;

ExpertControl expert = ExpertControl.Instance(ontologyPath, logsPath, expertConfPath, initialCol, intialRow);
DomainActions domain = expert.GetDomainActions(strDomainName);
if (domain == null)
{
domain = expert.CreateDomain(strDomainName);
}

WorldControl world = WorldControl.Instance(ontologyPath, logsPath);
DomainLog logs = StudentControl.Instance(ontologyPath, logsPath, expertConfPath).GetDomainLogsFromOntology(domain, expert.OtherErrors, world.WorldErrors);
StudentBehaviorPredictorControl.Instance(config).AddModel(logs, cluMet, includeNoPlanActions, inPhases);
}
}
}

0 comments on commit c59da20

Please sign in to comment.