Commit 13534ef7 authored by Martin Langhoff's avatar Martin Langhoff
Browse files

cvsimport fixups

parent 59aa15d6
This diff is collapsed.
......@@ -10,7 +10,8 @@
print_heading(page_doc_link(get_string('adminreport', 'question')));
$probstr = '';
if ($CFG->version < 2007081000){
$contextupgradeversion = 2007081000;
if ($CFG->version < $contextupgradeversion){
///cwrqpfs issue
$probstr = print_heading(get_string('cwrqpfs', 'question'), '', 3, 'main', true);
......@@ -34,12 +35,12 @@
}
$probstr .= '<li>'.get_string('changepublishstatuscat', 'question', $categories[$id]);
if ($questions = get_records_sql('SELECT q.*, qui.id as quizid, qui.name as quizname, cm.id as cmid, '
.'qui.course, c.fullname as coursename FROM '.$CFG->prefix.'question as q, '
.$CFG->prefix.'quiz_question_instances as qqi, '
.$CFG->prefix.'quiz as qui, '
.$CFG->prefix.'course_modules as cm, '
.$CFG->prefix.'modules as m, '
.$CFG->prefix.'course as c '
.'qui.course, c.fullname as coursename FROM '.$CFG->prefix.'question q, '
.$CFG->prefix.'quiz_question_instances qqi, '
.$CFG->prefix.'quiz qui, '
.$CFG->prefix.'course_modules cm, '
.$CFG->prefix.'modules m, '
.$CFG->prefix.'course c '
.'WHERE (q.category = '.$id.' AND qqi.question = q.id '
.'AND qqi.quiz = qui.id '
.'AND qui.course = c.id '
......
......@@ -102,7 +102,7 @@ class block_admin extends block_list {
if (($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context) && ($course->id!==SITEID)) {
$strgroups = get_string('groups');
$this->content->items[]='<a title="'.$strgroups.'" href="'.groups_home_url($this->instance->pageid).'">'.$strgroups.'</a>';
$this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/group/index.php?id='.$this->instance->pageid.'">'.$strgroups.'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" class="icon" alt="" />';
}
......
......@@ -114,6 +114,12 @@ if ($events === false) {
$ical = new iCalendar;
$ical->add_property('method', 'PUBLISH');
foreach($events as $event) {
if (!empty($event->modulename)) {
$cm = get_coursemodule_from_instance($event->modulename, $event->instance);
if (!groups_course_module_visible($cm)) {
continue;
}
}
$ev = new iCalendar_event;
$ev->add_property('summary', $event->name);
$ev->add_property('description', $event->description);
......
......@@ -152,13 +152,19 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
// Set event course class for course events
if (!empty($events)) {
foreach ($events as $event) {
foreach ($events as $eventid => $event) {
if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
$event->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
}
if (!empty($event->modulename)) {
$cm = get_coursemodule_from_instance($event->modulename, $event->instance);
if (!groups_course_module_visible($cm)) {
unset($events[$eventid]);
}
}
}
}
// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
......@@ -418,6 +424,12 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
if($events !== false) {
foreach($events as $event) {
if(!empty($event->modulename)) {
$mod = get_coursemodule_from_instance($event->modulename, $event->instance);
if (!groups_course_module_visible($mod)) {
continue;
}
}
if($processed >= $display->maxevents) {
break;
......
......@@ -372,7 +372,17 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $course
else {
$events = get_records_select('event', $whereclause, 'timestart');
}
if (!empty($events)) {
foreach($events as $eventid => $event) {
if (!empty($event->modulename)) {
$cm = get_coursemodule_from_instance($event->modulename, $event->instance);
if (!groups_course_module_visible($cm)) {
unset($events[$eventid]);
}
}
}
}
// Extract information: events vs. time
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
......
......@@ -256,6 +256,10 @@ $CFG->admin = 'admin';
// called. This option will action disregarding error_reporting setting.
// $CFG->dblogerror = true;
//
// The following setting will log every database query to a table called adodb_logsql.
// Use this setting on a development server only, the table grows quickly!
// $CFG->logsql = true;
//
// The following setting will turn on username logging into Apache log. For full details regarding setting
// up of this function please refer to the install section of the document.
// $CFG->apacheloguser = 0; // Turn this feature off. Default value.
......
<?php // $Id$
// Displays all grades for a student in a course
require_once("../config.php");
require_once("lib.php");
$id = required_param('id',PARAM_INT); // course id
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect");
}
if (!$course->showgrades) {
error("Grades are not available for students in this course");
}
require_login($course->id);
$strgrades = get_string("grades");
$strgrade = get_string("grade");
$strmax = get_string("maximumshort");
$stractivityreport = get_string("activityreport");
/// Get a list of all students
$columnhtml = array(); // Accumulate column html in this array.
$grades = array(); // Collect all grades in this array
$maxgrades = array(); // Collect all max grades in this array
$totalgrade = 0;
$totalmaxgrade = 0;
/// Collect modules data
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
/// Search through all the modules, pulling out grade data
$sections = get_all_sections($course->id); // Sort everything the same as the course
for ($i=0; $i<=$course->numsections; $i++) {
if (isset($sections[$i])) { // should always be true
$section = $sections[$i];
if (!empty($section->sequence)) {
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $sectionmod) {
$mod = $mods[$sectionmod];
if ($mod->visible) {
$instance = get_record("$mod->modname", "id", "$mod->instance");
$libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
if (file_exists($libfile)) {
require_once($libfile);
$gradefunction = $mod->modname."_grades";
if (function_exists($gradefunction)) { // Skip modules without grade function
if ($modgrades = $gradefunction($mod->instance)) {
$image = "<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
" title=\"$mod->modfullname\">".
"<img valign=\"middle\" src=\"../mod/$mod->modname/icon.gif\" ".
"class=\"icon\" alt=\"$mod->modfullname\" /></a>";
$columnhtml[] = "$image ".
"<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
format_string($instance->name,true).
"</a>";
if (empty($modgrades->grades[$USER->id])) {
$grades[] = "";
} else {
$grades[] = $modgrades->grades[$USER->id];
$totalgrade += (float)$modgrades->grades[$USER->id];
}
if (empty($modgrades->maxgrade)) {
$maxgrades[] = "";
} else {
$maxgrades[] = $modgrades->maxgrade;
$totalmaxgrade += $modgrades->maxgrade;
}
}
}
}
}
}
}
}
}
/// OK, we have all the data, now present it to the user
print_header("$course->shortname: $strgrades", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
-> $strgrades");
print_heading($strgrades);
$table->head = array( get_string("activity"), get_string("maximumgrade"), get_string("grade"));
$table->align = array("LEFT", "RIGHT", "RIGHT");
foreach ($grades as $key => $grade) {
$table->data[] = array($columnhtml[$key], $maxgrades[$key], $grade);
}
$table->data[] = array(get_string("total"), $totalmaxgrade, $totalgrade);
print_table($table);
print_continue("view.php?id=$course->id");
print_footer($course);
?>
<?php // $Id$
// Displays all grades for a course
require_once("../config.php");
require_once("lib.php");
$id = required_param('id', PARAM_INT); // course id
$download = optional_param('download', '', PARAM_ALPHA);// to download data
$changegroup = optional_param('group', -1, PARAM_INT );
require_login();
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect");
}
require_capability('moodle/course:viewcoursegrades', get_context_instance(CONTEXT_COURSE, $id));
$strgrades = get_string("grades");
$strgrade = get_string("grade");
$strmax = get_string("maximumshort");
$stractivityreport = get_string("activityreport");
/// Check to see if groups are being used in this course
$groupmode = groupmode($course);
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
/// Get a list of all students
if ($currentgroup) {
if (!$students = get_group_students($currentgroup, "u.lastname ASC")) {
print_header("$course->shortname: $strgrades", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
-> $strgrades");
setup_and_print_groups($course, $groupmode, "grades.php?id=$course->id");
notice(get_string("nostudentsingroup"), "$CFG->wwwroot/course/view.php?id=$course->id");
print_footer($course);
exit;
}
} else {
if (!$students = get_course_students($course->id, "u.lastname ASC")) {
print_header("$course->shortname: $strgrades", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
-> $strgrades");
notice(get_string("nostudentsyet"), "$CFG->wwwroot/course/view.php?id=$course->id");
print_footer($course);
exit;
}
}
foreach ($students as $student) {
$grades[$student->id] = array(); // Collect all grades in this array
$gradeshtml[$student->id] = array(); // Collect all grades html formatted in this array
$totals[$student->id] = array(); // Collect all totals in this array
}
$columns = array(); // Accumulate column names in this array.
$columnhtml = array(); // Accumulate column html in this array.
/// Collect modules data
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
/// Search through all the modules, pulling out grade data
$sections = get_all_sections($course->id); // Sort everything the same as the course
for ($i=0; $i<=$course->numsections; $i++) {
if (isset($sections[$i])) { // should always be true
$section = $sections[$i];
if ($section->sequence) {
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $sectionmod) {
$mod = $mods[$sectionmod];
$instance = get_record("$mod->modname", "id", "$mod->instance");
$libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
if (file_exists($libfile)) {
require_once($libfile);
$gradefunction = $mod->modname."_grades";
if (function_exists($gradefunction)) { // Skip modules without grade function
if ($modgrades = $gradefunction($mod->instance)) {
if (!empty($modgrades->maxgrade)) {
if ($mod->visible) {
$maxgrade = "$strmax: $modgrades->maxgrade";
$maxgradehtml = "<br />$strmax: $modgrades->maxgrade";
} else {
$maxgrade = "$strmax: $modgrades->maxgrade";
$maxgradehtml = "<br /><font class=\"dimmed_text\">$strmax: $modgrades->maxgrade</font>";
}
} else {
$maxgrade = "";
$maxgradehtml = "";
}
$image = "<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\"".
" title=\"$mod->modfullname\">".
"<img src=\"../mod/$mod->modname/icon.gif\" ".
"class=\"icon\" alt=\"$mod->modfullname\" /></a>";
if ($mod->visible) {
$columnhtml[] = "$image ".
"<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
format_string($instance->name,true).
"</a>$maxgradehtml";
} else {
$columnhtml[] = "$image ".
"<a class=\"dimmed\" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
format_string($instance->name,true).
"</a>$maxgradehtml";
}
$columns[] = "$mod->modfullname: ".format_string($instance->name)." - $maxgrade";
foreach ($students as $student) {
if (!empty($modgrades->grades[$student->id])) {
$grades[$student->id][] = $currentstudentgrade = $modgrades->grades[$student->id];
if ($mod->visible) {
$gradeshtml[$student->id][] = $modgrades->grades[$student->id];
} else {
$gradeshtml[$student->id][] = "<font class=\"dimmed_text\">".
$modgrades->grades[$student->id].
"</font>";
}
} else {
$grades[$student->id][] = $currentstudentgrade = "";
$gradeshtml[$student->id][] = "";
}
if (!empty($modgrades->maxgrade)) {
$totals[$student->id] = (float)($totals[$student->id]) + (float)($currentstudentgrade);
} else {
$totals[$student->id] = (float)($totals[$student->id]) + 0;
}
}
}
}
}
}
}
}
} // a new Moodle nesting record? ;-)
/// OK, we have all the data, now present it to the user
if ($download == "ods" and confirm_sesskey()) {
require_once("../lib/odslib.class.php");
/// Calculate file name
$downloadfilename = clean_filename("$course->shortname $strgrades.ods");
/// Creating a workbook
$workbook = new MoodleODSWorkbook("-");
/// Sending HTTP headers
$workbook->send($downloadfilename);
/// Adding the worksheet
$myxls =& $workbook->add_worksheet($strgrades);
/// Print names of all the fields
$myxls->write_string(0,0,get_string("firstname"));
$myxls->write_string(0,1,get_string("lastname"));
$myxls->write_string(0,2,get_string("idnumber"));
$myxls->write_string(0,3,get_string("institution"));
$myxls->write_string(0,4,get_string("department"));
$myxls->write_string(0,5,get_string("email"));
$pos=6;
foreach ($columns as $column) {
$myxls->write_string(0,$pos++,strip_tags($column));
}
$myxls->write_string(0,$pos,get_string("total"));
/// Print all the lines of data.
$i = 0;
foreach ($grades as $studentid => $studentgrades) {
$i++;
$student = $students[$studentid];
if (empty($totals[$student->id])) {
$totals[$student->id] = '';
}
$myxls->write_string($i,0,$student->firstname);
$myxls->write_string($i,1,$student->lastname);
$myxls->write_string($i,2,$student->idnumber);
$myxls->write_string($i,3,$student->institution);
$myxls->write_string($i,4,$student->department);
$myxls->write_string($i,5,$student->email);
$j=6;
foreach ($studentgrades as $grade) {
$myxls->write_string($i,$j++,strip_tags($grade));
}
$myxls->write_number($i,$j,$totals[$student->id]);
}
/// Close the workbook
$workbook->close();
exit;
} else if ($download == "xls" and confirm_sesskey()) {
require_once("../lib/excellib.class.php");
/// Calculate file name
$downloadfilename = clean_filename("$course->shortname $strgrades.xls");
/// Creating a workbook
$workbook = new MoodleExcelWorkbook("-");
/// Sending HTTP headers
$workbook->send($downloadfilename);
/// Adding the worksheet
$myxls =& $workbook->add_worksheet($strgrades);
/// Print names of all the fields
$myxls->write_string(0,0,get_string("firstname"));
$myxls->write_string(0,1,get_string("lastname"));
$myxls->write_string(0,2,get_string("idnumber"));
$myxls->write_string(0,3,get_string("institution"));
$myxls->write_string(0,4,get_string("department"));
$myxls->write_string(0,5,get_string("email"));
$pos=6;
foreach ($columns as $column) {
$myxls->write_string(0,$pos++,strip_tags($column));
}
$myxls->write_string(0,$pos,get_string("total"));
/// Print all the lines of data.
$i = 0;
foreach ($grades as $studentid => $studentgrades) {
$i++;
$student = $students[$studentid];
if (empty($totals[$student->id])) {
$totals[$student->id] = '';
}
$myxls->write_string($i,0,$student->firstname);
$myxls->write_string($i,1,$student->lastname);
$myxls->write_string($i,2,$student->idnumber);
$myxls->write_string($i,3,$student->institution);
$myxls->write_string($i,4,$student->department);
$myxls->write_string($i,5,$student->email);
$j=6;
foreach ($studentgrades as $grade) {
$myxls->write_string($i,$j++,strip_tags($grade));
}
$myxls->write_number($i,$j,$totals[$student->id]);
}
/// Close the workbook
$workbook->close();
exit;
} else if ($download == "txt" and confirm_sesskey()) {
/// Print header to force download
header("Content-Type: application/download\n");
$downloadfilename = clean_filename("$course->shortname $strgrades");
header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\"");
/// Print names of all the fields
echo get_string("firstname")."\t".
get_string("lastname")."\t".
get_string("idnumber")."\t".
get_string("institution")."\t".
get_string("department")."\t".
get_string("email");
foreach ($columns as $column) {
$column = strip_tags($column);
echo "\t$column";
}
echo "\t".get_string("total")."\n";
/// Print all the lines of data.
foreach ($grades as $studentid => $studentgrades) {
$student = $students[$studentid];
if (empty($totals[$student->id])) {
$totals[$student->id] = '';
}
echo "$student->firstname\t$student->lastname\t$student->idnumber\t$student->institution\t$student->department\t$student->email";
foreach ($studentgrades as $grade) {
$grade = strip_tags($grade);
echo "\t$grade";
}
echo "\t".$totals[$student->id];
echo "\n";
}
exit;
} else { // Just print the web page
print_header("$course->shortname: $strgrades", $course->fullname,
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
-> $strgrades");
print_heading($strgrades);
setup_and_print_groups($course, $groupmode, "grades.php?id=$course->id");
echo "<table border=\"0\" align=\"center\"><tr>";
echo "<td>";
$options = array();
$options["id"] = "$course->id";
$options["download"] = "ods";
$options["sesskey"] = $USER->sesskey;
print_single_button("grades.php", $options, get_string("downloadods"));
echo "<td>";
$options["download"] = "xls";
print_single_button("grades.php", $options, get_string("downloadexcel"));
echo "<td>";
$options["download"] = "txt";
print_single_button("grades.php", $options, get_string("downloadtext"));
echo "</table>";
$table->head = array_merge(array ("", get_string("firstname"), get_string("lastname")), $columnhtml, array(get_string("total")));
$table->width = array(35, "");
$table->align = array("LEFT", "RIGHT", "LEFT");
foreach ($columns as $column) {
$table->width[] = "";
$table->align[] = "CENTER";
}
$table->width[] = "";
$table->align[] = "CENTER";
foreach ($students as $key => $student) {
$studentgrades = $gradeshtml[$student->id];
if (empty($totals[$student->id])) {
$totals[$student->id] = '';
}
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
$name = array ("$picture", "$student->firstname", "$student->lastname");
$total = array ($totals[$student->id]);
$table->data[] = array_merge($name, $studentgrades, $total);
}
print_table($table);
print_footer($course);
}
?>
......@@ -87,6 +87,10 @@ function print_recent_selector_form($course, $advancedfilter=0, $selecteduser=0,
if (!$mod->visible and !has_capability('moodle/course:viewhiddenactivities',get_context_instance(CONTEXT_MODULE, $mod->cm))) {
continue;
}
$mod->id = $mod->cm;
if (!groups_course_module_visible($mod)) {
continue;
}
if ($mod->section > 0 and $section <> $mod->section) {
$activities["section/$mod->section"] = "-------------- $strsection $mod->section --------------";
......@@ -1156,6 +1160,8 @@ function get_array_of_activities($courseid) {
// section - the number of the section (eg week or topic)
// name - the name of the instance
// visible - is the instance visible or not
// groupingid - grouping id
// groupmembersonly - is this instance visible to group members only
// extra - contains extra string to include in any link
global $CFG;
......@@ -1179,6 +1185,8 @@ function get_array_of_activities($courseid) {
$mod[$seq]->section = $section->section;
$mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance));
$mod[$seq]->visible = $rawmods[$seq]->visible;
$mod[$seq]->groupingid = $rawmods[$seq]->groupingid;
$mod[$seq]->groupmembersonly = $rawmods[$seq]->groupmembersonly;
$mod[$seq]->extra = "";
$modname = $mod[$seq]->mod;
......@@ -1231,6 +1239,10 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname
if (empty($modnames[$mod->modname])) {