Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public CohortConceptGraphs(ConceptGraph structureGraph, List<AssessmentItemRespo

}

public CohortConceptGraphs(String filename, ConceptGraph structureGraph, List<AssessmentItemResponse> summaries){
this(structureGraph,summaries);
public CohortConceptGraphs(String filename, ConceptGraph structureGraph, List<AssessmentItemResponse> responses){
this(structureGraph,responses);
//TODO: call CohortConceptGraphsRecord
}

Expand Down
100 changes: 50 additions & 50 deletions src/main/java/edu/ithaca/dragon/tecmap/conceptgraph/ConceptGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import edu.ithaca.dragon.tecmap.io.record.LinkRecord;
import edu.ithaca.dragon.tecmap.learningresource.AssessmentItem;
import edu.ithaca.dragon.tecmap.learningresource.AssessmentItemResponse;
import edu.ithaca.dragon.tecmap.learningresource.LearningResource;
import edu.ithaca.dragon.tecmap.learningresource.LearningMaterial;
import edu.ithaca.dragon.tecmap.learningresource.LearningResourceType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -24,7 +24,7 @@ public class ConceptGraph {
// but also can be quickly looked up here (also allows checks for duplicates).
private Map<String, ConceptNode> nodeMap;
private Map<String, AssessmentItem> assessmentItemMap;
private Map<String, LearningResource> learningMaterialMap;
private Map<String, LearningMaterial> learningMaterialMap;


public ConceptGraph(ConceptGraphRecord structureDef){
Expand All @@ -34,14 +34,14 @@ public ConceptGraph(ConceptGraphRecord structureDef){
this.learningMaterialMap = new HashMap<>();
}

public ConceptGraph(ConceptGraphRecord structureDef, List<LearningResourceRecord> lolRecords){
public ConceptGraph(ConceptGraphRecord structureDef, List<LearningResourceRecord> learningResourceRecords){
this(structureDef);
addLearningResourcesFromRecords(lolRecords);
addLearningResourcesFromRecords(learningResourceRecords);
}

public ConceptGraph(ConceptGraphRecord structureDef, List<LearningResourceRecord> lolRecords, List<AssessmentItemResponse> AssessmentItemResponses){
this(structureDef, lolRecords);
addAssessmentItemResponses(AssessmentItemResponses);
public ConceptGraph(ConceptGraphRecord structureDef, List<LearningResourceRecord> learningResourceRecords, List<AssessmentItemResponse> assessmentItemResponses){
this(structureDef, learningResourceRecords);
addAssessmentItemResponses(assessmentItemResponses);
}

/**
Expand All @@ -62,14 +62,14 @@ public ConceptGraph(ConceptGraph other, String newName){
* e.g., when you are making a tree copy
* @param other a graph to copy
* @param newName the new name of the graph
* @param loMap a map of learning objects, which can be in any state of populated/not populated. This function will
* @param aiMap a map of learning objects, which can be in any state of populated/not populated. This function will
* connect the existing learning obejcts, or add any new ones necessary
*/
public ConceptGraph(ConceptGraph other, String newName, HashMap<String, AssessmentItem> loMap, HashMap<String, LearningResource> lmMap){
public ConceptGraph(ConceptGraph other, String newName, HashMap<String, AssessmentItem> aiMap, HashMap<String, LearningMaterial> lmMap){
this.name = newName;
this.roots = new ArrayList<>();
nodeMap = new HashMap<>();
assessmentItemMap = loMap;
assessmentItemMap = aiMap;
learningMaterialMap = lmMap;

//recursively copy entire graph
Expand All @@ -85,7 +85,7 @@ public ConceptGraph(ConceptGraph other, String newName, HashMap<String, Assessme
* Used only by TreeConverter
* @param rootsIn
*/
public ConceptGraph(List<ConceptNode> rootsIn, String name, Map<String, AssessmentItem> AssessmentItemMap, Map<String, LearningResource> learningMaterialMap, Map<String, ConceptNode> nodeMap){
public ConceptGraph(List<ConceptNode> rootsIn, String name, Map<String, AssessmentItem> AssessmentItemMap, Map<String, LearningMaterial> learningMaterialMap, Map<String, ConceptNode> nodeMap){
this.name = name;
this.assessmentItemMap = AssessmentItemMap;
this.learningMaterialMap = learningMaterialMap;
Expand Down Expand Up @@ -159,7 +159,7 @@ public void addLearningResourcesFromRecords(List<LearningResourceRecord> learnin
if (record.isType(LearningResourceType.INFORMATION) || record.isType(LearningResourceType.PRACTICE)){
//since we've already added possibly an assessment for this record, remove it (if it were there) so the list can be used to create the material directly from the list
record.getResourceTypes().remove(LearningResourceType.ASSESSMENT);
linkLearningMaterials(new LearningResource(record), record.getConceptIds());
linkLearningMaterials(new LearningMaterial(record), record.getConceptIds());
}
}
}
Expand All @@ -174,11 +174,11 @@ public void addLearningResourcesFromRecords(List<LearningResourceRecord> learnin
*/
public int linkAssessmentItem (AssessmentItem toLink, Collection<String> conceptIds){
int numAdded = 0;
if (assessmentItemMap.get(toLink.getId()) != null){
logger.warn(toLink.getId()+" already exists in this graph. Nothing was added.");
if (assessmentItemMap.get(toLink.getText()) != null){
logger.warn(toLink.getText()+" already exists in this graph. Nothing was added.");
return -1;
}
assessmentItemMap.put(toLink.getId(), toLink);
assessmentItemMap.put(toLink.getText(), toLink);
for (String id: conceptIds){
if(nodeMap.get(id) != null){
numAdded++;
Expand All @@ -199,13 +199,13 @@ public int linkAssessmentItem (AssessmentItem toLink, Collection<String> concept
* @post the LearningMaterial is added to the graph's map, and to all associated Concept's AssessmentItem maps
* @return the number of concepts the LearningMaterial was added to, or -1 if the LearningMaterial already exists
*/
public int linkLearningMaterials(LearningResource toLink, Collection<String> conceptIds){
public int linkLearningMaterials(LearningMaterial toLink, Collection<String> conceptIds){
int numAdded = 0;
if (learningMaterialMap.get(toLink.getId()) != null){
logger.warn(toLink.getId()+" already exists in this graph. Nothing was added.");
if (learningMaterialMap.get(toLink.getText()) != null){
logger.warn(toLink.getText()+" already exists in this graph. Nothing was added.");
return -1;
}
learningMaterialMap.put(toLink.getId(), toLink);
learningMaterialMap.put(toLink.getText(), toLink);
for (String id: conceptIds){
if(nodeMap.get(id) != null){
numAdded++;
Expand All @@ -226,13 +226,14 @@ public int linkLearningMaterials(LearningResource toLink, Collection<String> con
*/
public void addAssessmentItemResponses(List<AssessmentItemResponse> assessmentItemResponses) {
for (AssessmentItemResponse response : assessmentItemResponses){
AssessmentItem assessmentItem = assessmentItemMap.get(response.getLearningObjectId());
AssessmentItem assessmentItem = assessmentItemMap.get(response.getAssessmentItemText());
if (assessmentItem != null){
assessmentItem.addResponse(response);
}
else {
logger.warn("No AssessmentItem:" + response.getLearningObjectId() + " for response: " + response.toString());
logger.warn("No AssessmentItem: " + response.getAssessmentItemText() + " for response: " + response.toString());
//TODO: maybe make a new list of unconnected learning objects???
Thread.dumpStack();
}
}
}
Expand All @@ -244,11 +245,11 @@ public void addAssessmentItemResponses(List<AssessmentItemResponse> assessmentIt
public Map<String, Integer> buildDirectConceptLinkCount(){
Map<String, Integer> directConceptLinkCountMap = new HashMap<>();
for (ConceptNode node: nodeMap.values()){
for (LearningResource learningMaterial : node.getLearningMaterialMap().values()){
if(directConceptLinkCountMap.containsKey(learningMaterial.getId())){
directConceptLinkCountMap.put(learningMaterial.getId(),directConceptLinkCountMap.get(learningMaterial.getId())+1);
for (LearningMaterial learningMaterial : node.getLearningMaterialMap().values()){
if(directConceptLinkCountMap.containsKey(learningMaterial.getText())){
directConceptLinkCountMap.put(learningMaterial.getText(),directConceptLinkCountMap.get(learningMaterial.getText())+1);
}else{
directConceptLinkCountMap.put(learningMaterial.getId(), 1);
directConceptLinkCountMap.put(learningMaterial.getText(), 1);
}
}
}
Expand All @@ -260,12 +261,11 @@ public Map<String, Integer> buildDirectConceptLinkCount(){
* @return a map from id -> pathCount to the given conceptNode
*/
public Map<String,Integer> buildLearningResourcePathCount(String node) {

ConceptNode findNode = findNodeById(node);
if (findNode != null) {
Map<String, Integer> idToPathCount = new HashMap<>();
findNode.buildLearningMaterialPathCount(idToPathCount);
return idToPathCount;
Map<String, Integer> textToPathCount = new HashMap<>();
findNode.buildLearningMaterialPathCount(textToPathCount);
return textToPathCount;
}else{
logger.warn("buildLearningMaterialPathCount:" + node + " is not found in the graph");
return null;
Expand Down Expand Up @@ -316,8 +316,8 @@ public double calcTotalKnowledgeEstimate(String startingNodeId){

public int responsesCount(){
int total = 0;
for (AssessmentItem lo : assessmentItemMap.values()){
total += lo.getResponses().size();
for (AssessmentItem assessmentItem : assessmentItemMap.values()){
total += assessmentItem.getResponses().size();
}
return total;
}
Expand Down Expand Up @@ -358,7 +358,7 @@ public void calcDataImportance(){
* @return
*/
public List<String> getAssessmentsBelowAssessmentID(String assessmentId) {
List<ConceptNode> nodesWithAssessmentId = getNodesWithAssessmentId(assessmentId);
List<ConceptNode> nodesWithAssessmentId = getNodesWithAssessmentText(assessmentId);

List<Integer> assessmentNodesPathLengths = new ArrayList<>();
for (ConceptNode node : nodesWithAssessmentId) {
Expand All @@ -373,24 +373,24 @@ public List<String> getAssessmentsBelowAssessmentID(String assessmentId) {
}

/**
* Gets list of assessmentItems that are x steps below the highest occurrence of the given assessmentId for each root
* @param assessmentId
* Gets list of assessmentItems that are x steps below the highest occurrence of the given assessmentText for each root
* @param assessmentText
* @param stepsDown number of steps to take
* @return List of assessments x steps down, null if there are negative stepsDown
*/
public List<String> getAssessmentsBelowAssessmentID(String assessmentId, int stepsDown) {
public List<String> getAssessmentsBelowAssessmentID(String assessmentText, int stepsDown) {
if (stepsDown < 0) {
return null;
}
List<ConceptNode> nodesWithAssessmentId = getNodesWithAssessmentId(assessmentId);
List<ConceptNode> nodesWithAssessmentText = getNodesWithAssessmentText(assessmentText);

//Dictates that an assessmentId will only be included once
//Dictates that an assessmentText will only be included once
Set<String> assessmentsBelow = new HashSet<>();
for (ConceptNode node : nodesWithAssessmentId) {
for (ConceptNode node : nodesWithAssessmentText) {
getAssessmentsBelowNode(assessmentsBelow, node, stepsDown);
for (AssessmentItem item : node.getAssessmentItemMap().values()) {
if (!assessmentsBelow.contains(item.getId()) && !item.getId().equals(assessmentId)) {
assessmentsBelow.add(item.getId());
if (!assessmentsBelow.contains(item.getText()) && !item.getText().equals(assessmentText)) {
assessmentsBelow.add(item.getText());
}
}
}
Expand All @@ -399,21 +399,21 @@ public List<String> getAssessmentsBelowAssessmentID(String assessmentId, int ste
}

/**
* Finds the nodes from the graph with the given assessmentId in its list of assessments
* @param assessmentId
* Finds the nodes from the graph with the given assessmentText in its list of assessments
* @param assessmentText
* @return
*/
public List<ConceptNode> getNodesWithAssessmentId(String assessmentId) {
List<ConceptNode> nodesWithAssessmentId = new ArrayList<>();
//Find the nodes with the given AssessmentId
public List<ConceptNode> getNodesWithAssessmentText(String assessmentText) {
List<ConceptNode> nodesWithAssessmentText = new ArrayList<>();
//Find the nodes with the given AssessmentText
for (ConceptNode node : nodeMap.values()) {
for (AssessmentItem item : node.getAssessmentItemMap().values()) {
if (item.getId().equals(assessmentId)) {
nodesWithAssessmentId.add(node);
if (item.getText().equals(assessmentText)) {
nodesWithAssessmentText.add(node);
}
}
}
return nodesWithAssessmentId;
return nodesWithAssessmentText;
}

/**
Expand All @@ -430,7 +430,7 @@ public Set<String> getAssessmentsBelowNode(Set<String> assessmentList, ConceptNo
} else {
for (ConceptNode child : startNode.getChildren()) {
for (AssessmentItem item : child.getAssessmentItemMap().values()) {
assessmentList.add(item.getId());
assessmentList.add(item.getText());
}
assessmentList = getAssessmentsBelowNode(assessmentList, child, stepsToTake-1);
}
Expand All @@ -452,7 +452,7 @@ public Map<String, AssessmentItem> getAssessmentItemMap() {
return assessmentItemMap;
}

public Map<String, LearningResource> getLearningMaterialMap() {
public Map<String, LearningMaterial> getLearningMaterialMap() {
return learningMaterialMap;
}

Expand Down
Loading