コード例 #1
0
     $selected_week = $currentweek;
 } elseif ($show_option == 'option2' && $completion->is_enabled()) {
     // show the selected week based on the section that have not attempted activity first
     foreach ($allSections as $k => $sect) {
         if ($k == 0) {
             continue;
         }
         if (!$sect->visible) {
             continue;
         }
         if ($k > $currentweek) {
             continue;
         }
         if ($k <= $COURSE->numsections) {
             if (!empty($sect)) {
                 $activityinfoarr = get_activities_status($course, $sect, $resubmission);
                 if ($activityinfoarr['saved'] > 0 || $activityinfoarr['notattempted'] > 0 || $activityinfoarr['waitngforgrade'] > 0) {
                     $selected_week = $k;
                     break;
                 }
             }
         }
     }
 } elseif ($show_option == 'option3' && $selected_week_indb <= $currentweek) {
     $selected_week = $selected_week_indb;
 } else {
     $selected_week = $selected_week;
 }
 if ($PAGE->user_is_editing()) {
     $selected_week = $currentweek;
 }
コード例 #2
0
 function print_weekly_activities_bar($week = 0, $tabrange = 0, $resubmission = false)
 {
     global $FULLME, $CFG, $course, $DB, $USER, $PAGE;
     // added by oncampus
     $last_visible_lection = 31;
     $active_chapter = optional_param('chapter', 0, PARAM_INT);
     $c = $this->get_chapter($active_chapter);
     // added by oncampus
     $lections = $c['lections'];
     // added by oncampus
     // oncampus end
     $selectedcolour = $DB->get_field('course_config_fn', 'value', array('courseid' => $this->course->id, 'variable' => 'selectedcolour'));
     $activelinkcolour = $DB->get_field('course_config_fn', 'value', array('courseid' => $this->course->id, 'variable' => 'activelinkcolour'));
     $activecolour = $DB->get_field('course_config_fn', 'value', array('courseid' => $this->course->id, 'variable' => 'activecolour'));
     $inactivelinkcolour = $DB->get_field('course_config_fn', 'value', array('courseid' => $this->course->id, 'variable' => 'inactivelinkcolour'));
     $inactivecolour = $DB->get_field('course_config_fn', 'value', array('courseid' => $this->course->id, 'variable' => 'inactivecolour'));
     $selectedcolour = $selectedcolour ? $selectedcolour : 'FFFF33';
     $activelinkcolour = $activelinkcolour ? $activelinkcolour : '000000';
     $inactivelinkcolour = $inactivelinkcolour ? $inactivelinkcolour : '000000';
     $activecolour = $activecolour ? $activecolour : 'DBE6C4';
     $inactivecolour = $inactivecolour ? $inactivecolour : 'BDBBBB';
     /* $fnmaxtab       = $DB->get_field('course_config_fn', 'value', array('courseid' => $this->course->id, 'variable' => 'maxtabs'));
     
             if ($fnmaxtab) {
                 $maximumtabs = $fnmaxtab;
             } else {
                 $maximumtabs = 12;
             } */
     $maximumtabs = 6;
     if ($lections < 6) {
         $maximumtabs = $lections;
     }
     echo "\r\n        <style>\r\n        .fnweeklynavselected {\r\n            background-color: #{$selectedcolour};\r\n\t\t\tcolor: #666666;\r\n        }\r\n        .fnweeklynavnorm,\r\n        .fnweeklynavnorm a:active {\r\n            background-color: #{$activecolour};\r\n        }\r\n        .fnweeklynavdisabled {\r\n            color: #{$inactivelinkcolour};\r\n            background-color: #{$inactivecolour};\r\n        }\r\n        .fnweeklynav .tooltip {\r\n            color: #{$activelinkcolour};\r\n        }\r\n        </style>";
     $completioninfo = new completion_info($course);
     // oncampus list($tablow, $tabhigh, $week) = $this->get_week_info($tabrange, $week);
     list($tablow, $tabhigh, $week) = $this->get_week_info($tabrange, $week, $active_chapter);
     // added by oncampus
     // oncampus tablow und high korrigieren bei klick auf nächste Lektion im Footer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     if ($USER->username == 'rieger') {
         //echo '0 high: '.$tabhigh.'<br />low: '.$tablow;
     }
     if ($tabhigh >= $c['first_lection'] + $c['lections']) {
         $tabhigh = $c['first_lection'] + $c['lections'] - 1;
         //$tablow = $tabhigh - 5;
         if ($USER->username == 'rieger') {
             //echo '<br />1 high: '.$tabhigh.'<br />low: '.$tablow;
         }
     }
     $lecs = 6;
     if ($c['lections'] < $lecs) {
         $lecs = $c['lections'];
     }
     if ($tabhigh - $tablow + 1 < $lecs) {
         $tablow = $tabhigh - $lecs + 1;
         if ($USER->username == 'rieger') {
             //echo '<br />2 high: '.$tabhigh.'<br />low: '.$tablow;
         }
     }
     if ($tablow < $c['first_lection']) {
         $tablow = $c['first_lection'];
         $tabhigh = $tablow + $lecs - 1;
         //$tabhigh = $c['first_lection'] + $c['lections'] - 1;
         if ($USER->username == 'rieger') {
             //echo '<br />3 high: '.$tabhigh.'<br />low: '.$tablow.', lecs: '.$lecs;
         }
     }
     //echo $tabrange.' '.$week.' '.$active_chapter.' '.$tablow;
     $timenow = time();
     $weekdate = $this->course->startdate;
     // this should be 0:00 Monday of that week
     $weekdate += 7200;
     // Add two hours to avoid possible DST problems
     $weekofseconds = 604800;
     $last_lection = $this->get_last_lection();
     // oncampus
     if ($last_lection > 20) {
         // oncampus
         $extraclassfortab = "tab-greaterthan5";
     } else {
         $extraclassfortab = "tab-lessthan5";
     }
     $extraclassfortab = 'tab-oc-mooin';
     if (isset($this->course->topicheading) && !empty($this->course->topicheading)) {
         $strtopicheading = $this->course->topicheading;
     } else {
         $strtopicheading = 'Week';
     }
     $context = get_context_instance(CONTEXT_COURSE, $this->course->id);
     $isteacher = has_capability('moodle/course:update', $this->context);
     $iseditingteacher = has_capability('gradereport/grader:view', $this->context);
     $url = preg_replace('/(^.*)(&selected_week\\=\\d+)(.*)/', '$1$3', $FULLME);
     $actbar = '';
     $actbar .= '<table cellpadding="0" cellspacing="0"><tr><td>';
     $actbar .= '<table cellpadding="0" cellspacing="0"  class="fnweeklynav"><tr>';
     $width = (int) (100 / ($tabhigh - $tablow + 3));
     $actbar .= '<td width="4" align="center" height=""></td>';
     //$actbar .= $tablow.' '.$c['first_lection'];
     if ($tablow <= $c['first_lection']) {
         //$actbar .= '<td height="25" class="tab-heading"><strong>' . $strtopicheading . ':&nbsp;</strong></td>';
         //$actbar .= '<td height="" class="tab-heading">&nbsp;&nbsp;&nbsp;</td>'; // oncampus
         $actbar .= '<td id="fn_tab_previous" height=""><div class = "prev-lection-inactive"></div></td>';
         // oncampus
     } else {
         $n = $tablow - 6;
         if ($n < $c['first_lection']) {
             $n = $c['first_lection'];
         }
         $prv = $n * 1000;
         // oncampus $actbar .= '<td id="fn_tab_previous" height="25"><a href="' . $url . '&selected_week=' . $prv . '">Previous</a></td>';
         $actbar .= '<td id="fn_tab_previous" height=""><a href="' . $url . '&selected_week=' . $prv . '" class="prev-lection"><div class = "oc-lection-btn"></div></a></td>';
         // oncampus
     }
     $tdselectedclass = array();
     $currentweek = $timenow > $course->startdate ? (int) (($timenow - $course->startdate) / $weekofseconds + 1) : 0;
     $currentweek = min($currentweek, $last_lection);
     // oncampus
     for ($i = $tablow; $i <= $tabhigh; $i++) {
         //if (empty($this->sections[$i]->visible) || ($timenow < $weekdate)) {
         // oncampus if (empty($this->sections[$i]->visible) || $i > $currentweek) {
         $i_chapter = $this->get_chapter_for_lection($i);
         // if ($i == $week) {
         if ($i < $c['first_lection'] or $i >= $c['first_lection'] + $c['lections']) {
             // added by oncampus Alle Lektionen, die nicht zum aktiven Kapitel gehören
             if ($i_chapter['enabled'] == false) {
                 // Diese Lektionen sind noch nicht verfügbar
                 $css = 'fnweeklynavdisabledselected';
             } else {
                 // verfügbare Lektionen
                 $css = 'fnweeklynavdisabled';
             }
             $tdselectedclass[$i] = $css;
             $newchapter = $this->get_chapter_for_lection($i);
             $newurl = preg_replace('/(^.*)(&chapter\\=\\d+)(.*)/', '$1$3', $url);
             $newurl = $newurl . '&chapter=' . $newchapter['number'];
             if ($isteacher) {
                 // oncampus $f = '<a href="' . $url . '&selected_week=' . $i . '" ><span class="' . $css . '">&nbsp;' .
                 $f = '<a href="' . $newurl . '&selected_week=' . $i . '" ><span class="' . $css . '">&nbsp;' . $i . '&nbsp;</span></a>';
             } else {
                 // Nutzer ist Student
                 if ($i_chapter['enabled'] == false) {
                     // Diese Lektionen sind noch nicht verfügbar
                     $f = ' ' . $i . ' ';
                 } else {
                     // verfügbare Lektionen
                     $f = '<a href="' . $newurl . '&selected_week=' . $i . '" ><span class="' . $css . '">&nbsp;' . $i . '&nbsp;</span></a>';
                 }
             }
             if (!$isteacher && !is_siteadmin() && !empty($completioninfo) && !$iseditingteacher) {
                 if ($completioninfo->is_enabled() && $CFG->enablecompletion) {
                     $oc_f = $this->quizzes_finished($this->sections[$i]) ? 'green-tab' : 'red-tab';
                 } else {
                     $oc_f = '';
                 }
             } else {
                 $oc_f = '';
                 // oncampus $f = ' ' . $i . ' ';
             }
             // oncampus $actbar .= '<td class="' . $css . ' ' . $extraclassfortab . '" height="25" width="" alt="Upcoming sections" title="Upcoming sections">' . $f . '</td>';
             $actbar .= '<td class="' . $css . ' ' . $extraclassfortab . ' ' . $oc_f . '" height="" width="" alt="Upcoming sections" title="Upcoming sections">' . $f . '</td>';
         } else {
             if ($i == $week) {
                 // die aktuell angezeigte Lektion
                 if (!$isteacher && !is_siteadmin() && !empty($completioninfo) && !$iseditingteacher) {
                     if ($completioninfo->is_enabled() && $CFG->enablecompletion) {
                         // oncampus $f = $this->is_section_finished($this->sections[$i], $this->mods) ? 'green-tab' : 'red-tab';
                         //$f = $this->quizzes_finished($this->sections[$i]) ? 'green-tab' : 'red-tab';
                     } else {
                         $f = '';
                     }
                 } else {
                     $f = '';
                 }
                 $tdselectedclass[$i] = 'fnweeklynavselected';
                 $show = '<div class="oc-nav-lektion-text">Lektion</div><div class="oc-nav-lektion-nr">' . ($i - $this->count_previous_chapter_lections($i)) . '</div>';
                 //'('. $i.') </td>';
                 $ocp = $this->get_section_grades($this->sections[$i]);
                 $ocp = round($ocp);
                 if ($ocp != -1) {
                     $show .= '<br />' . $this->get_progress_bar($ocp, 100, $this->sections[$i]->id);
                 } else {
                     $tdselectedclass[$i] = 'fnweeklynavselected noprogress';
                 }
                 $actbar .= '<td class="' . $tdselectedclass[$i] . ' ' . $f . ' ' . $extraclassfortab . '" id=fnweeklynav' . $i . ' width="" height=""><div class="tab-oc-seclected-content">' . $show . '</div></td>';
             } else {
                 // alle Lektionen, die zum Kapitel gehören
                 if (!$isteacher && !is_siteadmin() && !$iseditingteacher) {
                     if ($completioninfo->is_enabled() && $CFG->enablecompletion) {
                         // oncampus $f = $this->is_section_finished($this->sections[$i], $this->mods) ? 'green-tab' : 'red-tab';
                         //$f = $this->quizzes_finished($this->sections[$i]) ? 'green-tab' : 'red-tab';
                         $w = $i;
                         $sectionid = $i;
                         $section = $DB->get_record("course_sections", array("section" => $sectionid, "course" => $course->id));
                         $activitiesstatusarray = get_activities_status($course, $section, $resubmission);
                         $compl = $activitiesstatusarray['complete'];
                         $incompl = $activitiesstatusarray['incomplete'];
                         $svd = $activitiesstatusarray['saved'];
                         $notattemptd = $activitiesstatusarray['notattempted'];
                         $waitforgrade = $activitiesstatusarray['waitngforgrade'];
                     } else {
                         $f = '';
                     }
                 } else {
                     $f = '';
                 }
                 $tdselectedclass[$i] = 'fnweeklynavnorm';
                 // oncampus $tooltipclass = ($i >= ($tabhigh / 2)) ? '-right' : '';
                 $tooltipclass = 'tooltip';
                 // added by oncampus
                 $real_lection = '';
                 if ($USER->username == 'rieger') {
                     //$real_lection = '('.$i.')';
                 }
                 $show = '<div class="oc-nav-lektion-text">Lektion</div><div class="oc-nav-lektion-nr">' . ($i - $this->count_previous_chapter_lections($i)) . $real_lection . '</div>';
                 //('. $i.')&nbsp;</a>';
                 $ocp = $this->get_section_grades($this->sections[$i]);
                 $ocp = round($ocp);
                 if ($ocp != -1) {
                     $show .= '<br />' . $this->get_progress_bar($ocp, 100, $this->sections[$i]->id);
                 } else {
                     $tdselectedclass[$i] = 'fnweeklynavnorm noprogress';
                 }
                 //$show .= '<br />'.$this->get_progress_bar($this->get_section_grades($this->sections[$i]), 90, $this->sections[$i]->id);
                 $actbar .= '<td class="' . $tdselectedclass[$i] . ' ' . $f . ' ' . $extraclassfortab . '" id=fnweeklynav' . $i . ' width="100px" height="">' . '<a class="' . $tooltipclass . '" href="' . $url . '&selected_week=' . $i . '">' . $show . '</a>';
                 // oncampus $actbar .= '</a>' . '</td>';
                 $actbar .= '</td>';
             }
         }
         // $weekdate += ( $weekofseconds);
         // oncampus $actbar .= '<td align="center" height="25" style="width: 2px;">' .
         $actbar .= '<td align="center" height="" style="width: 2px;">' . '<img src="' . $CFG->wwwroot . '/pix/spacer.gif" height="1" width="1" alt="" /></td>';
     }
     /* oncampus if (($week == 0) && ($tabhigh >= $this->course->numsections)) {
            $actbar .= '<td class="fnweeklynavselected ' . $extraclassfortab . '"  width="" height="25">All</td>';
        } else if ($tabhigh >= $this->course->numsections) {
            $actbar .= '<td class="fnweeklynavnorm ' . $extraclassfortab . '" width="" height="25">' .
                    '<a href="' . $url . '&selected_week=0">All</a></td>';
        } else */
     if ($tabhigh < $c['first_lection'] + $c['lections'] - 1) {
         // oncampus
         $n = $tablow + 6;
         if ($c['lections'] + $c['first_lection'] - $n < 6) {
             $n = $c['lections'] + $c['first_lection'] - 6;
         }
         $nxt = $n * 1000;
         $actbar .= '<td id="fn_tab_next" height=""><a href="' . $url . '&selected_week=' . $nxt . '" class="next-lection"><div class = "oc-lection-btn"></div></a></td>';
         // oncampus
     } else {
         $actbar .= '<td id="fn_tab_next" height=""><div class = "next-lection-inactive"></div></td>';
         // oncampus
     }
     $settingIcon = '';
     if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) {
         $settingIcon = '<a href="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/tabsettings.php?id=' . $this->course->id . '" > 
                             <img style="margin: 3px 1px 1px 5px;" src="' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/cog.png" /></a>';
     }
     //$actbar .= '<td width="1" align="center" height="25">'.$settingIcon.'</td>';
     $actbar .= '<td width="1" align="center" height="">' . $settingIcon . '</td>';
     $actbar .= '</tr>';
     /* $actbar .= '<tr>';
             $actbar .= '<td height="3" colspan="2"></td>';
     
     
             $this->tdselectedclass = $tdselectedclass;
     
             for ($i = $tablow; $i <= $tabhigh; $i++) {
                 if ($i == $week) {
                     $actbar .= '<td height="3" class="' . $tdselectedclass[$i] . '"></td>';
                 } else {
                     $actbar .= '<td height="3"></td>';
                 }
                 $actbar .= '<td height="3"></td>';
             }
             $actbar .= '<td height="3" colspan="2"></td>';
             $actbar .= '</tr>'; */
     $actbar .= '</table>';
     $actbar .= '</td></tr></table>';
     rebuild_course_cache($this->course->id);
     unset($maximumtabs);
     return $actbar;
 }