Skip to content
Snippets Groups Projects
Commit 9be64856 authored by Kevin Rice's avatar Kevin Rice
Browse files

adds device column fixes

parent da5783fb
No related branches found
Tags 4.0.0-beta1
No related merge requests found
......@@ -6,4 +6,13 @@ simple_survey:
- simple_survey/simple_survey_js
css:
component:
dist/styles.css: { minified: true }
css/override.css: {}
simple_survey_js:
js:
dist/main.bundle.js: { minified: true }
dependencies:
- simple_survey/simple_survey_vendors
simple_survey_vendors:
js:
dist/vendors.bundle.js: { minified: true }
\ No newline at end of file
......@@ -267,35 +267,3 @@ function simple_survey_theme() {
],
];
}
/**
* Implements hook_library_info_build().
*/
function simple_survey_library_info_build() {
// Relative path to the build directory of CRA.
$cra_path = DRUPAL_ROOT . "/" . \Drupal::service('extension.list.module')->getPath('simple_survey');
$manifest_path = $cra_path . '/dist/manifest.json';
$libraries = [];
$library_name = 'simple_survey_js';
// Load the manifest file and decode it.
$manifest = json_decode(
file_get_contents($manifest_path),
TRUE
);
// Loop through the manifest and build the library definition.
foreach ($manifest as $key => $realpath) {
if (substr($key, -strlen('css')) === 'css') {
$libraries[$library_name]['css']['component'][$realpath] = [
'minified' => true,
];
}
else if (substr($key, -strlen('js')) === 'js') {
$libraries[$library_name]['js'][$realpath] = [
'minified' => true,
];
}
}
return $libraries;
}
......@@ -10,7 +10,6 @@ use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\simple_survey\Entity\SurveyResponse;
use Drupal\simple_survey\Entity\SurveyAnswer;
use Drupal\Core\Entity\EntityStorageException;
......@@ -22,9 +21,7 @@ use Drupal\simple_survey\Service\BigQueryConnect;
use Drupal\simple_survey\Service\ResponseExportService;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\simple_survey\Entity\SimpleSurvey;
use Drupal\simple_survey\Entity\SimpleSurveyInterface;
use Drupal\simple_survey\Entity\SurveyQuestion;
......@@ -386,7 +383,7 @@ class SimpleSurveyRestController extends ControllerBase {
$surveyResponse->set('created', $this->time->getRequestTime());
$surveyResponse->set('site_path', $sitePath);
$surveyResponse->set('site_path', $device);
$surveyResponse->set('device', $device);
$surveyResponse->set('langcode', Html::escape($request->get('language', 'en')));
try {
......
......@@ -240,6 +240,11 @@ class BigQueryConnect {
'name' => 'site_path',
'type' => 'STRING',
],
[
'description' => "User's device",
'name' => 'device',
'type' => 'STRING',
],
[
'description' => 'The language of the submission',
'name' => 'langcode',
......
......@@ -9,7 +9,6 @@ use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use SplTempFileObject;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Messenger\Messenger;
use Drupal\Core\Url;
......@@ -17,7 +16,6 @@ use Drupal\simple_survey\Entity\SimpleSurvey;
use Drupal\simple_survey\Entity\SurveyAnswer;
use Drupal\simple_survey\Entity\SurveyQuestion;
use Drupal\simple_survey\Entity\SurveyResponse;
use SplFileObject;
/**
* Survey Response convert and export service.
......@@ -138,8 +136,6 @@ class ResponseExportService implements ContainerInjectionInterface {
$this->entityTypeManager = $entity_type_manager;
$this->logger = $loggerFactory->get($this->moduleName);
$this->time = $time;
$this->simpleSurveyConfig = $this->configFactory->getEditable($this->moduleName . '.settings');
}
/**
......@@ -378,7 +374,7 @@ class ResponseExportService implements ContainerInjectionInterface {
. '/' . $filename;
if (empty($context['sandbox'])) {
$file = new SplFileObject($filepath, 'w');
$file = new \SplFileObject($filepath, 'w');
$context['sandbox']['headers'] = self::createHeaderRow($survey);
$context['sandbox']['max'] = self::getResponseCount($survey);
$context['sandbox']['progress'] = 0;
......@@ -388,7 +384,7 @@ class ResponseExportService implements ContainerInjectionInterface {
$file->fputcsv($context['sandbox']['headers']['columns']);
}
else {
$file = new SplFileObject($filepath, 'a');
$file = new \SplFileObject($filepath, 'a');
}
$max = $context['sandbox']['progress'] + $batch_size;
......@@ -440,7 +436,7 @@ class ResponseExportService implements ContainerInjectionInterface {
. '/' . $filename;
if (empty($context['sandbox'])) {
$file = new SplFileObject($filepath, 'w');
$file = new \SplFileObject($filepath, 'w');
$context['sandbox']['headers'] = self::createHeaderRow($survey);
$context['sandbox']['max'] = $db->select('survey_response', 'sr')
->condition('sr.survey', $survey)
......@@ -454,7 +450,7 @@ class ResponseExportService implements ContainerInjectionInterface {
$file->fputcsv($context['sandbox']['headers']['columns']);
}
else {
$file = new SplFileObject($filepath, 'a');
$file = new \SplFileObject($filepath, 'a');
}
$max = $context['sandbox']['progress'] + $batch_size;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment