[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/mod/survey/ -> index.php (source)

   1  <?php // $Id: index.php,v 1.24.2.5 2008/02/05 21:39:52 skodak Exp $
   2  
   3      require_once("../../config.php");
   4      require_once ("lib.php");
   5  
   6      $id = required_param('id', PARAM_INT);    // Course Module ID
   7  
   8      if (! $course = get_record("course", "id", $id)) {
   9          error("Course ID is incorrect");
  10      }
  11  
  12      require_course_login($course);
  13  
  14      add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", "");
  15  
  16      $strsurveys = get_string("modulenameplural", "survey");
  17      $strweek = get_string("week");
  18      $strtopic = get_string("topic");
  19      $strname = get_string("name");
  20      $strstatus = get_string("status");
  21      $strdone  = get_string("done", "survey");
  22      $strnotdone  = get_string("notdone", "survey");
  23  
  24      $navlinks = array();
  25      $navlinks[] = array('name' => $strsurveys, 'link' => '', 'type' => 'activity');
  26      $navigation = build_navigation($navlinks);
  27  
  28      print_header_simple("$strsurveys", "", $navigation,
  29                   "", "", true, "", navmenu($course));
  30  
  31      if (! $surveys = get_all_instances_in_course("survey", $course)) {
  32          notice(get_string('thereareno', 'moodle', $strsurveys), "../../course/view.php?id=$course->id");
  33      }
  34  
  35      if ($course->format == "weeks") {
  36          $table->head  = array ($strweek, $strname, $strstatus);
  37          $table->align = array ("CENTER", "LEFT", "LEFT");
  38      } else if ($course->format == "topics") {
  39          $table->head  = array ($strtopic, $strname, $strstatus);
  40          $table->align = array ("CENTER", "LEFT", "LEFT");
  41      } else {
  42          $table->head  = array ($strname, $strstatus);
  43          $table->align = array ("LEFT", "LEFT");
  44      }
  45  
  46      $currentsection = '';
  47  
  48      foreach ($surveys as $survey) {
  49          if (!empty($USER->id) and survey_already_done($survey->id, $USER->id)) {
  50              $ss = $strdone;
  51          } else {
  52              $ss = $strnotdone;
  53          }
  54          $printsection = "";
  55          if ($survey->section !== $currentsection) {
  56              if ($survey->section) {
  57                  $printsection = $survey->section;
  58              }
  59              if ($currentsection !== "") {
  60                  $table->data[] = 'hr';
  61              }
  62              $currentsection = $survey->section;
  63          }
  64          //Calculate the href
  65          if (!$survey->visible) {
  66              //Show dimmed if the mod is hidden
  67              $tt_href = "<a class=\"dimmed\" href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</a>";
  68          } else {
  69              //Show normal if the mod is visible
  70              $tt_href = "<a href=\"view.php?id=$survey->coursemodule\">".format_string($survey->name,true)."</a>";
  71          }
  72  
  73          if ($course->format == "weeks" or $course->format == "topics") {
  74              $table->data[] = array ($printsection, $tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
  75          } else {
  76              $table->data[] = array ($tt_href, "<a href=\"view.php?id=$survey->coursemodule\">$ss</a>");
  77          }
  78      }
  79  
  80      echo "<br />";
  81      print_table($table);
  82      print_footer($course);
  83  
  84  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7