예제 #1
0
function udutu_view_display($user, $udutu, $action, $cm, $boxwidth = '')
{
    global $CFG;
    if ($udutu->updatefreq == UDUTU_UPDATE_EVERYTIME) {
        $udutu->instance = $udutu->id;
        udutu_update_instance($udutu);
    }
    $organization = optional_param('organization', '', PARAM_INT);
    print_simple_box_start('center', $boxwidth);
    ?>
        <div class="structurehead"><?php 
    print_string('contents', 'udutu');
    ?>
</div>
<?php 
    if (empty($organization)) {
        $organization = $udutu->launch;
    }
    if ($orgs = get_records_select_menu('udutu_scoes', "udutu='{$udutu->id}' AND organization='' AND launch=''", 'id', 'id,title')) {
        if (count($orgs) > 1) {
            ?>
            <div class='center'>
                <?php 
            print_string('organizations', 'udutu');
            ?>
                <form id='changeorg' method='post' action='<?php 
            echo $action;
            ?>
'>
                    <?php 
            choose_from_menu($orgs, 'organization', "{$organization}", '', 'submit()');
            ?>
                </form>
            </div>
<?php 
        }
    }
    $orgidentifier = '';
    if ($sco = udutu_get_sco($organization, UDUTU_SCO_ONLY)) {
        if ($sco->organization == '' && $sco->launch == '') {
            $orgidentifier = $sco->identifier;
        } else {
            $orgidentifier = $sco->organization;
        }
    }
    /*
     $orgidentifier = '';
        if ($org = get_record('udutu_scoes','id',$organization)) {
            if (($org->organization == '') && ($org->launch == '')) {
                $orgidentifier = $org->identifier;
            } else {
                $orgidentifier = $org->organization;
            }
        }*/
    $udutu->version = strtolower(clean_param($udutu->version, PARAM_SAFEDIR));
    // Just to be safe
    if (!file_exists($CFG->dirroot . '/mod/udutu/datamodels/' . $udutu->version . 'lib.php')) {
        $udutu->version = 'udutu_12';
    }
    require_once $CFG->dirroot . '/mod/udutu/datamodels/' . $udutu->version . 'lib.php';
    $result = udutu_get_toc($user, $udutu, 'structlist', $orgidentifier);
    $incomplete = $result->incomplete;
    echo $result->toc;
    print_simple_box_end();
    ?>
            <div class="center">
               <form id="theform" method="post" action="<?php 
    echo $CFG->wwwroot;
    ?>
/mod/udutu/player.php?scoid=<?php 
    echo $sco->id;
    ?>
&id=<?php 
    echo $cm->id;
    ?>
"<?php 
    echo $udutu->popup == 1 ? ' target="newwin"' : '';
    ?>
>
              <?php 
    if ($udutu->hidebrowse == 0) {
        print_string('mode', 'udutu');
        echo '<input type="hidden" name="scoid" value="$sco->id" />' . "\n";
        echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">' . get_string('browse', 'udutu') . '</label>' . "\n";
        echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">' . get_string('normal', 'udutu') . "</label>\n";
    } else {
        echo '<input type="hidden" name="mode" value="normal" />' . "\n";
    }
    if ($incomplete === false && ($result->attemptleft > 0 || $udutu->maxattempt == 0)) {
        ?>
                  <br />
                  <input type="checkbox" id="a" name="newattempt" />
                  <label for="a"><?php 
        print_string('newattempt', 'udutu');
        ?>
</label>
<?php 
    }
    ?>
              <br />
              <input type="hidden" name="scoid"/>
              <input type="hidden" name="currentorg" value="<?php 
    echo $orgidentifier;
    ?>
" />
              <input type="submit" value="<?php 
    print_string('entercourse', 'udutu');
    ?>
" />
              </form>
          </div>
<?php 
}
예제 #2
0
//
// TOC processing
//
$udutu->version = strtolower(clean_param($udutu->version, PARAM_SAFEDIR));
// Just to be safe
if (!file_exists($CFG->dirroot . '/mod/udutu/datamodels/' . $udutu->version . 'lib.php')) {
    $udutu->version = 'udutu_12';
}
require_once $CFG->dirroot . '/mod/udutu/datamodels/' . $udutu->version . 'lib.php';
$attempt = udutu_get_last_attempt($udutu->id, $USER->id);
if ($newattempt == 'on' && ($attempt < $udutu->maxattempt || $udutu->maxattempt == 0)) {
    $attempt++;
    $mode = 'normal';
}
$attemptstr = '&amp;attempt=' . $attempt;
$result = udutu_get_toc($USER, $udutu, 'structurelist', $currentorg, $scoid, $mode, $attempt, true);
$sco = $result->sco;
if ($mode == 'browse' && $udutu->hidebrowse == 1) {
    $mode = 'normal';
}
if ($mode != 'browse') {
    if ($trackdata = udutu_get_tracks($sco->id, $USER->id, $attempt)) {
        if ($trackdata->status == 'completed' || $trackdata->status == 'passed' || $trackdata->status == 'failed') {
            $mode = 'review';
        } else {
            $mode = 'normal';
        }
    } else {
        $mode = 'normal';
    }
}