00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("content/classes/class.ilObjAICCLearningModule.php");
00025 require_once("content/classes/AICC/class.ilAICCObjectGUI.php");
00026 require_once("content/classes/SCORM/class.ilSCORMPresentationGUI.php");
00027
00028
00039 class ilAICCPresentationGUI extends ilSCORMPresentationGUI
00040 {
00041 var $ilias;
00042 var $slm;
00043 var $tpl;
00044 var $lng;
00045
00046 function ilAICCPresentationGUI()
00047 {
00048 global $ilias, $tpl, $lng, $ilCtrl;
00049
00050 $this->ilias =& $ilias;
00051 $this->tpl =& $tpl;
00052 $this->lng =& $lng;
00053 $this->ctrl =& $ilCtrl;
00054
00055 $cmd = (!empty($_GET["cmd"])) ? $_GET["cmd"] : "frameset";
00056
00057
00058 $this->slm =& new ilObjAICCLearningModule($_GET["ref_id"], true);
00059 }
00060
00064 function &executeCommand()
00065 {
00066 global $ilAccess, $ilLog;
00067
00068 $next_class = $this->ctrl->getNextClass($this);
00069 $cmd = $this->ctrl->getCmd("frameset");
00070
00071 if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00072 {
00073 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
00074 }
00075
00076 switch($next_class)
00077 {
00078 default:
00079 $this->$cmd();
00080 }
00081 }
00082
00083 function view()
00084 {
00085 $sc_gui_object =& ilAICCObjectGUI::getInstance($_GET["obj_id"]);
00086
00087 if(is_object($sc_gui_object))
00088 {
00089 $sc_gui_object->view();
00090 }
00091
00092 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00093 $this->tpl->show();
00094 }
00095
00099 function explorer($a_target = "sahs_content")
00100 {
00101 $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, true);
00102
00103
00104 require_once("./content/classes/AICC/class.ilAICCExplorer.php");
00105 $exp = new ilAICCExplorer(
00106 $this->ctrl->getLinkTarget($this, "view"), $this->slm);
00107 $exp->setTargetGet("obj_id");
00108 $exp->setFrameTarget($a_target);
00109
00110
00111 if ($_GET["scexpand"] == "")
00112 {
00113 $mtree = new ilSCORMTree($this->slm->getId());
00114 $expanded = $mtree->readRootId();
00115 }
00116 else
00117 {
00118 $expanded = $_GET["scexpand"];
00119 }
00120 $exp->setExpand($expanded);
00121
00122 $exp->forceExpandAll(true, false);
00123
00124
00125
00126 $exp->setOutput(0);
00127
00128 $output = $exp->getOutput();
00129
00130 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00131 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00132 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
00133 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
00134 $this->tpl->setVariable("EXPLORER",$output);
00135 $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, $_GET["cmd"])."&frame=".$_GET["frame"].
00136 "&ref_id=".$this->slm->getRefId()."&scexpand=".$_GET["scexpand"]);
00137 $this->tpl->parseCurrentBlock();
00138 $this->tpl->show();
00139 }
00140
00141 function launchSahs()
00142 {
00143 global $ilUser, $ilDB;
00144
00145 $sahs_id = ($_GET["sahs_id"] == "")
00146 ? $_POST["sahs_id"]
00147 : $_GET["sahs_id"];
00148 $ref_id = ($_GET["ref_id"] == "")
00149 ? $_POST["ref_id"]
00150 : $_GET["ref_id"];
00151
00152 $this->slm =& new ilObjAICCLearningModule($ref_id, true);
00153
00154 include_once("content/classes/AICC/class.ilAICCUnit.php");
00155 $unit =& new ilAICCUnit($sahs_id);
00156
00157
00158 $url=$unit->getCommand_line();
00159 if (strlen($url)==0)
00160 $url=$unit->getFilename();
00161 if (strcasecmp(substr($unit->getFilename(),0,4),"http")!=0)
00162 $url=$this->slm->getDataDirectory("output")."/".$url;
00163 if (strlen($unit->getWebLaunch())>0)
00164 $url.="?".$unit->getWebLaunch();
00165
00166
00167
00168
00169
00170
00171 $this->tpl = new ilTemplate("tpl.sahs_launch_cbt.html", true, true, true);
00172 $this->tpl->setVariable("HREF", $url);
00173
00174 $this->tpl->setVariable("MAST_SCORE", $unit->getMasteryScore());
00175 $this->tpl->setVariable("MAX_TIME", $unit->getMaxTimeAllowed());
00176 $this->tpl->setVariable("LIMIT_ACT", $unit->getTimeLimitAction());
00177 if($ilUser->getFirstName() == "Joe")
00178 {
00179 $this->tpl->setCurrentBlock("credit");
00180 $this->tpl->setVariable("CREDIT_MODE", "normal");
00181 $this->tpl->parseCurrentBlock();
00182 }
00183 $query = "SELECT * FROM scorm_tracking WHERE".
00184 " user_id = ".$ilDB->quote($ilUser->getId()).
00185 " AND sco_id = ".$ilDB->quote($sahs_id);
00186
00187
00188 $val_set = $ilDB->query($query);
00189 $re_value = array();
00190 while($val_rec = $val_set->fetchRow(DB_FETCHMODE_ASSOC))
00191 {
00192 $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
00193 $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
00194 $val_rec["rvalue"] = str_replace("\n", "%n%", $val_rec["rvalue"]);
00195 $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
00196 }
00197
00198 foreach($re_value as $var => $value)
00199 {
00200 switch ($var)
00201 {
00202 case "cmi.core.lesson_location":
00203 case "cmi.core.lesson_status":
00204 case "cmi.core.entry":
00205 case "cmi.core.score.raw":
00206 case "cmi.core.score.max":
00207 case "cmi.core.score.min":
00208 case "cmi.core.total_time":
00209 case "cmi.core.exit":
00210 case "cmi.suspend_data":
00211 case "cmi.comments":
00212 case "cmi.student_preference.audio":
00213 case "cmi.student_preference.language":
00214 case "cmi.student_preference.speed":
00215 case "cmi.student_preference.text":
00216 $this->setSingleVariable($var, $value);
00217 break;
00218
00219 case "cmi.objectives._count":
00220 $this->setSingleVariable($var, $value);
00221 $this->setArray("cmi.objectives", $value, "id", $re_value);
00222 $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
00223 $this->setArray("cmi.objectives", $value, "score.max", $re_value);
00224 $this->setArray("cmi.objectives", $value, "score.min", $re_value);
00225 $this->setArray("cmi.objectives", $value, "status", $re_value);
00226 break;
00227
00228 case "cmi.interactions._count":
00229 $this->setSingleVariable($var, $value);
00230 $this->setArray("cmi.interactions", $value, "id", $re_value);
00231 for($i=0; $i<$value; $i++)
00232 {
00233 $var2 = "cmi.interactions.".$i.".objectives._count";
00234 if (isset($v_array[$var2]))
00235 {
00236 $cnt = $v_array[$var2];
00237 $this->setArray("cmi.interactions.".$i.".objectives",
00238 $cnt, "id", $re_value);
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 }
00249 }
00250 $this->setArray("cmi.interactions", $value, "time", $re_value);
00251 $this->setArray("cmi.interactions", $value, "type", $re_value);
00252 for($i=0; $i<$value; $i++)
00253 {
00254 $var2 = "cmi.interactions.".$i.".correct_responses._count";
00255 if (isset($v_array[$var2]))
00256 {
00257 $cnt = $v_array[$var2];
00258 $this->setArray("cmi.interactions.".$i.".correct_responses",
00259 $cnt, "pattern", $re_value);
00260 $this->setArray("cmi.interactions.".$i.".correct_responses",
00261 $cnt, "weighting", $re_value);
00262 }
00263 }
00264 $this->setArray("cmi.interactions", $value, "student_response", $re_value);
00265 $this->setArray("cmi.interactions", $value, "result", $re_value);
00266 $this->setArray("cmi.interactions", $value, "latency", $re_value);
00267 break;
00268 }
00269 }
00270
00271 global $lng;
00272 $this->tpl->setCurrentBlock("switch_icon");
00273 $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
00274 $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.gif"));
00275 $this->tpl->setVariable("SCO_ALT",
00276 $lng->txt("cont_status").": "
00277 .$lng->txt("cont_sc_stat_running")
00278 );
00279 $this->tpl->parseCurrentBlock();
00280
00281
00282 $lesson_mode = $this->slm->getDefaultLessonMode();
00283 if ($this->slm->getAutoReview())
00284 {
00285 if ($re_value["cmi.core.lesson_status"] == "completed" ||
00286 $re_value["cmi.core.lesson_status"] == "passed" ||
00287 $re_value["cmi.core.lesson_status"] == "failed")
00288 {
00289 $lesson_mode = "review";
00290 }
00291 }
00292 $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
00293
00294
00295 if ($lesson_mode == "normal")
00296 {
00297 $this->tpl->setVariable("CREDIT_MODE",
00298 str_replace("_", " ", $this->slm->getCreditMode()));
00299 }
00300 else
00301 {
00302 $this->tpl->setVariable("CREDIT_MODE", "no-credit");
00303 }
00304
00305
00306 $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
00307
00308 if (!isset($re_value["cmi.core.total_time"]))
00309 {
00310 $unit->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
00311 }
00312 if (!isset($re_value["cmi.core.lesson_status"]))
00313 {
00314 $unit->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
00315 }
00316 if (!isset($re_value["cmi.core.entry"]))
00317 {
00318 $unit->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
00319 }
00320
00321 $this->tpl->show();
00322 }
00323
00324 }
00325 ?>