ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCmiXapiVerbList.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
16 {
17  const COMPLETED = 'http://adlnet.gov/expapi/verbs/completed';
18  const PASSED = 'http://adlnet.gov/expapi/verbs/passed';
19  const FAILED = 'http://adlnet.gov/expapi/verbs/failed';
20  const SATISFIED = 'http://adlnet.gov/expapi/verbs/satisfied';
21  const PROGRESSED = 'http://adlnet.gov/expapi/verbs/progressed';
22  const EXPERIENCED = 'http://adlnet.gov/expapi/verbs/experienced';
23 
27  protected $verbs = array(
28  'http://adlnet.gov/expapi/verbs/abandoned',
29  'http://adlnet.gov/expapi/verbs/answered',
30  'http://adlnet.gov/expapi/verbs/asked',
31  'http://adlnet.gov/expapi/verbs/attempted',
32  'http://adlnet.gov/expapi/verbs/attended',
33  'http://adlnet.gov/expapi/verbs/commented',
34  'http://adlnet.gov/expapi/verbs/completed',
35  'http://adlnet.gov/expapi/verbs/exited',
36  'http://adlnet.gov/expapi/verbs/experienced',
37  'http://adlnet.gov/expapi/verbs/failed',
38  'http://adlnet.gov/expapi/verbs/imported',
39  'http://adlnet.gov/expapi/verbs/initialized',
40  'http://adlnet.gov/expapi/verbs/interacted',
41  'http://adlnet.gov/expapi/verbs/launched',
42  'http://adlnet.gov/expapi/verbs/mastered',
43  'http://adlnet.gov/expapi/verbs/passed',
44  'http://adlnet.gov/expapi/verbs/preferred',
45  'http://adlnet.gov/expapi/verbs/progressed',
46  'http://adlnet.gov/expapi/verbs/registered',
47  'http://adlnet.gov/expapi/verbs/responded',
48  'http://adlnet.gov/expapi/verbs/resumed',
49  'http://adlnet.gov/expapi/verbs/satisfied',
50  'http://adlnet.gov/expapi/verbs/scored',
51  'http://adlnet.gov/expapi/verbs/shared',
52  'http://adlnet.gov/expapi/verbs/suspended',
53  'http://adlnet.gov/expapi/verbs/terminated',
54  'http://adlnet.gov/expapi/verbs/voided'
55  );
56 
61  public function isValidVerb($verb)
62  {
63  return true;//not necessary for dynamic verbs: in_array($verb, $this->verbs);
64  }
65 
70  public function getVerbUri($verb)
71  {
72  return 'http://adlnet.gov/expapi/verbs/' . $verb;
73  }
74 
79  {
80  global $DIC; /* @var \ILIAS\DI\Container $DIC */
81 
82  $options = array(
83  '' => $DIC->language()->txt('cmix_all_verbs')
84  );
85 
86  foreach ($verbs as $verb) {
87  $verb = $verb['_id'];
88  $options[urlencode($verb)] = self::getVerbTranslation(
89  $DIC->language(),
90  $verb
91  );
92  }
93 
94  return $options;
95  }
96 
100  public function getSelectOptions()
101  {
102  global $DIC; /* @var \ILIAS\DI\Container $DIC */
103 
104  $options = array(
105  '' => $DIC->language()->txt('cmix_all_verbs')
106  );
107 
108  foreach ($this->verbs as $verb) {
109  $options[urlencode($verb)] = self::getVerbTranslation(
110  $DIC->language(),
111  $verb
112  );
113  }
114 
115  return $options;
116  }
117 
123  public static function getVerbTranslation(ilLanguage $lng, $verb)
124  {
125  $verbMatch = preg_match('/\/([^\/]+)$/', $verb, $matches);
126  $shortVerb = $matches[1];
127  $langVar = preg_replace('/http(s)?:\/\//', '', $verb);
128  $langVar = str_replace('.', '', $langVar);
129  $langVar = str_replace('/', '_', $langVar);
130  $langVar = 'cmix_' . $langVar;
131  $translatedVerb = $lng->txt($langVar);
132  // check no translation found?
133  if (strpos($translatedVerb, '-cmix_') === 0) {
134  return $shortVerb;
135  } else {
136  return $translatedVerb;
137  }
138  }
139 
143  public static function getInstance()
144  {
145  return new self();
146  }
147 }
static getVerbTranslation(ilLanguage $lng, $verb)
$lng
global $DIC
Definition: goto.php:24
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...