Commit cea691f4 authored by ewelinarybczynska's avatar ewelinarybczynska
Browse files

regex for notes fixed

parent 47340249
......@@ -5,20 +5,20 @@ const USER = 'prov:wasAssociatedWith lokiuser:(\S+) ;\s+';
const DESCRIPTION = 'dc:description "\w+" ;\s+';
const WHAT_WAS_DONE = 'loki:whatWasDone "[\w\s]+" ;\s+';
const WHY_WAS_DONE = 'loki:whyWasDone "[\w\s]+" ;\s+';
const CLASSES_CHANGE = 'prov:used [\w\s,]+;\s+loki:classesChange "\d";\s+';
const RELATIONS_CHANGE = 'loki:relationsChange "\d";\s+';
const ATTRIBUTES_CHANGE = 'loki:attributesChange "\d";\s+';
const STATEMENTS_CHANGE = 'loki:statementsChange "\d";\s+';
const TEST_PASSED = 'loki:testsPassed \[ loki:valueBefore "\d+" ; loki:valueAfter "(\d+)" \] ;\s+';
const ATTRIBUTE_RICHNESS = 'loki:AttributeRichness \[ loki:valueBefore "\d"; loki:valueAfter "\d" \] ;\s+';
const AVERAGE_POPULATION = 'loki:AveragePopulation \[ loki:valueBefore "\d"; loki:valueAfter "\d" \] ;\s+';
const SIZE_OF_VOCABULARY = 'loki:SizeOfVocabulary \[ loki:valueBefore "\d"; loki:valueAfter "\d" \] ;\s+';
const EDGE_NODE_RATIO = 'loki:EdgeNodeRatio \[ loki:valueBefore "\d"; loki:valueAfter "\d" \] ;\s+';
const WEIGHTED_AVERAGE = 'loki:weightedAverage "(\d+\.?\d*)" ;\s+';
const EVALUATED_BY_USER = 'loki:evaluatedByUser\s(.+)';
const PROV = 'prov:used .+;\s+';
const CLASSES_CHANGE = 'loki:classesChange "\d";\s+';
const RELATIONS_CHANGE = 'loki:relationsChange "\d?";\s+';
const ATTRIBUTES_CHANGE = 'loki:attributesChange "\d?";\s+';
const STATEMENTS_CHANGE = 'loki:statementsChange "\d?";\s+';
const TEST_PASSED = 'loki:testsPassed \[ loki:valueBefore "\d+"\s+; loki:valueAfter "(\d+)" \] ;\s+';
const ATTRIBUTE_RICHNESS = 'loki:attributeRichness \[ loki:valueBefore "\d?"; loki:valueAfter "\d?" \] ;\s+';
const AVERAGE_POPULATION = 'loki:averagePopulation \[ loki:valueBefore "\d?"; loki:valueAfter "\d?" \] ;\s+';
const SIZE_OF_VOCABULARY = 'loki:sizeOfVocabulary \[ loki:valueBefore "\d?"; loki:valueAfter "\d?" \] ;\s+';
const EDGE_NODE_RATIO = 'loki:edgeNodeRatio \[ loki:valueBefore "\d?"; loki:valueAfter "\d?" \] ;\s+';
const WEIGHTED_AVERAGE = 'loki:weightedAverage "(\d+\.?\d*)"\s+.';
define ("USER_PATTERN", '/' . EVENT . USER . DESCRIPTION . WHAT_WAS_DONE . WHY_WAS_DONE . CLASSES_CHANGE
define ("USER_PATTERN", '/' . EVENT . USER . DESCRIPTION . WHAT_WAS_DONE . WHY_WAS_DONE . PROV . CLASSES_CHANGE
. RELATIONS_CHANGE . ATTRIBUTES_CHANGE . STATEMENTS_CHANGE . TEST_PASSED . ATTRIBUTE_RICHNESS
. AVERAGE_POPULATION . SIZE_OF_VOCABULARY . EDGE_NODE_RATIO . WEIGHTED_AVERAGE . EVALUATED_BY_USER . '/');
. AVERAGE_POPULATION . SIZE_OF_VOCABULARY . EDGE_NODE_RATIO . WEIGHTED_AVERAGE . '/');
define("NOTE_PATTERN", '/\d/');
\ No newline at end of file
......@@ -122,6 +122,8 @@ class action_plugin_wikigame_wikigame extends DokuWiki_Action_Plugin
$fileContent = file_get_contents($pathName, true);
preg_match_all(USER_PATTERN, $fileContent, $matches);
file_put_contents('php://stderr', print_r($matches, TRUE));
$names = $matches[3];
for ($i = 0; $i <= sizeof($names) - 1; $i++) {
......@@ -134,19 +136,27 @@ class action_plugin_wikigame_wikigame extends DokuWiki_Action_Plugin
$weightedAverage = $matches[5][$i];
$event = $matches[1][$i];
preg_match_all(NOTE_PATTERN, $matches[6][$i], $notes);
$evaluatedByUserPattern = '/lokievent:edited_(\w+)_' . $date . ' loki:evaluatedByUser\s(.+)/';
preg_match_all($evaluatedByUserPattern, $fileContent, $evaluatedByUser);
$notes = array();
for ($i = 0; $i < sizeof($evaluatedByUser[2]) - 1; $i++) {
preg_match_all(NOTE_PATTERN, $evaluatedByUser[2][$i], $note);
array_push($notes, $note[0][0]);
}
if (array_key_exists($userName, $users)) {
$currentUser = $users[$userName];
$currentUser->updateAllSingleEvent($event);
if ($currentTime - $date < WEEK) {
$currentUser->updateUserWithEvent($event, $weightedAverage, $testPassed, $notes[0]);
$currentUser->updateUserWithEvent($event, $weightedAverage, $testPassed, $notes);
}
} else {
$newUser = new User($userName, $weightedAverage, $testPassed, $notes[0]);
$newUser = new User($userName, $weightedAverage, $testPassed, $notes);
$newUser->updateAllSingleEvent($event);
if ($currentTime - $date < WEEK) {
$newUser->updateUserWithEvent($event, $weightedAverage, $testPassed, $notes[0]);
$newUser->updateUserWithEvent($event, $weightedAverage, $testPassed, $notes);
}
$users[$userName] = $newUser;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment