v1.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace zin;
  3. requireWg('thinkQuestion');
  4. class thinkScore extends thinkQuestion
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array
  10. (
  11. 'fields?: array', // 列标题
  12. 'setOption?: bool=false', // 选项配置方式
  13. 'quoteTitle?: string', // 列标题
  14. 'quoteQuestions?: array', // 引用问题
  15. 'citation?: int=1', // 引用方式
  16. 'selectColumn?: string', // 选择列
  17. 'scoreSetting?: string=0', // 分制设置
  18. 'criterions5?: array', // 5分制的评分标准
  19. 'criterions10?: array', // 10分制的评分标准
  20. );
  21. public static function getPageCSS()
  22. {
  23. $baseCss = file_get_contents(dirname(__FILE__, 2) . DS . 'thinkstepbase' . DS . 'css' . DS . 'v1.css');
  24. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css') . $baseCss;
  25. }
  26. protected function buildDetail()
  27. {
  28. global $lang;
  29. $detailWg = parent::buildDetail();
  30. list($step, $scoreSetting, $criterions5, $criterions10) = $this->prop(array('step', 'scoreSetting', 'criterions5', 'criterions10'));
  31. if($step)
  32. {
  33. $fields = !empty($step->options->fields) ? $step->options->fields : array();
  34. $scoreSetting = isset($step->options->scoreSetting) ? $step->options->scoreSetting : '0';
  35. $quoteTitleList = !empty($step->options->quoteTitle) ? explode(", ", $step->options->quoteTitle) : array();
  36. $criterions5 = isset($step->options->criterions5) ? $step->options->criterions5 : $lang->thinkwizard->criterion->defaultCriteria5;
  37. $criterions10 = isset($step->options->criterions10) ? $step->options->criterions10 : $lang->thinkwizard->criterion->defaultCriteria10;
  38. $answer = $step->answer;
  39. $result = !empty($answer->result) ? $answer->result : array();
  40. }
  41. if(empty($fields) && !empty($quoteTitleList)) $fields = array($lang->thinkwizard->previewSteps->objectReference, $lang->thinkwizard->previewSteps->objectReference,$lang->thinkwizard->previewSteps->objectReference);
  42. $scoreCount = $scoreSetting == '0' ? 5 : 10;
  43. $items = array();
  44. $radioItems = array();
  45. $criterions = $scoreSetting == '0' ? $criterions5 : $criterions10;
  46. for($i=1; $i<=$scoreCount; $i++){$items[] = array('text' => $i, 'value' => $i, 'disabledPrefix' => true, 'title' => $criterions[$i - 1]);}
  47. foreach ($fields as $index => $field)
  48. {
  49. $radioItems[] = array(
  50. div(setClass('my-1 text-md leading-5 break-words'), $field),
  51. thinkBaseCheckbox
  52. (
  53. set::type('radio'),
  54. set::items($items),
  55. set::name('result[' . $index . ']'),
  56. set::value(!empty($result[$index]) ? $result[$index] : ''),
  57. set::inline(true),
  58. set::disabled(false)
  59. )
  60. );
  61. }
  62. $detailWg[] = div(setClass('score-content', $scoreSetting == '0' ? 'score-5' : 'score-10'), $radioItems);
  63. return $detailWg;
  64. }
  65. }