Merge branch 'master' into backup-convert

This commit is contained in:
David Mudrak 2011-05-13 03:16:13 +02:00
commit eb3dc80bc3
17 changed files with 203 additions and 72 deletions

View file

@ -47,19 +47,34 @@ class block_completionstatus extends block_base {
// Create empty content // Create empty content
$this->content = new stdClass; $this->content = new stdClass;
// Can edit settings?
$can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
// Get course completion data
$info = new completion_info($this->page->course);
// Don't display if completion isn't enabled! // Don't display if completion isn't enabled!
if (!$this->page->course->enablecompletion) { if (!completion_info::is_enabled_for_site()) {
$this->content->text = get_string('completionnotenabled', 'block_completionstatus'); if ($can_edit) {
$this->content->text = get_string('completionnotenabledforsite', 'completion');
}
return $this->content;
} else if (!$info->is_enabled()) {
if ($can_edit) {
$this->content->text = get_string('completionnotenabledforcourse', 'completion');
}
return $this->content; return $this->content;
} }
// Load criteria to display // Load criteria to display
$info = new completion_info($this->page->course);
$completions = $info->get_completions($USER->id); $completions = $info->get_completions($USER->id);
// Check if this course has any criteria // Check if this course has any criteria
if (empty($completions)) { if (empty($completions)) {
$this->content->text = get_string('nocriteria', 'block_completionstatus'); if ($can_edit) {
$this->content->text = get_string('nocriteriaset', 'completion');
}
return $this->content; return $this->content;
} }

View file

@ -60,14 +60,11 @@ $can_view = false;
// Can view own report // Can view own report
if ($USER->id == $user->id) { if ($USER->id == $user->id) {
$can_view = true; $can_view = true;
} } else if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
elseif (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
$can_view = true; $can_view = true;
} } else if (has_capability('coursereport/completion:view', $coursecontext)) {
elseif (has_capability('coursereport/completion:view', $coursecontext)) {
$can_view = true; $can_view = true;
} } else if (has_capability('coursereport/completion:view', $personalcontext)) {
elseif (has_capability('coursereport/completion:view', $personalcontext)) {
$can_view = true; $can_view = true;
} }
@ -76,23 +73,31 @@ if (!$can_view) {
} }
// Load completion data
$info = new completion_info($course);
$returnurl = "{$CFG->wwwroot}/course/view.php?id={$id}";
// Don't display if completion isn't enabled! // Don't display if completion isn't enabled!
if (!$course->enablecompletion) { if (!$info->is_enabled()) {
print_error('completionnotenabled', 'block_completionstatus'); print_error('completionnotenabled', 'completion', $returnurl);
} }
// Load criteria to display // Load criteria to display
$info = new completion_info($course);
$completions = $info->get_completions($user->id); $completions = $info->get_completions($user->id);
// Check if this course has any criteria // Check if this course has any criteria
if (empty($completions)) { if (empty($completions)) {
print_error('nocriteria', 'block_completionstatus'); print_error('nocriteriaset', 'completion', $returnurl);
} }
// Check this user is enroled // Check this user is enroled
if (!$info->is_tracked_user($user->id)) { if (!$info->is_tracked_user($user->id)) {
print_error('notenroled', 'completion'); if ($USER->id == $user->id) {
print_error('notenroled', 'completion', $returnurl);
} else {
print_error('usernotenroled', 'completion', $returnurl);
}
} }

View file

@ -1,9 +1,7 @@
<?php <?php
$string['completionnotenabled'] = 'Course completion is not enabled';
$string['completionprogressdetails'] = 'Completion progress details'; $string['completionprogressdetails'] = 'Completion progress details';
$string['completionstatus'] = 'Course completion status'; $string['completionstatus'] = 'Course completion status';
$string['criteriagroup'] = 'Criteria group'; $string['criteriagroup'] = 'Criteria group';
$string['nocriteria'] = 'No criteria have been set for this course';
$string['pluginname'] = 'Course completion status'; $string['pluginname'] = 'Course completion status';
$string['requirement'] = 'Requirement'; $string['requirement'] = 'Requirement';

View file

@ -40,36 +40,44 @@ class block_selfcompletion extends block_base {
} }
public function get_content() { public function get_content() {
global $USER; global $CFG, $USER;
// If content is cached // If content is cached
if ($this->content !== NULL) { if ($this->content !== NULL) {
return $this->content; return $this->content;
} }
global $CFG;
// Create empty content // Create empty content
$this->content = new stdClass; $this->content = new stdClass;
// Don't display if completion isn't enabled! // Can edit settings?
if (!$this->page->course->enablecompletion) { $can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
$this->content->text = get_string('completionnotenabled', 'block_selfcompletion');
return $this->content;
}
// Get course completion data // Get course completion data
$info = new completion_info($this->page->course); $info = new completion_info($this->page->course);
$completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
// Is course complete? // Don't display if completion isn't enabled!
if ($info->is_course_complete($USER->id)) { if (!completion_info::is_enabled_for_site()) {
if ($can_edit) {
$this->content->text = get_string('completionnotenabledforsite', 'completion');
}
return $this->content;
} else if (!$info->is_enabled()) {
if ($can_edit) {
$this->content->text = get_string('completionnotenabledforcourse', 'completion');
}
return $this->content; return $this->content;
} }
// Get this user's data
$completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
// Check if self completion is one of this course's criteria // Check if self completion is one of this course's criteria
if (empty($completion)) { if (empty($completion)) {
$this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion'); if ($can_edit) {
$this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
}
return $this->content; return $this->content;
} }
@ -79,13 +87,21 @@ class block_selfcompletion extends block_base {
return $this->content; return $this->content;
} }
// Check if the user has already marked themselves as complete // Is course complete?
if ($completion->is_complete()) { if ($info->is_course_complete($USER->id)) {
$this->content->text = get_string('coursealreadycompleted', 'completion');
return $this->content; return $this->content;
// Check if the user has already marked themselves as complete
} else if ($completion->is_complete()) {
$this->content->text = get_string('alreadyselfcompleted', 'block_selfcompletion');
return $this->content;
// If user is not complete, or has not yet self completed
} else { } else {
$this->content->text = ''; $this->content->text = '';
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/course/togglecompletion.php?course='.$this->page->course->id.'">'. $this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/course/togglecompletion.php?course='.$this->page->course->id.'">';
get_string('completecourse', 'block_selfcompletion').'</a>...'; $this->content->footer .= get_string('completecourse', 'block_selfcompletion').'</a>...';
} }
return $this->content; return $this->content;

View file

@ -23,8 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
$string['selfcompletion'] = 'Self completion'; $string['alreadyselfcompleted'] = 'You have already marked yourself as complete in this course';
$string['pluginname'] = 'Self completion';
$string['completecourse'] = 'Complete course'; $string['completecourse'] = 'Complete course';
$string['completionnotenabled'] = 'Course completion is not enabled'; $string['pluginname'] = 'Self completion';
$string['selfcompletion'] = 'Self completion';
$string['selfcompletionnotenabled'] = 'The self completion criteria has not been enabled for this course'; $string['selfcompletionnotenabled'] = 'The self completion criteria has not been enabled for this course';

View file

@ -117,7 +117,7 @@ class blog_entry {
$this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id); $this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
$options = array('overflowdiv'=>true); $options = array('overflowdiv'=>true);
$template['body'] = format_text($this->summary, $this->summaryformat, $options).$cmttext; $template['body'] = format_text($this->summary, $this->summaryformat, $options);
$template['title'] = format_string($this->subject); $template['title'] = format_string($this->subject);
$template['userid'] = $user->id; $template['userid'] = $user->id;
$template['author'] = fullname($user); $template['author'] = fullname($user);
@ -307,6 +307,9 @@ class blog_entry {
$contentcell->text .= '</div>'; $contentcell->text .= '</div>';
} }
//add comments under everything
$contentcell->text .= $cmttext;
$mainrow->cells[] = $contentcell; $mainrow->cells[] = $contentcell;
$table->data = array($mainrow); $table->data = array($mainrow);

View file

@ -89,7 +89,7 @@ function callback_weeks_get_section_name($course, $section) {
foreach ($sections as $sec) { foreach ($sections as $sec) {
if ($sec->id == $section->id) { if ($sec->id == $section->id) {
break; break;
} else if ($sec->visible && $sec->section != 0) { } else if ($sec->section != 0) {
$weekdate += 604800; $weekdate += 604800;
} }
} }

View file

@ -56,6 +56,9 @@ $string['completion_manual'] = 'Students can manually mark the activity as compl
$string['completion_none'] = 'Do not indicate activity completion'; $string['completion_none'] = 'Do not indicate activity completion';
$string['completion-title-manual-n'] = 'Mark as complete'; $string['completion-title-manual-n'] = 'Mark as complete';
$string['completion-title-manual-y'] = 'Mark as not complete'; $string['completion-title-manual-y'] = 'Mark as not complete';
$string['completionnotenabled'] = 'Completion is not enabled';
$string['completionnotenabledforcourse'] = 'Completion is not enabled for this course';
$string['completionnotenabledforsite'] = 'Completion is not enabled for this site';
$string['completionusegrade'] = 'Require grade'; $string['completionusegrade'] = 'Require grade';
$string['completionusegrade_help'] = 'If enabled, the activity is considered complete when a student receives a grade. Pass and fail icons may be displayed if a pass grade for the activity has been set.'; $string['completionusegrade_help'] = 'If enabled, the activity is considered complete when a student receives a grade. Pass and fail icons may be displayed if a pass grade for the activity has been set.';
$string['completionusegrade_desc'] = 'Student must receive a grade to complete this activity'; $string['completionusegrade_desc'] = 'Student must receive a grade to complete this activity';
@ -93,6 +96,7 @@ $string['completionsettingslocked']='Completion settings locked';
$string['completionstartonenrol']='Completion tracking begins on enrolment'; $string['completionstartonenrol']='Completion tracking begins on enrolment';
$string['completionstartonenrolhelp']='Begin tracking a student\'s progress in course completion after course enrolment'; $string['completionstartonenrolhelp']='Begin tracking a student\'s progress in course completion after course enrolment';
$string['confirmselfcompletion']='Confirm self completion'; $string['confirmselfcompletion']='Confirm self completion';
$string['coursealreadycompleted']='You have already completed this course';
$string['coursecomplete']='Course complete'; $string['coursecomplete']='Course complete';
$string['coursecompleted']='Course completed'; $string['coursecompleted']='Course completed';
$string['coursegrade']='Course grade'; $string['coursegrade']='Course grade';
@ -121,7 +125,8 @@ $string['markcomplete']='Mark complete';
$string['markedcompleteby']='Marked complete by {$a}'; $string['markedcompleteby']='Marked complete by {$a}';
$string['markingyourselfcomplete']='Marking yourself complete'; $string['markingyourselfcomplete']='Marking yourself complete';
$string['moredetails']='More details'; $string['moredetails']='More details';
$string['notenroled']='You are not enroled as a student in this course'; $string['nocriteriaset']='No completion criteria set for this course';
$string['notenroled']='You are not enroled in this course';
$string['notyetstarted']='Not yet started'; $string['notyetstarted']='Not yet started';
$string['overallcriteriaaggregation']='Overall criteria type aggregation'; $string['overallcriteriaaggregation']='Overall criteria type aggregation';
$string['passinggrade']='Passing grade'; $string['passinggrade']='Passing grade';
@ -142,6 +147,7 @@ $string['unenrolingfromcourse']='Unenroling from course';
$string['unenrolment']='Unenrolment'; $string['unenrolment']='Unenrolment';
$string['unlockcompletiondelete']='Unlock completion options and delete user completion data'; $string['unlockcompletiondelete']='Unlock completion options and delete user completion data';
$string['usealternateselector']='Use the alternate course selector'; $string['usealternateselector']='Use the alternate course selector';
$string['usernotenroled']='User is not enroled in this course';
$string['viewcoursereport']='View course report'; $string['viewcoursereport']='View course report';
$string['viewingactivity']='Viewing the {$a}'; $string['viewingactivity']='Viewing the {$a}';
$string['xdays']='{$a} days'; $string['xdays']='{$a} days';

View file

@ -541,7 +541,7 @@ class block_manager {
list($pagetypepatterntest, $pagetypepatternparams) = list($pagetypepatterntest, $pagetypepatternparams) =
$DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest'); $DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest');
list($ccselect, $ccjoin) = context_instance_preload_sql('b.id', CONTEXT_BLOCK, 'ctx'); list($ccselect, $ccjoin) = context_instance_preload_sql('bi.id', CONTEXT_BLOCK, 'ctx');
$params = array( $params = array(
'subpage1' => $this->page->subpage, 'subpage1' => $this->page->subpage,

View file

@ -603,8 +603,8 @@ class completion_info {
* @return void * @return void
*/ */
public function set_module_viewed($cm, $userid=0) { public function set_module_viewed($cm, $userid=0) {
global $PAGE; global $PAGE, $UNITTEST;
if ($PAGE->headerprinted) { if ($PAGE->headerprinted && empty($UNITTEST->running)) {
debugging('set_module_viewed must be called before header is printed', debugging('set_module_viewed must be called before header is printed',
DEBUG_DEVELOPER); DEBUG_DEVELOPER);
} }

View file

@ -579,6 +579,10 @@ class mysqli_native_moodle_database extends moodle_database {
if ($column->meta_type == 'I' or $column->meta_type == 'F' or $column->meta_type == 'N') { if ($column->meta_type == 'I' or $column->meta_type == 'F' or $column->meta_type == 'N') {
$value = 0; // prevent '' problems in numeric fields $value = 0; // prevent '' problems in numeric fields
} }
// Any float value being stored in varchar or text field is converted to string to avoid
// any implicit conversion by MySQL
} else if (is_float($value) and ($column->meta_type == 'C' or $column->meta_type == 'X')) {
$value = "$value";
} }
// workaround for problem with wrong enums in mysql - TODO: Out in Moodle 2.1 // workaround for problem with wrong enums in mysql - TODO: Out in Moodle 2.1
if (!empty($column->enums)) { if (!empty($column->enums)) {

View file

@ -1806,6 +1806,34 @@ class dml_test extends UnitTestCase {
$DB->delete_records($tablename, array()); $DB->delete_records($tablename, array());
$id4 = $DB->insert_record($tablename, array('course' => 3)); $id4 = $DB->insert_record($tablename, array('course' => 3));
$this->assertTrue($id3 < $id4); $this->assertTrue($id3 < $id4);
// Test saving a float in a CHAR column, and reading it back.
$id = $DB->insert_record($tablename, array('onechar' => 1.0));
$this->assertEqual(1.0, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e20));
$this->assertEqual(1e20, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e-4));
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onechar' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
// Test saving a float in a TEXT column, and reading it back.
$id = $DB->insert_record($tablename, array('onetext' => 1.0));
$this->assertEqual(1.0, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e20));
$this->assertEqual(1e20, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e-4));
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$id = $DB->insert_record($tablename, array('onetext' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
} }
public function test_import_record() { public function test_import_record() {
@ -2178,6 +2206,35 @@ class dml_test extends UnitTestCase {
$this->assertEqual($newclob, $record->onetext, 'Test "small" CLOB update (full contents output disabled)'); $this->assertEqual($newclob, $record->onetext, 'Test "small" CLOB update (full contents output disabled)');
$this->assertEqual($newblob, $record->onebinary, 'Test "small" BLOB update (full contents output disabled)'); $this->assertEqual($newblob, $record->onebinary, 'Test "small" BLOB update (full contents output disabled)');
// Test saving a float in a CHAR column, and reading it back.
$id = $DB->insert_record($tablename, array('onechar' => 'X'));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1.0));
$this->assertEqual(1.0, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e20));
$this->assertEqual(1e20, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e-4));
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onechar' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
// Test saving a float in a TEXT column, and reading it back.
$id = $DB->insert_record($tablename, array('onetext' => 'X'));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1.0));
$this->assertEqual(1.0, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e20));
$this->assertEqual(1e20, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e-4));
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e-5));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e-300));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->update_record($tablename, array('id' => $id, 'onetext' => 1e300));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
} }
public function test_set_field() { public function test_set_field() {
@ -2243,6 +2300,36 @@ class dml_test extends UnitTestCase {
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
} }
// Test saving a float in a CHAR column, and reading it back.
$id = $DB->insert_record($tablename, array('onechar' => 'X'));
$DB->set_field($tablename, 'onechar', 1.0, array('id' => $id));
$this->assertEqual(1.0, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e20, array('id' => $id));
$this->assertEqual(1e20, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e-4, array('id' => $id));
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e-5, array('id' => $id));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e-300, array('id' => $id));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
$DB->set_field($tablename, 'onechar', 1e300, array('id' => $id));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onechar', array('id' => $id)));
// Test saving a float in a TEXT column, and reading it back.
$id = $DB->insert_record($tablename, array('onetext' => 'X'));
$DB->set_field($tablename, 'onetext', 1.0, array('id' => $id));
$this->assertEqual(1.0, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e20, array('id' => $id));
$this->assertEqual(1e20, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e-4, array('id' => $id));
$this->assertEqual(1e-4, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e-5, array('id' => $id));
$this->assertEqual(1e-5, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e-300, array('id' => $id));
$this->assertEqual(1e-300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
$DB->set_field($tablename, 'onetext', 1e300, array('id' => $id));
$this->assertEqual(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id)));
// Note: All the nulls, booleans, empties, quoted and backslashes tests // Note: All the nulls, booleans, empties, quoted and backslashes tests
// go to set_field_select() because set_field() is just one wrapper over it // go to set_field_select() because set_field() is just one wrapper over it
} }

View file

@ -525,7 +525,7 @@ class moodle_page_cm_test extends UnitTestCaseUsingDatabase {
parent::setUp(); parent::setUp();
$this->originalcourse = $COURSE; $this->originalcourse = $COURSE;
$this->testpage = new moodle_page(); $this->testpage = new moodle_page();
$this->create_test_tables(array('course', 'context'), 'lib'); $this->create_test_tables(array('course', 'context', 'modules', 'course_modules', 'course_modules_availability', 'grade_items', 'course_sections'), 'lib');
$this->create_test_table('forum', 'mod/forum'); $this->create_test_table('forum', 'mod/forum');
$this->switch_to_test_db(); $this->switch_to_test_db();
@ -551,6 +551,7 @@ class moodle_page_cm_test extends UnitTestCaseUsingDatabase {
$course->fullname = 'Anonymous test course'; $course->fullname = 'Anonymous test course';
$course->shortname = 'ANON'; $course->shortname = 'ANON';
$course->summary = ''; $course->summary = '';
$course->modinfo = null;
$course->id = $this->testdb->insert_record('course', $course); $course->id = $this->testdb->insert_record('course', $course);
$forum = new stdClass; $forum = new stdClass;
@ -559,12 +560,23 @@ class moodle_page_cm_test extends UnitTestCaseUsingDatabase {
$forum->intro = ''; $forum->intro = '';
$forum->id = $this->testdb->insert_record('forum', $forum); $forum->id = $this->testdb->insert_record('forum', $forum);
$module = new stdClass;
$module->name = 'forum';
$module->id = $this->testdb->insert_record('modules', $module);
$cm = new stdClass; $cm = new stdClass;
$cm->id = 13;
$cm->course = $course->id; $cm->course = $course->id;
$cm->instance = $forum->id; $cm->instance = $forum->id;
$cm->modname = 'forum'; $cm->modname = 'forum';
$cm->module = $module->id;
$cm->name = $forum->name; $cm->name = $forum->name;
$cm->id = $this->testdb->insert_record('course_modules', $cm);
$section = new stdClass;
$section->course = $course->id;
$section->section = 0;
$section->sequence = $cm->id;
$section->id = $this->testdb->insert_record('course_sections', $section);
$context = new stdClass; $context = new stdClass;
$context->contextlevel = CONTEXT_MODULE; $context->contextlevel = CONTEXT_MODULE;
@ -590,26 +602,6 @@ class moodle_page_cm_test extends UnitTestCaseUsingDatabase {
$this->assert(new CheckSpecifiedFieldsExpectation($cm), $this->testpage->cm); $this->assert(new CheckSpecifiedFieldsExpectation($cm), $this->testpage->cm);
} }
public function test_cannot_set_cm_without_name() {
// Setup fixture
list($cm) = $this->create_a_forum_with_context();
// Set expectation
$this->expectException();
// Exercise SUT
unset($cm->name);
$this->testpage->set_cm($cm);
}
public function test_cannot_set_cm_without_modname() {
// Setup fixture
list($cm) = $this->create_a_forum_with_context();
// Set expectation
$this->expectException();
// Exercise SUT
unset($cm->modname);
$this->testpage->set_cm($cm);
}
public function test_cannot_set_activity_record_before_cm() { public function test_cannot_set_activity_record_before_cm() {
// Setup fixture // Setup fixture
list($cm, $course, $forum) = $this->create_a_forum_with_context(); list($cm, $course, $forum) = $this->create_a_forum_with_context();
@ -672,18 +664,21 @@ class moodle_page_cm_test extends UnitTestCaseUsingDatabase {
$this->testpage->set_activity_record($forum); $this->testpage->set_activity_record($forum);
} }
public function test_settin_cm_sets_course() { public function test_setting_cm_sets_course() {
// Setup fixture // Setup fixture
list($cm, $course) = $this->create_a_forum_with_context(); list($cm, $course) = $this->create_a_forum_with_context();
// Exercise SUT // Exercise SUT
$this->testpage->set_cm($cm); $this->testpage->set_cm($cm);
// Validate // Validate
unset($course->modinfo); // This changed, but we don't care
$this->assert(new CheckSpecifiedFieldsExpectation($course), $this->testpage->course); $this->assert(new CheckSpecifiedFieldsExpectation($course), $this->testpage->course);
} }
public function test_set_cm_with_course_and_activity_no_db() { public function test_set_cm_with_course_and_activity_no_db() {
// Setup fixture // Setup fixture
list($cm, $course, $forum) = $this->create_a_forum_with_context(); list($cm, $course, $forum) = $this->create_a_forum_with_context();
// This only works without db if we already have modinfo cache
$modinfo = get_fast_modinfo($course);
$this->drop_test_table('forum'); $this->drop_test_table('forum');
$this->drop_test_table('course'); $this->drop_test_table('course');
// Exercise SUT // Exercise SUT

View file

@ -715,6 +715,8 @@ class UnitTestCaseUsingDatabase extends UnitTestCase {
if ($cleanmore) { if ($cleanmore) {
accesslib_clear_all_caches_for_unit_testing(); accesslib_clear_all_caches_for_unit_testing();
$course = 'reset';
get_fast_modinfo($course);
} }
} }

View file

@ -1285,12 +1285,12 @@ function upgrade_language_pack($lang='') {
require_once($CFG->libdir.'/componentlib.class.php'); require_once($CFG->libdir.'/componentlib.class.php');
$installer = new lang_installer($pack); $installer = new lang_installer($lang);
$results = $installer->run(); $results = $installer->run();
foreach ($results as $langcode => $langstatus) { foreach ($results as $langcode => $langstatus) {
switch ($langstatus) { switch ($langstatus) {
case lang_installer::RESULT_DOWNLOADERROR: case lang_installer::RESULT_DOWNLOADERROR:
echo $OUTPUT->notification($pack . '.zip'); echo $OUTPUT->notification($langcode . '.zip');
break; break;
case lang_installer::RESULT_INSTALLED: case lang_installer::RESULT_INSTALLED:
echo $OUTPUT->notification(get_string('langpackinstalled', 'admin', $langcode), 'notifysuccess'); echo $OUTPUT->notification(get_string('langpackinstalled', 'admin', $langcode), 'notifysuccess');

View file

@ -235,15 +235,15 @@ class feedback_item_multichoice extends feedback_item_base {
// $worksheet->setFormat("<l><f><ro2><vo><c:green>"); // $worksheet->setFormat("<l><f><ro2><vo><c:green>");
//frage schreiben //frage schreiben
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2_green); $worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
$worksheet->write_string($rowOffset, 1, $analysed_item[1], $xlsFormats->head2_green); $worksheet->write_string($rowOffset, 1, $analysed_item[1], $xlsFormats->head2);
if (is_array($data)) { if (is_array($data)) {
$sizeofdata = sizeof($data); $sizeofdata = sizeof($data);
for ($i = 0; $i < $sizeofdata; $i++) { for ($i = 0; $i < $sizeofdata; $i++) {
$aData = $data[$i]; $aData = $data[$i];
// $worksheet->setFormat("<l><f><ro2><vo><c:blue>"); // $worksheet->setFormat("<l><f><ro2><vo><c:blue>");
$worksheet->write_string($rowOffset, $i + 2, trim($aData->answertext), $xlsFormats->value_blue); $worksheet->write_string($rowOffset, $i + 2, trim($aData->answertext), $xlsFormats->head2);
// $worksheet->setFormat("<l><vo>"); // $worksheet->setFormat("<l><vo>");
$worksheet->write_number($rowOffset + 1, $i + 2, $aData->answercount, $xlsFormats->default); $worksheet->write_number($rowOffset + 1, $i + 2, $aData->answercount, $xlsFormats->default);

View file

@ -30,10 +30,10 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$version = 2011050500.00; // YYYYMMDD = weekly release date of this DEV branch $version = 2011051100.00; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches // RR = release increments - 00 in DEV branches
// .XX = incremental changes // .XX = incremental changes
$release = '2.1dev (Build: 20110505)'; // Human-friendly version name $release = '2.1dev (Build: 20110511)'; // Human-friendly version name
$maturity = MATURITY_ALPHA; // this version's maturity level $maturity = MATURITY_ALPHA; // this version's maturity level