Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bug/17773-master--Code-name-change-while-w…
…e-updated-from-Edit-Question-screen
- Loading branch information
Showing
636 changed files
with
30,583 additions
and
56,102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
use \tebazil\yii1seeder\Seeder; | ||
|
||
class IdValidator | ||
{ | ||
private $bag; | ||
private $original; | ||
public function __construct($bag) | ||
{ | ||
$this->bag = $bag; | ||
$this->original = $bag; | ||
} | ||
public function __invoke($nr) | ||
{ | ||
if (!isset($this->bag[$nr - 1])) { | ||
return false; | ||
} else { | ||
unset($this->bag[$nr - 1]); | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
class DbSeederCommand extends CConsoleCommand | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function run($args) | ||
{ | ||
$seeder = new Seeder(); | ||
$generator = $seeder->getGeneratorConfigurator(); | ||
$faker = $generator->getFakerConfigurator(); | ||
|
||
// Generate surveys | ||
$sids = [1, 2, 3]; | ||
$sidValidator = new IdValidator($sids); | ||
$seeder->table('{{surveys}}')->columns( | ||
[ | ||
'sid' => $faker->unique()->numberBetween(1, 3), | ||
'owner_id' => 1, | ||
'language' => 'en' | ||
] | ||
)->rowQuantity(3); | ||
|
||
// Generate survey text | ||
$sidValidator = new IdValidator($sids); | ||
$seeder->table('{{surveys_languagesettings}}')->columns( | ||
[ | ||
'surveyls_survey_id' => $faker->unique(true)->numberBetween(1, 4), | ||
'surveyls_language' => 'en', | ||
'surveyls_title' => 'mo' | ||
] | ||
)->rowQuantity(3); | ||
|
||
// Generate groups | ||
$gids = [1, 2, 3, 4, 5]; | ||
$gidValidator = new IdValidator($gids); | ||
$seeder->table('{{groups}}')->columns( | ||
[ | ||
'gid' => $faker->unique(true)->numberBetween(1, 10), | ||
'sid' => $faker->numberBetween(1, 3), | ||
] | ||
)->rowQuantity(10); | ||
$seeder->refill(); | ||
return; | ||
|
||
// Generate questions | ||
$qids = [1, 2, 3, 4, 5, 6, 7]; | ||
$qidValidator = new IdValidator($qids); | ||
$seeder->table('{{questions}}')->columns( | ||
[ | ||
'qid' => $faker->valid($qidValidator)->randomElement($qids), | ||
'sid' => $faker->randomElement($sids), | ||
'gid' => $faker->randomElement($gids), | ||
] | ||
)->rowQuantity(count($qids)); | ||
|
||
$i = 0; | ||
$seeder->table('{{answers}}')->columns( | ||
[ | ||
'aid', | ||
'qid' => function () use (&$i) { | ||
return $i++; | ||
}, | ||
'code' => $faker->uuid, | ||
'sortorder' => function () use (&$i) { | ||
return $i++; | ||
}, | ||
'assessment_value' => function () { return rand(1, 10); } | ||
] | ||
)->rowQuantity(30); | ||
|
||
$seeder->refill(); | ||
} | ||
} |
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
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
Oops, something went wrong.