Skip to content
Open
47 changes: 23 additions & 24 deletions log/createDashboard_js.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php
/*
Dragoon Project
Arizona State University
(c) 2014, Arizona Board of Regents for and on behalf of Arizona State University
This file is a part of Dragoon
Dragoon is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dragoon Project
Arizona State University
(c) 2014, Arizona Board of Regents for and on behalf of Arizona State University

This file is a part of Dragoon
Dragoon is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Dragoon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Dragoon. If not, see <http://www.gnu.org/licenses/>.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Dragoon. If not, see <http://www.gnu.org/licenses/>.
*/
include "logAnalysis.php";
include "logProblemObject.php";
Expand All @@ -31,7 +31,6 @@ function __construct($con){

function createDashboard($section, $mode, $activity, $user, $problem, $fromTime, $fromDate, $toTime, $toDate){
$query = $this->getQuery($section, $mode, $activity, $user, $problem, $fromTime, $fromDate, $toTime, $toDate);
//echo $query;
$result = $this->al->getResults($query);
$objects = null;
if($result->num_rows != 0)
Expand All @@ -43,7 +42,7 @@ function createDashboard($section, $mode, $activity, $user, $problem, $fromTime,
function getQuery($section, $mode, $activity, $user, $problem, $fromDate, $toDate, $fromTime, $toTime){
$userString = "AND user = '".$user."' ";
$fromTimeString = "AND time >= '".$fromDate.(!empty($fromTime)?(" ".$fromTime):"")."' ";
$toTimeString = "AND time <= '".(!empty($toDate)?$toDate:$fromDate).(!empty($toTime)?(" ".$toTime):"")."' ";
$toTimeString = "AND time <= '".$toDate.(!empty($toTime)?(" ".$toTime):"")."' ";

$modeConnector = "=";
if(substr($mode, 0, 1) == "!"){
Expand Down Expand Up @@ -80,11 +79,11 @@ function getQuery($section, $mode, $activity, $user, $problem, $fromDate, $toDat
" AND method != 'runtime-error' ".
(!empty($user)?$userString:"").
(!empty($problem) ?$problemString:"").
(!empty($fromDate)?$toTimeString:"").
(!empty($toDate)?$toTimeString:"").
(!empty($mode)?$modeString:"").
(!empty($activity)?$activityString:"").
"ORDER BY user asc, problem asc, time asc, id asc;";
// $queryString = "SELECT tid, mode, session.session_id, user, problem, time, method, message, `group` from session JOIN step ON session.session_id = step.session_id where method != 'client-message' AND mode != 'AUTHOR' AND user = 'cdluna' AND problem LIKE '%ps3-0%' ORDER BY user asc, problem asc, tid asc;";
//$queryString = "SELECT tid, session.session_id, mode, user, problem, time, method, message, folder from session JOIN step ON session.session_id = step.session_id where section = 'lms-CPI_Fall_2017' AND method != 'runtime-error' AND mode NOT LIKE '%AUTHOR' AND user = 'jarell13' ORDER BY user asc, problem asc, time asc, id asc;";
//echo $queryString;

return $queryString;
Expand Down Expand Up @@ -516,7 +515,7 @@ function parseMessages($result){
} else if($newNode == null && $currentNode != null && strpos($currentNode->id, $newMessage['nodeID']) === false){
// case when no node exists and an out of order message. this issue has been fixed but still for fall 14 analysis it is needed
$newNode = new Node();
$newNode->name = $newMessage['node'];
$newNode->name = array_key_exists("node", $newMessage)?$newMessage['node']:"";
$newNode->id = $nodeID;
$newNode->openTimes = 0;
$newNode->nodeExist = true;
Expand All @@ -535,19 +534,19 @@ function parseMessages($result){
//when some other property came and is not for the current node. this is primarily because some log messages just didnt reach the database
if($currentNode!=null && strpos($currentNode->id, $newMessage['nodeID']) === false){
$pushNodeBack = true;
$newNode = $upObject->getNodeFromName($newMessage['node']);
$newNode = (array_key_exists("node", $newMessage)?$upObject->getNodeFromName($newMessage['node']):null);
if($newNode != null && !($newNode->nodeExist)){
//the node was deleted and without the description for re creation did not reach. so just start from the value that you have.
$newNode->id = $newNode->id."|".$newMessage['nodeID'];
$newNode->nodeExist = true;
} else if($newNode == null) {
$newNode = new Node();
$newNode->id = $newMessage['nodeID'];
$newNode->name = $newMessage['node']; //has come after description so the node name will always be there.
$newNode->name = array_key_exists("node", $newMessage)?$newMessage['node']:"";
$newNode->openTimes = 1;
$newNode->nodeExist = true;
}
} else if($currentNode == null && count($upObject->nodes) == 0){
} else if($currentNode == null /*&& count($upObject->nodes) == 0*/){
//first message is out of order
$currentNode = new Node();
$currentNode->id = $newMessage['nodeID'];
Expand Down
4 changes: 4 additions & 0 deletions log/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ define([
this.query = this.modules.qObject;
if(params.t.indexOf("lms") >= 0){
this.query.s = params.s;
if(params.td)
this.query.td=params.td;
if(params.fd)
this.query.fd=params.fd;
}
}else
this.query = params;
Expand Down
8 changes: 7 additions & 1 deletion www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,20 @@
<div id="variableTypeQuestionMark" class="questionMark"></div>
<label>Type</label>
</span>
<select id="variableType" data-dojo-type="dijit/form/Select">
<option value='defaultSelect'>---Select---</option>
<option value='unknown'>Unknown</option>
<option value='parameter'>Parameter</option>
</select>
<!--
<input data-dojo-type="dijit/form/RadioButton" name="variableType" class="handleVariable" id="unknownType" value="unknown"/>
<label for="unknownType">Unknown</label>
<input data-dojo-type="dijit/form/RadioButton" name="variableType" class="handleVariable" id="parameterType" value="parameter"/>
<label for="parameterType">Parameter</label>
<span id="variableTypeDynamicOption" style="display: none;">
<input data-dojo-type="dijit/form/RadioButton" name="variableType" class="handleVariable" id="dynamicType" value="dynamic"/>
<label for="dynamicType">Dynamic</label>
</span>
</span> -->
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead and delete the code for this. We can always retrieve it from git if we need it later.

</div>

<div class="fieldgroup" id="valueUnitsContainer" style="display: block;">
Expand Down
47 changes: 30 additions & 17 deletions www/js/con-student.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ define([

// A list of control map specific to students
resettableControls: ["equation"],
variableNodeControls: ["variable","value","units"],
variableNodeControls: ["variable","value","units","variableType"],
equationNodeControls: ["equation","schemas","entity"],
commonNodeControls: ["modelType","description"],
qtyElements: ["qtyDescriptionInputboxContainerStudent","variableTypeContainer","variableInputboxContainer", "unitsSelectorContainerStudent"],
Expand Down Expand Up @@ -239,9 +239,8 @@ define([
units: "unitsSelectorStudent",
modelType: "modelSelector",
value: "valueInputbox",
unknown: "unknownType",
parameter: "parameterType",
dynamic: "dynamicType",
variableType: "variableType",
//dynamic: "dynamicType",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can delete this dynamic line too.

schemas: "schemaSelector",
entity: "entitySelectorStudent",
schemaDisplay: "schemaDescriptionQuestionMark",
Expand Down Expand Up @@ -310,12 +309,12 @@ define([
// Log Error
//}
},
handleVariableType: function(e){
handleVariableType: function(varType){
// Summary : Sets variableType to Unknown/Parameter/Dynamic
// Value is not allowed when variableType is Unknown
// Value is handled when variableType is parameter or dynamic.
console.log("********************* in handleVariableType");
var _variableType = e.target.value;
var _variableType = varType;
this._model.student.setVariableType(this.currentID, _variableType);
this.variableTypeControls(this.currentID, _variableType);
this.applyDirectives(this._PM.processAnswer(this.currentID, 'variableType', _variableType));
Expand Down Expand Up @@ -505,6 +504,7 @@ define([
console.log("element",elem);
style.set(elem,"display","block");
});

//initially disable the type value and units which will be later handled in control settings based on state
this.disableTypeValueUnits(true);

Expand Down Expand Up @@ -717,13 +717,24 @@ define([
style.set("unitsSelectorContainerStudent","display","none");
}

/*
var prevSelected = query("input[name='variableType']:checked")[0] ? query("input[name='variableType']:checked")[0].value : undefined;
if(prevSelected)
registry.byId(prevSelected+"Type").set('checked', false);
registry.byId(prevSelected+"Type").set('checked', false); */
var varTypeSel = registry.byId(this.controlMap.variableType);
varTypeSel.removeOption(varTypeSel.getOptions());
var varTypes = ["unknown","parameter","dynamic"];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "dynamic" here.

//var curVarType = this._model.student.getVariableType(nodeid);
if(!varType){
varTypeSel.addOption({label: "---Select---", value: "defaultValue"});
}
array.forEach(varTypes, function(unit){
varTypeSel.addOption({label: unit, value: unit});
});
if(varType){
registry.byId(varType+"Type").set('checked', true);
this.variableTypeControls(this.currentID, varType);
}
varTypeSel.set('value', varType);
}
this.variableTypeControls(this.currentID, varType);
this.applyDirectives(nodeDirectives);
registry.byId(this.controlMap.variable).set("disabled",false);
}
Expand Down Expand Up @@ -1015,18 +1026,18 @@ define([
updateVariableTypeValue: function(value){
if(value == "unknown")
this._model.student.setValue(this.currentID, "");
registry.byId(value+"Type").set("checked", "checked");
registry.byId(this.controlMap.variableType).set('value', value);
this._model.student.setVariableType(this.currentID, value);
},

updateVariableTypeStatus: function(attribute, value){
if(attribute === "disabled" && value === true){
array.forEach(this._variableTypes, function(type){
registry.byId(type+"Type").set("disabled", true);
});
//array.forEach(this._variableTypes, function(type){
registry.byId(this.controlMap.variableType).set("disabled", true);
//});
} else if(attribute === "status"){
var selectedVariableType = query("input[name='variableType']:checked")[0].value;
registry.byId(selectedVariableType+"Type").set(attribute, value);
//var selectedVariableType = query("input[name='variableType']:checked")[0].value;
registry.byId(this.controlMap.variableType).set(attribute, value);
}
},
handleEquationDescription: function(description){
Expand Down Expand Up @@ -1073,9 +1084,11 @@ define([
disableTypeValueUnits: function(disable){
registry.byId(this.controlMap.value).set("disabled", disable);
registry.byId(this.controlMap.units).set("disabled", disable);
registry.byId(this.controlMap.variableType).set("disabled", disable);
/*
registry.byId(this.controlMap.unknown).set("disabled", disable);
registry.byId(this.controlMap.parameter).set("disabled", disable);
registry.byId(this.controlMap.dynamic).set("disabled", disable);
registry.byId(this.controlMap.dynamic).set("disabled", disable); */
},
getSlotVariablesList: function(){
return this._model.student.getAllVariables();
Expand Down
24 changes: 17 additions & 7 deletions www/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ define([
// Controls that are select menus
// note that topomath author design has been updated, so updating selects and equationButtons array
//selects: ['description', 'units', 'inputs'],
selects: ['description', 'units'],
selects: ['description', 'units', 'variableType'],

//equationButtons: ["plus", "minus", "times", "divide", "equals", "undo", "equationDone"],
equationButtons: [],
Expand Down Expand Up @@ -205,6 +205,7 @@ define([
Previously, just set domNode.bgcolor but this approach didn't work
for text boxes. */
// console.log(">>>>>>>>>>>>> setting color ", this.domNode.id, " to ", value);
/*
if(this.domNode && this.domNode.firstChild &&
(this.domNode.firstChild.name == "variableType" ||
this.domNode.name == "variableType")){
Expand All @@ -213,9 +214,8 @@ define([
updateColor(registry.byId(type+"Type").domNode.firstChild.labels[0], "");
});
updateColor(this.domNode.firstChild.labels[0], colorMap[value]);
} else {
updateColor(this.domNode, colorMap[value]);
}
} else { */
updateColor(this.domNode, colorMap[value]);
},

hideCloseNodeEditor: function(/* originical hide method*/ doHide){
Expand Down Expand Up @@ -503,16 +503,22 @@ define([
return this.disableHandlers || this.handleEquationDescription.apply(this, arguments);
}));

//event handler for new variable type select field
var varTypeSel = registry.byId(this.controlMap.variableType);
varTypeSel.on('Change', lang.hitch(this, function(){
return this.disableHandlers || this.handleVariableType.apply(this, arguments);
}));
/*
* event handler for 'value' field
* 'handleValue' will be called in either Student or Author mode
* */
var variableTypeToggle = dojo.query(".handleVariable");
/*
var variableTypeToggle = dojo.query(".handleVariable");
variableTypeToggle.forEach(function(toggleNode){
registry.byNode(toggleNode).on('click', lang.hitch(this, function(event){
return this.disableHandlers || this.handleVariableType(event);
}));
}, this);
}, this); */

var valueWidget = registry.byId(this.controlMap.value);
// This event gets fired if student hits TAB or input box
Expand Down Expand Up @@ -718,11 +724,12 @@ define([

// reset the variablte type radio button labels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned before, you can go ahead and remove the radio button code.

if(this.nodeType == "quantity"){
/*
array.forEach(this._variableTypes, function(type){
var w = registry.byId(type+"Type")
w.set("status", "");
w.set("disabled", false);
});
});*/
}

for(control in this.genericDivMap)
Expand Down Expand Up @@ -800,6 +807,9 @@ define([
// Initial input in Units box
registry.byId(this.controlMap.units).set('value', unit || '');

var varType = model.getVariableType(nodeid);
registry.byId(this.controlMap.variableType).set('value', varType || '');

}
else if(this.nodeType == "equation"){
//populate nodeEditor fields for an equation node
Expand Down
30 changes: 29 additions & 1 deletion www/js/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,13 @@ define([
if( (nodeStatus === "correct" && score === 0 && completeness) || (nodeStatus === "correct" && score === 1 && tweaked && completeness))
nodeStatus = "perfect";
if(gifted){
nodeStatus = "gifted-"+nodeStatus;
//if a gifted node turns out to be not a perfect node, ungift it and let user solve it and regular badges follow
if(nodeStatus == "perfect"){
nodeStatus = "gifted-"+nodeStatus;
}
else{
this.unGiftNode(id);
}
}
return nodeStatus;
},
Expand Down Expand Up @@ -1326,6 +1332,9 @@ define([
isGifted: function(id){
return this.getNode(id).gifted ? true : false;
},
unGiftNode: function(id){
this.getNode(id).gifted = false;
},
getCorrectAnswer : function(/*string*/ studentID, /*string*/ part){
var id = this.getAuthoredID(studentID);
var node = obj.authored.getNode(id);
Expand Down Expand Up @@ -1403,6 +1412,11 @@ define([
update("schemas");
update("entity");
update("equation");
//in case slots are not yet corrected, return incorrect even if the equation status is demo, refer to topomath issue "Inconsistent state with multiple yellow nodes #576"
var slotsCorrected = this.areSlotsDemo(studentID);
if(bestStatus == "demo" && this.getStatus(studentID,"equation").status == "demo" && !slotsCorrected){
bestStatus = "incorrect";
}
}
if(bestStatus == "partial"){
bestStatus = "incorrect";
Expand Down Expand Up @@ -1484,6 +1498,20 @@ define([
var entityValid = entityStatusObj.status == "correct" || entityStatusObj.status == "demo";
return schemaValid && entityValid;
},
areSlotsDemo: function(nodeID){
var ret = false;
var statusObj = this.getNode(nodeID).status;
Object.keys(statusObj).some(function(key){
if(key!= "schemas" && key!= "entity" && key!= "description" && key!= "equation"){
console.log(key);
if(statusObj[key] == "demo"){
ret = true;
return true;
}
}
});
return ret;
},
getGreenScore: function(problemConditions){
//returns the percentage of the greens or stars from all the user solved nodes so far
//nodeDen is the denominator the score being computed. It comprises of all the nodes student attempted so far (which exludes given nodes)
Expand Down