$tempkey = strtolower($key);
$_POST[$tempkey] = $value;
}
-
+
$command = required_param('command', PARAM_ALPHA);
$sessionid = required_param('session_id', PARAM_ALPHANUM);
$aiccdata = optional_param('aicc_data', '', PARAM_RAW);
$value = '';
if (is_numeric($values[0])) {
- $value = trim($values[0]);
+ $value = trim($values[0]);
$id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
$score = $value;
echo "error=3\r\nerror_text=Invalid Session ID\r\n";
}
}
-?>
\ No newline at end of file
-<?php //$Id$
+<?php
//This php script contains all the stuff to backup/restore
//scorm mods
//This is the "graphical" structure of the scorm mod:
//
- // scorm
+ // scorm
// (CL,pk->id)-------------------------------------
// | |
// | |
fwrite ($bf,full_tag("UPDATEFREQ",4,false,$scorm->updatefreq));
fwrite ($bf,full_tag('TIMEMODIFIED',4,false,$scorm->timemodified));
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);
-
+
//if we've selected to backup users info, then execute backup_scorm_scoes_track
if ($status) {
if (backup_userdata_selected($preferences,'scorm',$scorm->id)) {
}
return $status;
}
-
+
//Backup scorm_scoes_data contents (executed from scorm_backup_scorm_scoes)
function backup_scorm_scoes_data ($bf,$preferences,$sco) {
global $CFG, $DB;
}
return $status;
}
-
+
//Backup scorm_scoes_track contents (executed from scorm_backup_mods)
function backup_scorm_scoes_track ($bf,$preferences,$scorm) {
global $CFG, $DB;
$status =fwrite ($bf,start_tag('SEQ_RULECONDS',4,true));
//Iterate over each sco
foreach ($scorm_seq_ruleconditions as $seq_rulecondition) {
- //Start sco
+ //Start sco
$status =fwrite ($bf,start_tag('SEQ_RULECOND',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$seq_rulecondition->id));
$status =fwrite ($bf,start_tag('SEQ_RULECOND_DATAS',4,true));
//Iterate over each sco
foreach ($scorm_seq_ruleconditions as $seq_rulecondition) {
- //Start sco
+ //Start sco
$status =fwrite ($bf,start_tag('SEQ_RULECOND_DATA',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$seq_rulecondition->id));
$status =fwrite ($bf,start_tag('SEQ_ROLLUPRULES',4,true));
//Iterate over each sco
foreach ($scorm_seq_rolluprules as $seq_rolluprule) {
- //Start sco
+ //Start sco
$status =fwrite ($bf,start_tag('SEQ_ROLLUPRULE',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$seq_rolluprule->id));
$status =fwrite ($bf,start_tag('SEQ_ROLLUPRULECONDS',4,true));
//Iterate over each sco
foreach ($scorm_seq_rollupruleconditions as $seq_rolluprulecondition) {
- //Start sco
+ //Start sco
$status =fwrite ($bf,start_tag('SEQ_ROLLUPRULECOND',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$seq_rolluprulecondition->id));
$status =fwrite ($bf,start_tag('SEQ_OBJECTIVES',4,true));
//Iterate over each sco
foreach ($scorm_seq_objectives as $seq_objective) {
- //Start sco
+ //Start sco
$status =fwrite ($bf,start_tag('SEQ_OBJECTIVE',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$seq_objective->id));
$status =fwrite ($bf,start_tag('SEQ_MAPINFO',4,true));
//Iterate over each sco
foreach ($scorm_seq_objectives as $seq_objective) {
- //Start sco
+ //Start sco
$status =fwrite ($bf,start_tag('SEQ_MAPINF',5,true));
//Print track contents
fwrite ($bf,full_tag('ID',6,false,$seq_objective->id));
}
return $status;
}
-
+
////Return an array of info (name,value)
function scorm_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
FROM {scorm} a
WHERE a.course = ?", array($course));
}
-
+
//Returns an array of scorm_scoes id
function scorm_scoes_track_ids_by_course ($course) {
global $CFG, $DB;
FROM {scorm_scoes_track} s
WHERE s.scormid = ?", array($instanceid));
}
-?>
+
<?php
require_once('../../config.php');
require_once('locallib.php');
-
+
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', PARAM_INT); // sco ID
echo "\n".$request;
}
}
-?>
+
-<?php // $Id$
+<?php
function scorm_add_time($a, $b) {
$aes = explode(':',$a);
return $result;
}
-?>
+
<?php
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
-
+
if (isset($userdata->status)) {
if ($userdata->status == '') {
$userdata->entry = 'ab-initio';
scorm_reconstitute_array_element($scorm->version, $userdata, 'cmi.objectives', array('score'));
scorm_reconstitute_array_element($scorm->version, $userdata, 'cmi.interactions', array('objectives', 'correct_responses'));
?>
-
+
if (cmi.core.lesson_status == '') {
cmi.core.lesson_status = 'not attempted';
- }
-
+ }
+
//
// API Methods definition
//
if (!Initialized) {
Initialized = true;
errorCode = "0";
- <?php
+ <?php
if (scorm_debugging($scorm)) {
//echo 'alert("Initialized SCORM 1.2");';
echo 'LogAPICall("LMSInitialize", param, "", errorCode);';
} else {
errorCode = "201";
}
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSInitialize", param, "", errorCode);';
}
?>
return "false";
}
-
+
function LMSFinish (param) {
errorCode = "0";
if (param == "") {
if (<?php echo $scorm->auto ?> == 1) {
setTimeout('top.document.location=top.next;',500);
}
- }
- <?php
+ }
+ <?php
if (scorm_debugging($scorm)) {
//echo 'alert("Finished SCORM 1.2");';
echo 'LogAPICall("LMSFinish", param, "", 0);';
} else {
errorCode = "201";
}
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSFinish", param, "", errorCode);';
}
?>
return "false";
}
-
+
function LMSGetValue (element) {
errorCode = "0";
if (Initialized) {
}
if (subelement == element) {
errorCode = "0";
- <?php
+ <?php
if (scorm_debugging($scorm)) {
//echo 'alert(element+": "+eval(element));';
echo 'LogAPICall("LMSGetValue", element, eval(element), 0);';
} else {
errorCode = "301";
}
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSGetValue", element, "", errorCode);';
}
?>
return "";
}
-
+
function LMSSetValue (element,value) {
errorCode = "0";
if (Initialized) {
}
if (elementIndexes[i+1] == eval(subelement+'.'+elementIndex+'._count')) {
eval(subelement+'.'+elementIndex+'._count++;');
- }
+ }
if (elementIndexes[i+1] > eval(subelement+'.'+elementIndex+'._count')) {
errorCode = "201";
}
if ((value >= ranges[0]) && (value <= ranges[1])) {
eval(element+'=value;');
errorCode = "0";
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
//echo 'alert(element+":= "+value);';
eval(element+'=value;');
}
errorCode = "0";
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
//echo 'alert(element+":= "+value);';
} else {
errorCode = "301";
}
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSSetValue", element, value, errorCode);';
}
?>
return "false";
}
-
+
function LMSCommit (param) {
errorCode = "0";
if (param == "") {
if (Initialized) {
result = StoreData(cmi,false);
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("Commit", param, "", 0);';
//echo 'alert("Data Commited");';
} else {
errorCode = "201";
}
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSCommit", param, "", 0);';
}
?>
return "false";
}
-
+
function LMSGetLastError () {
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSGetLastError", "", "", errorCode);';
}
?>
return errorCode;
}
-
+
function LMSGetErrorString (param) {
if (param != "") {
var errorString = new Array();
errorString["403"] = "Element is read only";
errorString["404"] = "Element is write only";
errorString["405"] = "Incorrect data type";
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSGetErrorString", param, errorString[param], 0);';
}
?>
return errorString[param];
} else {
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSGetErrorString", param, "No error string found!", 0);';
}
return "";
}
}
-
+
function LMSGetDiagnostic (param) {
if (param == "") {
param = errorCode;
}
- <?php
+ <?php
if (scorm_debugging($scorm)) {
echo 'LogAPICall("LMSGetDiagnostic", param, param, 0);';
}
}
datastring += '&attempt=<?php echo $attempt ?>';
datastring += '&scoid=<?php echo $scoid ?>';
-
+
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php echo sesskey() ?>"+datastring);
results = String(result).split('\n');
-<?php // $Id$
+<?php
/**
* This is really a little language parser for AICC_SCRIPT
* evaluates the expression and returns a boolean answer
return $result;
}
-?>
+
-<?php // $Id$
+<?php
function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false) {
global $CFG, $DB, $PAGE, $OUTPUT;
return $result;
}
-?>
+
}
}
-?>
\ No newline at end of file
-<?php // $Id$
+<?php
require ('scormlib.php');
function scorm_seq_evaluate($scoid,$usertracks) {
$seq->nextactivity = null;
$seq->deliveryvalid = null;
$seq->attempt = $attempt;
-
+
$seq->identifiedactivity = null;
$seq->delivery = null;
$seq->deliverable = false;
$seq->sequencing = 'start';
} else {
$seq->exception = 'NB.2.1-1'; /// Sequencing session already begun
- }
+ }
break;
case 'resumeall_':
if (empty($seq->currentactivity)) {
}
} else {
$seq->exception = 'NB.2.1-1'; /// Sequencing session already begun
- }
+ }
break;
case 'continue_':
case 'previous_':
$sco = $seq->currentactivity;
if ($sco->parent != '/') {
if ($parentsco = scorm_get_parent($sco)) {
-
+
if (isset($parentsco->flow) && ($parentsco->flow == true)) {//I think it's parentsco
// Current activity is active !
if (scorm_seq_is('active',$sco->id,$userid)) {
$seq->exception = 'NB.2.1-2'; /// Current activity not defined
}
break;
- default: /// {target=<STRING>}choice
+ default: /// {target=<STRING>}choice
if ($targetsco = $DB->get_record('scorm_scoes', array('scorm'=>$sco->scorm,'identifier'=>$request))) {
if ($targetsco->parent != '/') {
$seq->target = $request;
if (!isset($parentsco->choice) || ($parent->choice == true)) {
$seq->target = $request;
}
- }
+ }
}
if ($seq->target != null) {
if (empty($seq->currentactivity)) {
$seq->exception = 'NB.2.1-8'; /// Violates control mode
return $seq;
}
- }
+ }
} else {
$seq->navigation = false;
$seq->termination = null;
}
/// Terminate Descendent Attempts Process
-
- if ($ancestors = scorm_get_ancestors($sco)) {
+
+ if ($ancestors = scorm_get_ancestors($sco)) {
foreach ($ancestors as $ancestor) {
scorm_seq_end_attempt($ancestor,$userid,$seq);
$seq->currentactivity = $ancestor;
// return $seq;
}
}
- if ($ancestors = scorm_get_ancestors($sco)) {
+ if ($ancestors = scorm_get_ancestors($sco)) {
foreach ($ancestors as $ancestor) {
scorm_seq_set('active',$ancestor->id,$userid,false);
scorm_seq_set('suspended',$ancestor->id,$userid);
$seq->termination = true;
break;
case 'abandonall':
- if ($ancestors = scorm_get_ancestors($sco)) {
+ if ($ancestors = scorm_get_ancestors($sco)) {
foreach ($ancestors as $ancestor) {
scorm_seq_set('active',$ancestor->id,$userid,false);
$seq->currentactivity = $ancestor;
if (!scorm_seq_is('suspended',$sco->id,$userid)) {
if (!isset($sco->completionsetbycontent) || ($sco->completionsetbycontent == 0)) {
if (!scorm_seq_is('attemptprogressstatus',$sco->id,$userid,$seq->attempt)) {
- // if (!scorm_seq_is('attemptprogressstatus',$sco->id,$userid)) {
+ // if (!scorm_seq_is('attemptprogressstatus',$sco->id,$userid)) {
scorm_seq_set('attemptprogressstatus',$sco->id,$userid);
scorm_seq_set('attemptcompletionstatus',$sco->id,$userid);
}
}
if ($suspended) {
scorm_seq_set('suspended',$sco,$userid);
- } else {
+ } else {
scorm_seq_set('suspended',$sco,$userid,false);
}
}
}
}
if ($exittarget != null) {
- $commons = array_slice($ancestors,0,scorm_find_common_ancestor($ancestors,$exittarget));
-
+ $commons = array_slice($ancestors,0,scorm_find_common_ancestor($ancestors,$exittarget));
+
/// Terminate Descendent Attempts Process
- if ($commons) {
+ if ($commons) {
foreach ($commons as $ancestor) {
-
+
scorm_seq_end_attempt($ancestor,$userid,$seq->attempt);
$seq->currentactivity = $ancestor;
}
}
}
$bag [$rule->id] = $rulecond->cond;
-
+
}
if (empty($bag)){
$cond = 'unknown';
if ($rule->conditioncombination = 'all'){
foreach ($bag as $con){
$cond = $cond.' and '.$con;
-
+
}
}
else{
function scorm_seq_overall_rollup($sco,$userid){//Carlos
- if ($ancestors = scorm_get_ancestors($sco)) {
+ if ($ancestors = scorm_get_ancestors($sco)) {
foreach ($ancestors as $ancestor) {
if(!scorm_is_leaf($ancestor)){
scorm_seq_measure_rollup($sco,$userid);
}
- }
+ }
}
/* For this next function I have defined measure weight and measure status as records with the attempt = 0 on the scorm_scoes_track table. According to the page 89 of the SeqNav.pdf those datas give us some information about the progress of the objective*/
foreach ($objectives as $objective){
- if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
+ if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
$targetobjective = $objective;
break;
}
foreach ($children as $child){
$child = scorm_get_sco ($child);
if (!isset($child->tracked) || ($child->tracked == 1)){
-
+
$rolledupobjective = null;// we set the rolled up activity to undefined
$objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$child->id));
foreach ($objectives as $objective){
- if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
+ if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
$rolledupobjective = $objective;
break;
}
}
if ($rolledupobjective != null){
$child = scorm_get_sco($child->id);
-
+
$countedmeasures = $countedmeasures + ($child->measureweight);
if (!scorm_seq_is('objectivemeasurestatus',$sco->id,$userid)) {
$normalizedmeasure = $DB->get_record('scorm_scoes_track', array('scoid'=>$child->id,'userid'=>$userid,'element'=>'objectivenormalizedmeasure'));
$valid = true;
}
-
-
+
+
}
}
}
-
+
if(!$valid){
scorm_seq_set('objectivemeasurestatus',$sco->id,$userid,false);
scorm_seq_set('objectivemeasurestatus',$sco->id,$userid);
$val=$totalmeasure/$countedmeasures;
scorm_seq_set('objectivenormalizedmeasure',$sco->id,$userid,$val);
-
+
}
else{
scorm_seq_set('objectivemeasurestatus',$sco->id,$userid,false);
-
+
}
}
}
-
+
}
function scorm_seq_objective_rollup($sco,$userid){
global $DB;
-
+
scorm_seq_objective_rollup_measure($sco,$userid);
scorm_seq_objective_rollup_rules($sco,$userid);
scorm_seq_objective_rollup_default($sco,$userid);
foreach($rolluprules as $rolluprule){
$rollupruleconds = $DB->get_records('scorm_seq_rolluprulecond', array('rollupruleid'=>$rolluprule->id));
foreach($rollupruleconds as $rolluprulecond){
-
+
switch ($rolluprulecond->cond!='satisfied' && $rolluprulecond->cond!='completed' && $rolluprulecond->cond!='attempted'){
-
+
scorm_seq_set('objectivesatisfiedstatus',$sco->id,$userid, false);
break;
}
}
-
+
}
}
-*/
+*/
}
function scorm_seq_objective_rollup_measure($sco,$userid){
global $DB;
$targetobjective = null;
-
+
$objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$sco->id));
foreach ($objectives as $objective){
if($targetobjective->satisfiedbymeasure){
-
+
if (!scorm_seq_is('objectiveprogressstatus',$sco->id,$userid)) {
scorm_seq_set('objectiveprogressstatus',$sco->id,$userid,false);
-
+
}
else{
else{
scorm_seq_set('objectiveprogressstatus',$sco->id,$userid,false);
-
+
}
}
}
global $DB;
if (!(scorm_seq_rollup_rule_check($sco,$userid,'incomplete')) && !(scorm_seq_rollup_rule_check($sco,$userid,'completed'))){
-
+
$rolluprules = $DB->get_record('scorm_seq_rolluprule', array('scoid'=>$sco->id,'userid'=>$userid));
foreach($rolluprules as $rolluprule){
$rollupruleconds = $DB->get_records('scorm_seq_rolluprulecond', array('rollupruleid'=>$rolluprule->id));
foreach($rollupruleconds as $rolluprulecond){
-
+
if ($rolluprulecond->cond!='satisfied' && $rolluprulecond->cond!='completed' && $rolluprulecond->cond!='attempted'){
-
+
scorm_seq_set('objectivesatisfiedstatus',$sco->id,$userid, false);
break;
}
}
-
+
}
}
-
+
}
$objectives = $DB->get_records('scorm_seq_objective', array('scoid'=>$sco->id));
foreach ($objectives as $objective){
- if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
+ if ($objective->primaryobj == true){//Objective contributes to rollup I'm using primaryobj field, but not
$targetobjective = $objective;
break;
}
}
if ($targetobjective != null){
-
+
if(scorm_seq_rollup_rule_check($sco,$userid,'notsatisfied')){//with not satisfied rollup for the activity
-
+
scorm_seq_set('objectiveprogressstatus',$sco->id,$userid);
scorm_seq_set('objectivesatisfiedstatus',$sco->id,$userid,false);
}
}
}
}
-
+
}
$change = false;
$condit = scorm_evaluate_cond($rolluprulecond,$sco,$userid);
if($rule->operator=='not'){// If operator is not, negate the condition
- if ($rule->cond != 'unknown'){
+ if ($rule->cond != 'unknown'){
if ($condit){
$condit = false;
}
else{
$val = false;
-
+
if($b == 'unknown'){
$unk = true;
}
function scorm_evaluate_condition ($rolluprulecond,$sco,$userid){
global $DB;
-
+
$res = false;
switch ($rolluprulecond->cond){
-
+
case 'satisfied':
if($r=$DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'objectivesatisfiedstatus'))) {
if($r->value == true){
if($r->value == true){
$res = true;
}
-
+
}
break;
if($r->value){
$res = true;
}
-
+
}
}
-
+
}
break;
if($r->value > 0){
$res = true;
}
-
+
}
}
-
+
}
break;
-
+
case 'attemptLimitExceeded':
if ($r = $DB->get_record('scorm_scoes_track', array('scoid'=>$sco->id,'userid'=>$userid,'element'=>'activityprogressstatus'))) {
if($r->value >= $r2->value){
$res = true;
}
-
+
}
-
+
}
-
+
}
-
+
}
-
+
}
-
+
break;
case 'activityProgressKnown':
if($r->value){
$res = true;
}
-
+
}
-
+
}
-
+
}
-
+
break;
}
return $res;
if (!$sco->rollupobjectivesatisfied){
$included = true;
if (($action == 'satisfied' && $sco->requiredforsatisfied == 'ifnotsuspended') || ($action == 'notsatisfied' && $sco->requiredfornotsatisfied == 'ifnotsuspended')){
-
+
if (!scorm_seq_is('activityprogressstatus',$sco->id,$userid) || ((($r->value)>0)&& !scorm_seq_is('suspended',$sco->id,$userid))){
$included = false;
}
}
else{
-
+
if (($action == 'completed' && $sco->requiredforcompleted == 'ifattempted') || ($action == 'incomplete' && $sco->requiredforincomplete == 'ifattempted')){
if (!scorm_seq_is('activityprogressstatus',$sco->id,$userid) || (($r->value)==0)){
$included = false;
//TODO: undefined $sco!
$seq = scorm_seq_start_sequencing($sco,$userid,$seq); //We'll see the parameters we have to send, this should update delivery and end
$seq->sequencing = true;
-
-
+
+
break;
-
+
case 'resumeall':
$seq = scorm_seq_resume_sequencing($sco,$userid,$seq); //We'll see the parameters we have to send, this should update delivery and end
$seq->sequencing = true;
-
-
-
+
+
+
break;
case 'exit':
$seq = scorm_seq_exit_sequencing($sco,$userid,$seq); //We'll see the parameters we have to send, this should update delivery and end
$seq->sequencing = true;
-
-
+
+
break;
case 'retry':
$seq = scorm_seq_retry_sequencing($sco,$userid,$seq); //We'll see the parameters we have to send, this should update delivery and end
$seq->sequencing = true;
-
-
+
+
break;
case 'previous':
$seq = scorm_seq_previous_sequencing($sco,$userid,$seq);// We'll see the parameters we have to send, this should update delivery and end
$seq->sequencing = true;
-
+
break;
case 'choice':
$seq = scorm_seq_choice_sequencing($sco,$userid,$seq);// We'll see the parameters we have to send, this should update delivery and end
- $seq->sequencing = true;
-
-
+ $seq->sequencing = true;
+
+
break;
}
$seq->sequencing = false;
return $seq;
}
-
+
$seq->sequencing= true;
return $seq;
}
return $seq;
}
$seq->delivery = $DB->get_record('scorm_scoes', array('scoid'=>$scoid,'userid'=>$userid));//we assign the sco to the delivery
-
+
}
function scorm_seq_continue_sequencing($scoid,$userid,$seq){
$seq->exception = 'SB.2.8-1';
return $seq;
}
-
+
$currentact= $seq->currentactivity;
if ($currentact->parent != '/') {//if the activity is the root and is leaf
$parent = scorm_get_parent ($activity); // TODO: undefined!!
$seq->endsession = true;
return $seq;
}
-
+
$seq->endsession = false;
return $seq;
}
$seq->exception = 'SB.2.10-2';
return $seq;
}
-
+
if (!scorm_is_leaf($seq->currentactivity)){
$res = scorm_seq_flow($seq->currentactivity,'forward',$seq,true,$userid);
if($res != null){
$seq->nextactivity = $activity;
return $seq;
}
-
+
$rulch = scorm_seq_rules_check($sco, 'skipped'); // TODO: undefined
if ($rulch != null){
$seq = scorm_seq_flow_tree_traversal ($activity, $direction, false, $prevdirection, $seq,$userid);//endsession and exception
return $seq;
}
else{
-
+
if ($prevdirection = 'backward' && $seq->traversaldir == 'backward'){
$seq = scorm_seq_flow_tree_traversal ($activity,$direction,false,null,$seq,$userid);
$seq = scorm_seq_flow_activity($seq->identifiedactivity, $userid, $direction, $childrenflag, $prevdirection, $seq,$userid);
}
if (scorm_is_leaf ($activity) || !$childrenflag){
if ($children[$siz-1]->id == $activity->id){
-
+
$seq = scorm_seq_flow_tree_traversal ($parent, $direction, false, null, $seq,$userid);
// I think it's not necessary to do a return in here
}
return $seq;
}
}
-
+
}
if($direction = 'backward'){
-
+
if ($activity->parent == '/'){
$seq->traversaldir = null;
$seq->nextactivity = null;
$seq->traversaldir = 'forward';
$seq->nextactivity = $children[0];
return $seq;
-
+
}
else{
$children = scorm_get_children ($activity);
}
else{
-
+
$seq->traversaldir = null;
$seq->nextactivity = null;
$seq->exception = 'SB.2.1-2';
global $DB;
if (isset($activity->tracked) && ($activity->tracked == 0)){
-
+
return false;
}
return false;
}
- if (!isset($activity->limitcontrol) || ($activity->limitcontrol == 1)){
+ if (!isset($activity->limitcontrol) || ($activity->limitcontrol == 1)){
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'activityattemptcount'));
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitattempt)){
return true;
}
}
- if (!isset($activity->limitabsdurcontrol) || ($activity->limitabsdurcontrol == 1)){
+ if (!isset($activity->limitabsdurcontrol) || ($activity->limitabsdurcontrol == 1)){
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'activityabsoluteduration'));
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitabsduration)){
return true;
}
}
- if (!isset($activity->limitexpdurcontrol) || ($activity->limitexpdurcontrol == 1)){
+ if (!isset($activity->limitexpdurcontrol) || ($activity->limitexpdurcontrol == 1)){
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'activityexperiencedduration'));
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitexpduration)){
return true;
}
}
-
- if (!isset($activity->limitattabsdurcontrol) || ($activity->limitattabsdurcontrol == 1)){
+
+ if (!isset($activity->limitattabsdurcontrol) || ($activity->limitattabsdurcontrol == 1)){
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptabsoluteduration'));
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitattabsduration)){
return true;
}
}
- if (!isset($activity->limitattexpdurcontrol) || ($activity->limitattexpdurcontrol == 1)){
+ if (!isset($activity->limitattexpdurcontrol) || ($activity->limitattexpdurcontrol == 1)){
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptexperiencedduration'));
if (scorm_seq_is('activityprogressstatus',$activity->id,$userid) && ($r->value >=$activity->limitattexpduration)){
return true;
}
}
- if (!isset($activity->limitbegincontrol) || ($activity->limitbegincontrol == 1)){
+ if (!isset($activity->limitbegincontrol) || ($activity->limitbegincontrol == 1)){
$r = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'begintime'));
if (time()>=$activity->limitbegintime){
return true;
}
}
- if (!isset($activity->limitbegincontrol) || ($activity->limitbegincontrol == 1)){
+ if (!isset($activity->limitbegincontrol) || ($activity->limitbegincontrol == 1)){
if (time()<$activity->limitbegintime){
return true;
}
}
- if (!isset($activity->limitendcontrol) || ($activity->limitendcontrol == 1)){
+ if (!isset($activity->limitendcontrol) || ($activity->limitendcontrol == 1)){
if (time()>$activity->limitendtime){
return true;
return $seq;
}
-
+
$children = scorm_get_children (scorm_get_parent ($sco));
$pos1 = array_search($children, $sco);
$pos2 = array_search($seq->currentactivity, $sco);
}
}
}
- break;
+ break;
}
if(scorm_is_leaf ($sco)){
else{
return $seq;
}
-
+
}
function scorm_seq_choice_flow ($constrained, $traverse, $seq){
//ONCE THE DELIVERY BEGINS (How should I check that?)
if(isset($activity->tracked) || ($activity->tracked == 0)){
- //How should I track the info and what should I do to not record the information for the activity during delivery?
+ //How should I track the info and what should I do to not record the information for the activity during delivery?
$atabsdur = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptabsoluteduration'));
$atexpdur = $DB->get_record('scorm_scoes_track', array('scoid'=>$activity->id,'userid'=>$userid,'element'=>'attemptexperiencedduration'));
}
return $seq;
-
+
}
function scorm_clear_suspended_activity($act,$seq){
global $DB;
}
else{
$children = scorm_get_children($activity);
- $bool= false;
+ $bool= false;
foreach ($children as $child){
if(scorm_seq_is('suspended',$child->id,$userid)){
$bool= true;
case 'oneachnewattempt':
case 'never':
break;
-
+
case 'once':
if(!scorm_seq_is('activityprogressstatus',$scoid,$userid)){
if(scorm_seq_is('selectioncountsstatus',$scoid,$userid)){
}
}
break;
-
+
}
}
switch($r->value) {
-
+
case 'never':
break;
-
+
case 'oneachnewattempt':
case 'once':
if(!scorm_seq_is('activityprogressstatus',$scoid,$userid)){
array_splice($children,$pos,1);
$i--;
}
-
+
$clist = serialize ($childlist);
scorm_seq_set('availablechildren', $scoid, $userid, false);
scorm_seq_set('availablechildren', $scoid, $userid, $clist);
}
}
break;
-
-
-
+
+
+
}
}
foreach ($activitypath as $sco) {
scorm_seq_end_attempt($sco,$userid,$seq->attempt);
-
+
}
}
}
- }
+ }
}
function scorm_sequencing_exception($seq){
case 'SB.2.10-3':
echo $OUTPUT->notification("Flow Sequencing Control Model Violation");
break;
-
+
case 'SB.2.11-1':
echo $OUTPUT->notification("Sequencing session has not begun");
break;
case 'DB.2-1':
echo $OUTPUT->notification("Identified activity is already active");
break;
-
+
}
-
+
}
}
-?>
+
)
);
-?>
\ No newline at end of file
-<?php //$Id$
+<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
-<?php //$Id$
+<?php
// This file keeps track of upgrades to
// the scorm module
return $result;
}
-?>
+
echo $OUTPUT->footer();
-?>
+
*/
function scorm_option2text($scorm) {
$scorm_popoup_options = scorm_get_popup_options_array();
-
+
if (isset($scorm->popup)) {
if ($scorm->popup == 1) {
$optionlist = array();
/**
* Implementation of the function for printing the form elements that control
* whether the course reset functionality affects the scorm.
- *
+ *
* @param object $mform form passed by reference
*/
function scorm_reset_course_form_definition(&$mform) {
/**
* File browsing support
- *
+ *
* @todo Document this function
*/
function scorm_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) {
$filepath = is_null($filepath) ? '/' : $filepath;
$filename = is_null($filename) ? '.' : $filename;
-
+
$urlbase = $CFG->wwwroot.'/pluginfile.php';
if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
if ($filepath === '/' and $filename === '.') {
} else if ($filearea === 'scorm_package') {
$filepath = is_null($filepath) ? '/' : $filepath;
$filename = is_null($filename) ? '.' : $filename;
-
+
$urlbase = $CFG->wwwroot.'/pluginfile.php';
if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) {
if ($filepath === '/' and $filename === '.') {
if (!$cm = get_coursemodule_from_instance('scorm', $cminfo->instance, $course->id)) {
return false;
}
-
+
require_login($course, true, $cm);
if ($filearea === 'scorm_content') {
-<?php // $Id$
+<?php
require_once("$CFG->dirroot/mod/scorm/lib.php");
<div class='scorm-center'>
<?php print_string('organizations','scorm') ?>
<form id='changeorg' method='post' action='<?php echo $action ?>'>
- <?php
+ <?php
$select = new html_select();
$select->options = $orgs;
$select->name = 'organization';
$select->selectedvalue = $organization;
$select->add_action('change', 'submit_form_by_id', array('id' => 'changeorg'));
- echo $OUTPUT->select($select);
+ echo $OUTPUT->select($select);
?>
</form>
</div>
parent::set_data($default_values);
}
}
-?>
+
function scorm_get_element_style(obj, prop, cssProp) {
var ret = '';
-
+
if (obj.currentStyle) {
ret = obj.currentStyle[prop];
} else if (document.defaultView && document.defaultView.getComputedStyle) {
var compStyle = document.defaultView.getComputedStyle(obj, null);
ret = compStyle.getPropertyValue(cssProp);
}
-
+
if (ret == 'auto') ret = '0';
return ret;
}
winwidth = document.body.clientWidth;
winheight = document.body.clientHeight;
}
-
- var header = document.getElementById('header');
+
+ var header = document.getElementById('header');
var content = document.getElementById('content');
var headerheight = 0;
if (content) {
headerheight = content.offsetTop;
}
-
+
var footer = document.getElementById('footer');
var imsnavbar = document.getElementById('tochead');
var scormtop = document.getElementById('scormtop');
var topmargin = parseInt(scorm_get_element_style(document.getElementsByTagName('body')[0], 'marginTop', 'margin-top'));
var bottommargin = parseInt(scorm_get_element_style(document.getElementsByTagName('body')[0], 'marginBottom', 'margin-bottom'));
-
- var totalheight = headerheight +
- footerheight +
+
+ var totalheight = headerheight +
+ footerheight +
scormtopheight+
topmargin +
bottommargin+10; // +10 to save a minor vertical scroll always present!
var finalheighttoc = winheight - totalheighttoc;
if (finalheighttoc <= 0) {
finalheighttoc = winheight;
- }
+ }
var finalheight = winheight - totalheight;
if (finalheight <= 0) {
finalheight = winheight;
- }
+ }
var toctree = document.getElementById('toctree');
if (toctree != null){
var toctreeHeight = toctree.offsetHeight;
if ($action !== '') {
$url->param('action', $action);
}
-
+
if (!empty($id)) {
$url->param('id', $id);
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
if (empty($noheader)) {
echo $OUTPUT->footer();
}
-?>
+
-<?php //$Id$
+<?php
//This php script contains all the stuff to backup/restore
//reservation mods
foreach ($oldoptions as $oldoption) {
list($element,$value) = explode('=',$oldoption);
$element = trim($element);
- $value = trim($value);
+ $value = trim($value);
switch ($element) {
case 'width':
$scorm->width = $value;
$scorm->launch = $launchsco->new_id;
$DB->update_record('scorm',$scorm);
}
- }
-
+ }
+
} else {
$status = false;
}
//The structure is equal to the db, so insert the scorm_scoes
$newid = $DB->insert_record ("scorm_scoes",$sco);
-
+
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"scorm_scoes", $oldid, $newid);
$status = scorm_scoes_tracks_restore_mods ($scorm_id,$info,$restore);
}
}
- }
-
+ }
+
return $status;
}
//Get the discussions array
$objectives = array();
-
+
if (!empty($info['MOD']['#']['SEQ_OBJECTIVES']['0']['#']['SEQ_OBJECTIVE'])) {
$objectives = $info['MOD']['#']['SEQ_OBJECTIVES']['0']['#']['SEQ_OBJECTIVE'];
}
$objective->objectiveid = backup_todb($obj_info['#']['OBJECTIVEID']['0']['#']);
$objective->satisfiedbymeasure = backup_todb($obj_info['#']['SATISFIEDBYMEASURE']['0']['#']);
$objective->minnormalizedmeasure = backup_todb($obj_info['#']['MINNORMALIZEDMEASURE']['0']['#']);
-
+
//The structure is equal to the db, so insert the forum_discussions
$newid = $DB->insert_record ("scorm_seq_objective",$objective);
//Now restore the scorm_seq_mapinfo for each objective
$status = scorm_seq_mapinfo_restore_mods ($sco_id,$newid,$obj_info,$restore);
-
+
}
return $status;
//Get the discussions array
$rolluprules = array();
-
+
if (!empty($info['MOD']['#']['SEQ_ROLLUPRULES']['0']['#']['SEQ_ROLLUPRULE'])) {
$rolluprules = $info['MOD']['#']['SEQ_ROLLUPRULES']['0']['#']['SEQ_ROLLUPRULE'];
}
$rolluprule->minimumpercent = backup_todb($rol_info['#']['MINIMUMPERCENT']['0']['#']);
$rolluprule->conditioncombination = backup_todb($rol_info['#']['CONDITIONCOMBINATION']['0']['#']);
$rolluprule->action = backup_todb($rol_info['#']['ACTION']['0']['#']);
-
+
//The structure is equal to the db, so insert the forum_discussions
$newid = $DB->insert_record ("scorm_seq_rolluprule",$rolluprule);
//Now restore the scorm_seq_mapinfo for each objective
$status = scorm_seq_rolluprulecond_restore_mods ($sco_id, $newid,$obj_info,$restore);
-
+
}
return $status;
//Get the discussions array
$ruleconds = array();
-
+
if (!empty($info['MOD']['#']['SEQ_RULECONDS']['0']['#']['SEQ_RULECOND'])) {
$ruleconds = $info['MOD']['#']['SEQ_RULECONDS']['0']['#']['SEQ_RULECOND'];
}
//We'll need this later!!
$oldid = backup_todb($rul_info['#']['ID']['0']['#']);
-
- $rulecond->scoid = $sco_id;
+
+ $rulecond->scoid = $sco_id;
$rulecond->conditioncombination = backup_todb($rul_info['#']['CONDITIONCOMBINATION']['0']['#']);
$rulecond->minimumpercent = backup_todb($rul_info['#']['RULETYPE']['0']['#']);
$rulecond->action = backup_todb($rul_info['#']['ACTION']['0']['#']);
-
+
//The structure is equal to the db, so insert the forum_discussions
$newid = $DB->insert_record ("scorm_seq_ruleconds",$rulecond);
//Now restore the scorm_seq_mapinfo for each objective
$status = scorm_seq_rulecond_restore_mods ($sco_id, $newid,$obj_info,$restore);
-
+
}
return $status;
//Get the discussions array
$rulecondsd = array();
-
+
if (!empty($info['MOD']['#']['SEQ_RULECOND_DATAS']['0']['#']['SEQ_RULECOND_DATA'])) {
$rulecondsd = $info['MOD']['#']['SEQ_RULECOND_DATAS']['0']['#']['SEQ_RULECOND_DATA'];
}
-
+
for($i = 0; $i < sizeof($rulecondsd); $i++) {
$ruld_info = $rulecondsd[$i];
//Debug
//We'll need this later!!
$oldid = backup_todb($rul_info['#']['ID']['0']['#']);
-
- $rulecondd->scoid = $sco_id;
+
+ $rulecondd->scoid = $sco_id;
$rulecondd->ruleconditions = $rulecondid;
$rulecondd->refrencedobjective = backup_todb($ruld_info['#']['REFRENCEDOBJECTIVE']['0']['#']);
$rulecondd->measurethreshold = backup_todb($ruld_info['#']['MEASURETHRESHOLD']['0']['#']);
$rulecondd->operator = backup_todb($ruld_info['#']['OPERATOR']['0']['#']);
$rulecondd->cond = backup_todb($ruld_info['#']['COND']['0']['#']);
-
+
//The structure is equal to the db, so insert the forum_discussions
$newid = $DB->insert_record ("scorm_seq_rulecond",$rulecondd);
//Get the discussions array
$rollupruleconds = array();
-
+
if (!empty($info['MOD']['#']['SEQ_ROLLUPRULECONDS']['0']['#']['SEQ_ROLLUPRULECOND'])) {
$rollupruleconds = $info['MOD']['#']['SEQ_ROLLUPRULECONDS']['0']['#']['SEQ_ROLLUPRULECOND'];
}
-
+
for($i = 0; $i < sizeof($rollupruleconds); $i++) {
$rulc_info = $rollupruleconds[$i];
//Debug
//We'll need this later!!
$oldid = backup_todb($rulc_info['#']['ID']['0']['#']);
-
- $rolluprulecond->scoid = $sco_id;
+
+ $rolluprulecond->scoid = $sco_id;
$rolluprulecond->ruleconditions = $rolluprule;
$rolluprulecond->cond = backup_todb($rulc_info['#']['COND']['0']['#']);
$rolluprulecond->operator = backup_todb($rulc_info['#']['OPERATOR']['0']['#']);
//Get the discussions array
$mapinfos = array();
-
+
if (!empty($info['MOD']['#']['SEQ_MAPINFO']['0']['#']['SEQ_MAPINF'])) {
$mapinfos = $info['MOD']['#']['SEQ_MAPINFO']['0']['#']['SEQ_MAPINF'];
}
-
+
for($i = 0; $i < sizeof($mapinfos); $i++) {
$map_info = $mapinfos[$i];
//Debug
//We'll need this later!!
$oldid = backup_todb($map_info['#']['ID']['0']['#']);
-
- $mapinfo->scoid = $sco_id;
+
+ $mapinfo->scoid = $sco_id;
$mapinfo->objectiveid = $ojectiveid;
$mapinfo->targetobjectiveid = backup_todb($map_info['#']['TARGETOBJECTIVEID']['0']['#']);
$mapinfo->readsatisfiedstatus = backup_todb($map_info['#']['READSATISFIEDSTATUS']['0']['#']);
$mapinfo->writesatisfiedstatus = backup_todb($map_info['#']['WRITESATISFIEDSTATUS']['0']['#']);
$mapinfo->writenormalizedmeasure = backup_todb($map_info['#']['WRITENORMALIZEDMEASURE']['0']['#']);
-
+
//The structure is equal to the db, so insert the forum_discussions
$newid = $DB->insert_record ("scorm_seq_mapinfo",$mapinfo);
}
}
}
- }
-
+ }
+
return $status;
}
return $status;
}
-
+
//This function restores the scorm_scoes_track from Moodle 1.4
function scorm_scoes_tracks_restore_mods_pre15 ($scorm_id,$info,$restore) {
global $CFG, $DB;
if (!empty($info['MOD']['#']['SCO_USERS']['0']['#']['SCO_USER'])) {
$scousers = $info['MOD']['#']['SCO_USERS']['0']['#']['SCO_USER'];
}
-
+
$oldelements = array ('CMI_CORE_LESSON_LOCATION',
'CMI_CORE_LESSON_STATUS',
'CMI_CORE_EXIT',
//scorm_decode_content_links_caller() function in each module
//in the restore process
function scorm_decode_content_links ($content,$restore) {
-
+
global $CFG;
-
+
$result = $content;
-
+
//Link to the list of scorms
-
+
$searchstring='/\$@(SCORMINDEX)\*([0-9]+)@\$/';
//We look for it
preg_match_all($searchstring,$content,$foundset);
if($rec->new_id) {
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/scorm/index.php?id='.$rec->new_id,$result);
- } else {
+ } else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/scorm/index.php?id='.$old_id,$result);
}
return $status;
}
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->dirroot . '/mod/scorm/locallib.php');
$yesno = array(0 => get_string('no'),
1 => get_string('yes'));
$settings->add(new admin_setting_configtext('scorm/apidebugmask', get_string('apidebugmask', 'scorm'), '', '/.*/'));
-?>
+
width: 100%;
height: 100%;
-
-
+
+
}
position: relative;
width: 100%;
-
-
-
+
+
+
}
top: 3px;
- height: 30px;
-
-
+ height: 30px;
+
+
}
#mod-scorm-player .toc {
- width: 80%;
+ width: 80%;
+
+ margin-left: 20%;
+
+
- margin-left: 20%;
-
-
-
}
#mod-scorm-player .no-toc {
width: 100%;
-
-
+
+
}
#mod-scorm-player #scormobject {
- height: 400px;
-
-
-
+ height: 400px;
+
+
+
}
width: 100%;
height: 30px;
-
-
+
+
}
left: 5px;
top: 0px;
-
-
-
+
+
+
}
top: 3px;
width: 100%;
-
-
-
+
+
+
}
#mod-scorm-view .structurehead {
text-align: center;
-
-
+
+
}
list-style-type: none;
white-space: nowrap;
-
-
+
+
}
right: 0px;
top: 0px;
-
-
+
+
}
width: 24%;
font-size: 0.8em;
-
-
+
+
}
top: 3px;
- height: 30px;
-
-
+ height: 30px;
+
+
}
overflow-x: auto;
overflow-y: auto;
-
-
+
+
}
width: 96%;
margin-left:0;
-
+
padding-left: 0;
-
+
margin-right:0;
-
+
padding-right: 0;
-
+
padding-top: 0;
-
+
padding-bottom: 0;
-
+
margin-top:0;
-
+
margin-bottom:0;
-
-
-
-
+
+
+
+
}
-<?php // $Id$
+<?php
/////////////////////////////////////////////////////////////////////////////////
/// Code fragment to define the version of scorm
$module->requires = 2009041700; // The version of Moodle that is required
$module->cron = 300; // How often should cron check this module (seconds)?
-?>
\ No newline at end of file
require_once("../../config.php");
require_once('locallib.php');
-
+
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$organization = optional_param('organization', '', PARAM_INT); // organization ID
$url->param('organization', $organization);
}
$PAGE->set_url($url);
-
+
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
echo $OUTPUT->header();
if (has_capability('mod/scorm:viewreport', $context)) {
-
+
$trackedusers = scorm_get_count_users($scorm->id, $cm->groupingid);
if ($trackedusers > 0) {
echo "<div class=\"reportlink\"><a $CFG->frametarget href=\"report.php?id=$cm->id\"> ".get_string('viewalluserreports','scorm',$trackedusers).'</a></div>';
$attemptstatus = scorm_get_attempt_status($USER,$scorm);
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
-
+
$scormopen = true;
$timenow = time();
if ($scorm->timeclose !=0) {
scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
}
echo $OUTPUT->footer();
-?>
+
-<?php //$Id$
+<?php
//This php script contains all the stuff to backup/restore
//survey mods
// (CL,pk->id) |(CL,pk->id,?????) |
// | --------------------
// |
- // -----------------------------------
+ // -----------------------------------
// | |
// survey_analysis survey_answers
// (UL,pk->id, fk->survey) (UL,pk->id, fk->survey)
function survey_backup_one_mod($bf,$preferences,$survey) {
global $DB;
-
+
$status = true;
-
+
if (is_numeric($survey)) {
$survey = $DB->get_record('survey', array('id'=>$survey));
}
-
+
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print choice data
fwrite ($bf,full_tag("NAME",4,false,$survey->name));
fwrite ($bf,full_tag("INTRO",4,false,$survey->intro));
fwrite ($bf,full_tag("QUESTIONS",4,false,$survey->questions));
-
+
//if we've selected to backup users info, then execute backup_survey_answers and
//backup_survey_analysis
if (backup_userdata_selected($preferences,'survey',$survey->id)) {
WHERE s.survey = ?", array($instanceid));
}
-?>
+
-<?php //$Id$
+<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
-<?php //$Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the survey module
//
// Sometimes, changes between versions involve
return $result;
}
-?>
+
/// Check to see if groups are being used in this survey
if ($group) {
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $group, null, false);
- } else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
+ } else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
$groups = groups_get_all_groups($courseid, 0, $cm->groupingid);
$groups = array_keys($groups);
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $groups, null, false);
$stractual = get_string("actual", "survey");
$stractualclass = get_string("actualclass", "survey");
-
+
$strpreferred = get_string("preferred", "survey");
$strpreferredclass = get_string("preferredclass", "survey");
exit;
-?>
+
echo $OUTPUT->table($table);
echo $OUTPUT->footer();
-?>
+
return 0;
}
- $survey->questions = $template->questions;
+ $survey->questions = $template->questions;
$survey->timecreated = time();
$survey->timemodified = $survey->timecreated;
return 0;
}
- $survey->id = $survey->instance;
- $survey->questions = $template->questions;
+ $survey->id = $survey->instance;
+ $survey->questions = $template->questions;
$survey->timemodified = time();
return $DB->update_record("survey", $survey);
/**
* Given an ID of an instance of this module,
* this function will permanently delete the instance
- * and any data that depends on it.
+ * and any data that depends on it.
*
* @global object
* @param int $id
$questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions));
$questionorder = explode(",", $survey->questions);
-
+
foreach ($questionorder as $key=>$val) {
$question = $questions[$val];
$questiontext = get_string($question->shorttext, "survey");
-
+
if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
$answertext = "$answer->answer1";
} else {
$table->data[] = array("<b>$questiontext</b>", $answertext);
}
echo $OUTPUT->table($table);
-
+
} else {
-
+
survey_print_graph("id=$mod->id&sid=$user->id&type=student.png");
}
-
+
} else {
print_string("notdone", "survey");
}
$survey->name = $cm->name;
$survey->cmid = $cm->id;
$surveys[] = $survey;
- }
+ }
$rs->close();
if (!$surveys) {
$url = $CFG->wwwroot.'/mod/survey/view.php?id='.$survey->cmid;
print_recent_activity_note($survey->time, $survey, $survey->name, $url, false, $viewfullnames);
}
-
+
return true;
}
function survey_get_responses($surveyid, $groupid, $groupingid) {
global $DB;
- $params = array('surveyid'=>$surveyid, 'groupid'=>$groupid, 'groupingid'=>$groupingid);
+ $params = array('surveyid'=>$surveyid, 'groupid'=>$groupid, 'groupingid'=>$groupingid);
if ($groupid) {
$groupsjoin = "JOIN {groups_members} gm ON u.id = gm.userid AND gm.groupid = :groupid ";
function survey_get_analysis($survey, $user) {
global $DB;
- return $DB->get_record_sql("SELECT notes
+ return $DB->get_record_sql("SELECT notes
FROM {survey_analysis}
WHERE survey=? AND userid=?", array($survey, $user));
}
global $DB;
return $DB->execute("UPDATE {survey_analysis}
- SET notes=?
- WHERE survey=?
+ SET notes=?
+ WHERE survey=?
AND userid=?", array($notes, $survey, $user));
}
$groupsql = "";
}
- return $DB->get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture
- FROM {survey_answers} sa, {user} u, {groups_members} gm
- WHERE sa.survey = :surveyid
- AND sa.question = :questionid
+ return $DB->get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture
+ FROM {survey_answers} sa, {user} u, {groups_members} gm
+ WHERE sa.survey = :surveyid
+ AND sa.question = :questionid
AND u.id = sa.userid $groupsql
ORDER BY $sort", $params);
}
function survey_get_user_answer($surveyid, $questionid, $userid) {
global $DB;
- return $DB->get_record_sql("SELECT sa.*
+ return $DB->get_record_sql("SELECT sa.*
FROM {survey_answers} sa
- WHERE sa.survey = ?
- AND sa.question = ?
+ WHERE sa.survey = ?
+ AND sa.question = ?
AND sa.userid = ?", array($surveyid, $questionid, $userid));
}
foreach ($results as $a) {
$table->data[] = array($OUTPUT->user_picture(moodle_user_picture::make($a, $courseid)),
- $OUTPUT->link("report.php?action=student&student=$a->id&id=$cmid", fullname($a)),
+ $OUTPUT->link("report.php?action=student&student=$a->id&id=$cmid", fullname($a)),
userdate($a->time));
}
if ($oneanswer) {
echo "<tr><th scope=\"col\" colspan=\"6\">$question->intro</th></tr>\n";
} else {
- echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n";
+ echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n";
}
$subquestions = $DB->get_records_list("survey_questions", "id", explode(',', $question->multi));
$default = get_accesshide($strdefault, 'label', '', "for=\"q$P$q->id\"");
echo "<td class=\"whitecell\"><input type=\"radio\" name=\"q$P$q->id\" id=\"q$P" . $q->id . "_D\" value=\"0\" checked=\"checked\" />$default</td>";
$checklist["q$P$q->id"] = $numoptions;
-
- } else {
+
+ } else {
// yu : fix for MDL-7501, possibly need to use user flag as this is quite ugly.
echo "<th scope=\"row\" class=\"optioncell\">";
echo "<b class=\"qnumtopcell\">$qnum</b> ";
$default = get_accesshide($strdefault, 'label', '', "for=\"q$q->id\"");
echo "<td class=\"buttoncell\"><input type=\"radio\" name=\"q$q->id\" id=\"q$q->id\" value=\"0\" checked=\"checked\" />$default</td>";
$checklist["qP$q->id"] = $numoptions;
- $checklist["q$q->id"] = $numoptions;
+ $checklist["q$q->id"] = $numoptions;
}
echo "</tr>\n";
}
/**
* Implementation of the function for printing the form elements that control
* whether the course reset functionality affects the survey.
- *
+ *
* @param object $mform form passed by reference
*/
function survey_reset_course_form_definition(&$mform) {
$PAGE->set_url($url);
require_login($course->id, false, $cm);
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/survey:readresponses', $context);
if ($currentgroup) {
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $currentgroup, null, false);
- } else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
+ } else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
$groups = groups_get_all_groups($courseid, 0, $cm->groupingid);
$groups = array_keys($groups);
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $groups, null, false);
}
$groupingid = $cm->groupingid;
-
+
echo $OUTPUT->box_start("generalbox boxaligncenter");
if ($showscales) {
echo "<a href=\"report.php?action=summary&id=$id\">$strsummary</a>";
$table->data[] = array($contents);
echo $OUTPUT->table($table);
-
+
$spacer = new html_image();
$spacer->height = 30;
$spacer->width = 1;
}
echo $OUTPUT->footer();
-?>
+
-<?php //$Id$
+<?php
//This php script contains all the stuff to backup/restore
//survey mods
// (CL,pk->id) |(CL,pk->id,?????) |
// | --------------------
// |
- // -----------------------------------
+ // -----------------------------------
// | |
// survey_analysis survey_answers
// (UL,pk->id, fk->survey) (UL,pk->id, fk->survey)
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
if ($data) {
- //Now get completed xmlized object
+ //Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//Do some output
if (($i+1) % 50 == 0) {
if (!defined('RESTORE_SILENTLY')) {
- echo ".";
+ echo ".";
if (($i+1) % 1000 == 0) {
echo "<br />";
}
//servey_decode_content_links_caller() function in each module
//in the restore process
function servey_decode_content_links ($content,$restore) {
-
+
global $CFG;
-
+
$result = $content;
-
+
//Link to the list of serveys
-
+
$searchstring='/\$@(SURVEYINDEX)\*([0-9]+)@\$/';
//We look for it
preg_match_all($searchstring,$content,$foundset);
if($rec->new_id) {
//Now replace it
$result= preg_replace($searchstring,$CFG->wwwroot.'/mod/servey/index.php?id='.$rec->new_id,$result);
- } else {
+ } else {
//It's a foreign link so leave it as original
$result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/servey/index.php?id='.$old_id,$result);
}
function survey_decode_content_links_caller($restore) {
global $CFG, $DB;
$status = true;
-
+
if ($surveys = $DB->get_records('survey', array('course'=>$restore->course_id), '', "id,intro")) {
//Iterate over each survey->intro
$i = 0; //Counter to send some output to the browser to avoid timeouts
}
return $status;
}
-?>
+
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/survey/save.php', array('id'=>$id)));
require_login($course->id, false, $cm);
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/survey:participate', $context);
-
+
if (! $survey = $DB->get_record("survey", array("id"=>$cm->instance))) {
print_error('invalidsurveyid', 'survey');
}
exit;
-?>
+
-<?php // $Id$
+<?php
////////////////////////////////////////////////////////////////////////////////
// Code fragment to define the module version etc.
$module->requires = 2009041700; // Requires this Moodle version
$module->cron = 0;
-?>
+
echo $OUTPUT->footer();
-?>
+
//-------------------------------------------------------
$mform->addElement('header', 'content', get_string('contentheader', 'url'));
- $mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size'=>'60'), array('usefilepicker'=>true));
+ $mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size'=>'60'), array('usefilepicker'=>true));
//-------------------------------------------------------
$mform->addElement('header', 'optionssection', get_string('optionsheader', 'url'));