Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature #17226: Ability to export to SPSS .sav format (#1877)
- Loading branch information
1 parent
3963f29
commit 0662c99
Showing
414 changed files
with
66,596 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
class ExportSPSSsav extends \LimeSurvey\PluginManager\PluginBase | ||
{ | ||
|
||
protected $storage = 'DbStorage'; | ||
|
||
static protected $description = 'Core: Export survey results to an SPSS sav file'; | ||
static protected $name = 'SPSS Export'; | ||
|
||
public function init() | ||
{ | ||
/** | ||
* Here you should handle subscribing to the events your plugin will handle | ||
*/ | ||
$this->subscribe('listExportPlugins'); | ||
$this->subscribe('listExportOptions'); | ||
$this->subscribe('newExport'); | ||
} | ||
|
||
protected $settings = array( | ||
'spssfileversion' => array( | ||
'type' => 'select', | ||
'label' => 'Export for SPSS', | ||
'options' => array('16' => 'versions 14 and above', '13' => 'version 13 and below (limited string length)'), | ||
'default' => '16', | ||
'submitonchange'=> false | ||
) | ||
); | ||
|
||
public function listExportOptions() | ||
{ | ||
$event = $this->getEvent(); | ||
$type = $event->get('type'); | ||
|
||
switch ($type) { | ||
case 'spsssav': | ||
$event->set('label', gT("SPSS (.sav)")); | ||
$event->set('onclick', ' | ||
document.getElementById("answers-short").checked=true; | ||
document.getElementById("answers-long").disabled=true; | ||
document.getElementById("converty").checked=true; | ||
document.getElementById("convertn").checked=true; | ||
document.getElementById("convertnto").value=0; | ||
document.getElementById("convertyto").value=1; | ||
document.getElementById("headstyle-code").disabled=true; | ||
document.getElementById("headstyle-abbreviated").disabled=true; | ||
document.getElementById("headstyle-full").checked=true; | ||
document.getElementById("headstyle-codetext").disabled=true; | ||
'); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
* Registers this export type | ||
*/ | ||
public function listExportPlugins() | ||
{ | ||
$event = $this->getEvent(); | ||
$exports = $event->get('exportplugins'); | ||
|
||
// Yes we overwrite existing classes if available | ||
$exports['spsssav'] = get_class(); | ||
$event->set('exportplugins', $exports); | ||
} | ||
|
||
/** | ||
* Returns the required IWriter | ||
*/ | ||
public function newExport() | ||
{ | ||
$event = $this->getEvent(); | ||
|
||
$pluginsettings = $this->getPluginSettings(true); | ||
$writer = new SPSSWriter($pluginsettings); | ||
$event->set('writer', $writer); | ||
} | ||
} |
Oops, something went wrong.
0662c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit breaks survey logic file view for some surveys using BigInteger class.
Class 'phpseclib\Math\BigInteger' not found
Possible fix, to use phpseclib3 instead, but must check for php compatibility.
0662c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
43 "phpseclib/bcmath_compat": "^2.0"
I think locking bcmath_compat to version 1 was the problem. But you'd have to try your SPSS feature after the changes.
0662c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamzammit Please test your feature on the latest master commits.
0662c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @olleharstedt . Just tested on commit 59ad72d and seems fine
0662c99
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great :)