Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes to dashboard and merge from students with fixes for topXQ and t…
…extCorrection
  • Loading branch information
Tom Reijnders committed Jul 16, 2019
1 parent 82e2611 commit 141de58
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 25 deletions.
3 changes: 2 additions & 1 deletion lti_launch.php
Expand Up @@ -20,6 +20,7 @@
$tsugi_disable_xerte_session = true;
require_once(dirname(__FILE__) . "/config.php");
require_once($xerte_toolkits_site->tsugi_dir . "/config.php");
require_once(dirname(__FILE__) . "/website_code/php/xAPI/xAPI_library.php");

ini_set('display_errors', 0);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT);
Expand Down Expand Up @@ -128,7 +129,7 @@
'lrssecret' => $row['tsugi_xapi_secret'],
);
}

$lrs = CheckLearningLocker($lrs);

$_SESSION['XAPI_PROXY'] = $lrs;

Expand Down
Expand Up @@ -403,8 +403,12 @@

function getUrl(xerteurl, xertelo, xertelabel, opinionClass)
{
var url = xerteurl + xertelo + '/' + xertelabel.replace(/ /g, "_");
if (opinionClass != '' && opinionClass != null) {
var url = xerteurl + xertelo;
if (xertelabel != undefined && xertelabel != '')
{
url += '/' + xertelabel.replace(/ /g, "_");
}
if (opinionClass != undefined && opinionClass != '' ) {
url += '/' + opinionClass.replace(/ /g, "_");
}
return url;
Expand Down Expand Up @@ -456,7 +460,7 @@
}
*/
if (typeof actor != "undefined") {
actor.account.homePage = xerteurl + xertelo;
//actor.account.homePage = xerteurl + xertelo;
q['agent'] = JSON.stringify(actor);
}
}
Expand Down Expand Up @@ -688,11 +692,7 @@
nrParticipantsText = 'The number of participants is {0}';
}

url = xerteurl + xertelo + '/' + xertelabel;
if (opinionClass != '' && opinionClass != null) {
url += '/' + opinionClass;

}
url = getUrl(xerteurl, xertelo, xertelabel, opinionClass);
var $this = this;
divUrl = escapeUrl(url, interactionType, interactionIndex);
name = interaction.getAttribute('name');
Expand Down Expand Up @@ -841,7 +841,7 @@
//score = interaction.score;
if (interaction.getAttribute("showScore") == "true") {
var txt = scoreLabelText;
txt = txt.replace(/\{0\}/, score);
txt = txt.replace(/\{0\}/, Math.round(score*10)/10);
$('#' + escapeUrl(url, type, interactionIndex) + ' .score .stats').append('<p>' + txt + '%</p>');
}

Expand Down Expand Up @@ -1748,7 +1748,7 @@
var scoretext = "";
if (interaction.score != Number.MAX_VALUE)
{
scoretext = "<div class='score'><p>" + scoreLabelText.replace('{0}', interaction.score) + "</p></div>";
scoretext = "<div class='score'><p>" + scoreLabelText.replace('{0}', Math.round(interaction.score*10)/10) + "</p></div>";
}
div.html('<h2><p>' +
name + '</p></h2>' +
Expand Down
Expand Up @@ -1006,7 +1006,7 @@
$targetHolder.find("input").each(function() {
var $this = $(this),
currvalue = !casesensitive ? $this.val().trim().toLowerCase() : $this.val().trim();
var feedback = "Incorrect"
var feedback = "Incorrect";
var correct = false;
var answer = currvalue;

Expand Down
Expand Up @@ -146,7 +146,11 @@
textCorrection.answer = answer;


var copyText = x_currentPageXML.getAttribute("copyText").trim();
var copyText = false;
if (x_currentPageXML.getAttribute("copyText") != undefined)
{
copyText = x_currentPageXML.getAttribute("copyText").trim();
}
var $textArea = $("#text");
if( copyText === "true"){
question = $("<div>").html(question).text().trim();
Expand Down
Expand Up @@ -4675,7 +4675,7 @@
<wrongText label="Incorrect Text" type="TextArea" height="150"/>
<answer label="Correct Text" type="TextArea" height="150"/>
<amountOfTries label="Attempts" type="TextInput" defaultValue="1" optional="true"/>
<copyText label="Copy Text" defaultValue="true" type="CheckBox" tooltip="Places the question in the text box"/>
<copyText label="Copy Text" defaultValue="false" type="CheckBox" optional="true" tooltip="Places the question in the text box"/>
<clarification type="group" label="Clarification" optional="true">
<showFurtherClarification label="Show Further Clarification" defaultValue="false" type="CheckBox"/>
<FurtherClarification label="Further Clarification" type="TextArea" height="50" tooltip="Add &quot;Show Further Clarification&quot; from the optional properties" defaultValue="Enter here further clarification"/>
Expand Down Expand Up @@ -5164,8 +5164,6 @@
<attemptLabel label="Attempt Label" type="TextInput" wysiwyg="false" language="true"/>

<checkBtnTxt label="Check Button Label" type="TextInput" wysiwyg="false" language="true"/>
<checkBtnTip label="Check Button Tip" type="textInput" language="false" deprecated="This property is no longer required"/>
<checkBtnWidth label="Check Button Width" type="NumericStepper" min="100" max="250" step="10" width="100" defaultValue="100" language="true" deprecated="Width is now set automatically"/>

<feedback type="TextArea" height="40" label="Feedback" optional="true" defaultValue="Enter your feedback here"/>

Expand Down
14 changes: 13 additions & 1 deletion modules/xerte/xAPI/xttracking_xapi.js
Expand Up @@ -1673,6 +1673,18 @@ function XTInitialise(category) {
}
);
*/

// // Check if aggretate is set for the lrsEndpoint, than assume this is learning locker and change normal API accordingly and save aggregate for XTGetStatements
// if (lrsEndpoint.indexOf("api/statements/aggregate/") >= 0)
// {
// state.aggregate = true;
// state.lrsAggregateEndpoint = lrsEndpont;
// apos = lrsEndpoint.indexOf("api/statements/aggregate");
// lrsEndpoint = lrsEndpoint.substr(0, lrsEndpoint.Length - apos) + 'data/xAPI';
// }
// else {
// state.aggregate = false;
// }
var conf = {
"endpoint": lrsEndpoint + '/',
"user": lrsUsername,
Expand Down Expand Up @@ -3214,7 +3226,7 @@ function XTResults(fullcompletion) {
correctAnswer = state.interactions[i].correctAnswers;
break;
}
if (state.interactions[i].ia_type != "match") {
if (state.interactions[i].ia_type != "match" && state.interactions[i].result != undefined) {
subinteraction.question = state.interactions[i].ia_name;
subinteraction.correct = state.interactions[i].result.success;
subinteraction.learnerAnswer = learnerAnswer;
Expand Down
4 changes: 1 addition & 3 deletions src/Nottingham/wizards/en-GB/template.xwd
Expand Up @@ -4675,7 +4675,7 @@
<wrongText label="Incorrect Text" type="TextArea" height="150"/>
<answer label="Correct Text" type="TextArea" height="150"/>
<amountOfTries label="Attempts" type="TextInput" defaultValue="1" optional="true"/>
<copyText label="Copy Text" defaultValue="true" type="CheckBox" tooltip="Places the question in the text box"/>
<copyText label="Copy Text" defaultValue="false" type="CheckBox" optional="true" tooltip="Places the question in the text box"/>
<clarification type="group" label="Clarification" optional="true">
<showFurtherClarification label="Show Further Clarification" defaultValue="false" type="CheckBox"/>
<FurtherClarification label="Further Clarification" type="TextArea" height="50" tooltip="Add &quot;Show Further Clarification&quot; from the optional properties" defaultValue="Enter here further clarification"/>
Expand Down Expand Up @@ -5164,8 +5164,6 @@
<attemptLabel label="Attempt Label" type="TextInput" wysiwyg="false" language="true"/>

<checkBtnTxt label="Check Button Label" type="TextInput" wysiwyg="false" language="true"/>
<checkBtnTip label="Check Button Tip" type="textInput" language="false" deprecated="This property is no longer required"/>
<checkBtnWidth label="Check Button Width" type="NumericStepper" min="100" max="250" step="10" width="100" defaultValue="100" language="true" deprecated="Width is now set automatically"/>

<feedback type="TextArea" height="40" label="Feedback" optional="true" defaultValue="Enter your feedback here"/>

Expand Down
2 changes: 1 addition & 1 deletion src/Nottingham/wizards/en-GB/textCorrection.xwd
Expand Up @@ -13,7 +13,7 @@
<wrongText label="Incorrect Text" type="TextArea" height="150"/>
<answer label="Correct Text" type="TextArea" height="150" />
<amountOfTries label="Attempts" type="TextInput" defaultValue="1" optional="true"/>
<copyText label="Copy Text" defaultValue="true" type="CheckBox" tooltip="Places the question in the text box"/>
<copyText label="Copy Text" defaultValue="false" type="CheckBox" optional="true" tooltip="Places the question in the text box"/>
<clarification type="group" label="Clarification" optional="true">
<showFurtherClarification label="Show Further Clarification" defaultValue="false" type="CheckBox"/>
<FurtherClarification label="Further Clarification" type="TextArea" height="50" tooltip='Add "Show Further Clarification" from the optional properties' defaultValue="Enter here further clarification"/>
Expand Down
2 changes: 0 additions & 2 deletions src/Nottingham/wizards/en-GB/topXQ.xwd
Expand Up @@ -26,8 +26,6 @@
<attemptLabel label="Attempt Label" type="TextInput" wysiwyg="false" language="true"/>

<checkBtnTxt label="Check Button Label" type="TextInput" wysiwyg="false" language="true" />
<checkBtnTip label="Check Button Tip" type="textInput" language="false" deprecated="This property is no longer required"/>
<checkBtnWidth label="Check Button Width" type="NumericStepper" min="100" max="250" step="10" width="100" defaultValue="100" language="true" deprecated="Width is now set automatically"/>

<feedback type="TextArea" height="40" label="Feedback" optional="true" defaultValue="Enter your feedback here"/>

Expand Down
14 changes: 13 additions & 1 deletion website_code/php/properties/properties_library.php
Expand Up @@ -22,6 +22,7 @@

require_once("../../../config.php");
require_once("../template_library.php");
require_once("../xAPI/xAPI_library.php");


_load_language_file("/website_code/php/properties/publish.inc");
Expand Down Expand Up @@ -598,12 +599,23 @@ function statistics_prepare($template_id)

$params = array($template_id);
$row = db_query_one($query_for_names, $params);
$row_sitedetails = db_query_one("select dashboard_allowed_links from {$prefix}sitedetails");
$row_sitedetails = db_query_one("select dashboard_allowed_links, LRS_Endpoint from {$prefix}sitedetails");

if ($row['tsugi_xapi_enabled'] && ($row['tsugi_xapi_useglobal'] || ($row['tsugi_xapi_endpoint'] != "" && $row['tsugi_xapi_key'] != "" && $row['tsugi_xapi_secret'] != ""))) {
$info->info = $html;
$lrsendpoint = array();
if ($row['tsugi_xapi_useglobal'])
{
$lrsendpoint['lrsendpoint'] = $row_sitedetails['LRS_Endpoint'];
}
else
{
$lrsendpoint['lrsendpoint'] = $row['tsugi_xapi_endpoint'];
}
$lrsendpoint = CheckLearningLocker($lrsendpoint);
$lrs = new stdClass();
$lrs->lrsendpoint = $xerte_toolkits_site->site_url . "xapi_proxy.php";
$lrs->lrs_use_aggregate = $lrsendpoint['aggregate'];

$lrs->lrskey = "";
$lrs->lrssecret = "";
Expand Down
17 changes: 17 additions & 0 deletions website_code/php/xAPI/xAPI_library.php
@@ -1,5 +1,22 @@
<?php


function CheckLearningLocker($lrs)
{
$apos = strpos($lrs['lrsendpoint'], 'api/statements/aggregate');
if ($apos !== false)
{
$lrs['aggregate'] = true;
$lrs['aggregateendpoint'] = $lrs['lrsendpoint'];
$lrs['lrsendpoint'] = substr($lrs['lrsendpoint'], 0, $apos) . 'data/xAPI';
}
else
{
$lrs['aggregate'] = false;
}
return $lrs;
}

function xAPI_html_page_create($id, $template_name, $type, $lo_name, $language) {

global $xerte_toolkits_site, $dir_path, $delete_file_array, $zipfile, $youtube_api_key;
Expand Down

0 comments on commit 141de58

Please sign in to comment.