Commit a7ee7164 authored by Rich Lott / Artful Robot's avatar Rich Lott / Artful Robot
Browse files

(custom) updates to fixul.php

parent 84f3c119
......@@ -3,27 +3,79 @@ use Civi\Hark\Survey;
use Civi\Hark\Participant;
use Civi\Api4\HarkParticipant;
print "STOP!\n"; exit ; /// xxx
if (php_sapi_name() !== 'cli') {
http_response_code(404);
echo "404 Not Found";
exit;
}
// UL19
$surveyID = 3;
// ul21
$surveyID = 8;
// UL19 $surveyID = 3;
// ul21 $surveyID = 8;
// ul22
$surveyID = 16;
/*
$survey = \Civi\Hark\Survey::newFromSurveyID($surveyID);
$def = $survey->getDefinition();
foreach ($def['parts'] as &$part) {
if (($part['codeName'] ?? NULL)[0] === '_') {
if (empty($part['legacy']['codeName'])) {
print "fixed part: " . json_encode(['id' => $part['id'], 'codeName' => $part['codeName'] ?? NULL, 'legacyQuestionID' => $part['legacyQuestionID']] ) . "\n";
unset($part['codeName']);
$codeName = $part['codeName'] ?? '';
if (preg_match('/^(s\d+_)(.*)$/', $codeName, $matches)) {
$new = [
's1_' => 'paw_',
's2_' => 'sta_',
's3_' => 'ems_',
's4_' => 'eib_',
's5_' => 'mc_',
's6_' => 'wr_',
's7_' => 'sf_',
's8_' => 'sse_',
's9_' => 'esd_',
's10_' => 'es_',
's11_' => 'wrg_',
's12_' => 'cr_',
's13_' => 'wrn_',
][$matches[1]] ?? '';
if ($new) {
$new .= $matches[2];
print "$codeName$new\n";
$part['codeName'] = $new;
}
}
elseif (preg_match('/^section_(\d+)(.*)$/', $codeName, $matches)) {
$new = [
'1' => 'paw',
'2' => 'sta',
'3' => 'ems',
'4' => 'eib',
'5' => 'mc',
'6' => 'wr',
'7' => 'sf',
'8' => 'sse',
'9' => 'esd',
'10' => 'es',
'11' => 'wrg',
'12' => 'cr',
'13' => 'wrn',
][$matches[1]] ?? '';
if ($new) {
$new = 'section_' . $new . $matches[2];
print "$codeName$new\n";
$part['codeName'] = $new;
}
}
elseif (preg_match('/^(sns|sna|snq|uaq|snp|cnq|saa|)_/', $codeName)) {
// legacy - remoe.
$part['codeName'] = '';
}
else {
if ($codeName) print "xx $codeName\n";
}
// Strip out old guff
unset($part['legacy']);
unset($part['legacyQuestionID']);
$part['acl'] = [ 'uni' => 'view', 'admin' => 'edit'];
// print json_encode($part) . "\n";
}
$def['parts'] = array_values($def['parts']);
\Civi\Api4\HarkSurvey::update(FALSE)
......@@ -31,8 +83,8 @@ $def['parts'] = array_values($def['parts']);
->addValue('definition', json_encode($def))
->execute();
*/
print "SAVED\n";
exit;
// Load this once.
$survey = Survey::newFromSurveyID($surveyID);
......
Supports Markdown
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