Blogs: Course Blog v0.7.3 for Moodle 1.9

Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Number of replies: 44
Here is a minor update for course blog. This fixes a few glitches in functionality, layout, and upgrade scripts. It is also the start of some support for MSSQL, which hasn't worked well with course blog in the past. I can't guarantee that this will work, but it is a start. Let me know how it works.

This is not a major update, so there are no changes to the database or new functions added. I am still interested in adding new features to Course Blog, including support for tags and groups. I also want to figure out how to get Course Blogs to work with the Moodle back-up function. Some of these are really complex, but if you know how to make that work, feel free to post the code or send it to me. I also want to add a 'save as draft' option. Any other ideas or contributions are gladly accepted. Just PM with what you are doing so I don't duplicate your efforts. I think that the db files need to be changed over to the newer upgrade method.

Also - a Swedish language file (courtesy of Tobias Wallenqvist - thanks!) was added. I think I've added all of the stuff that has been submitted so far, but if I forgot something - let me know and I will add it.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Stephen Liseo -

Hi Matt
Tried 0.7.3 this morning and this is what I got. Looks like problem creating the tables, I will try to get a SQL guru friend of mine to have a look.

Thanks for you efforts.

 This script generated 3 warnings - Scroll to the first warning

simpleblog

--------------------------------------------------------------------------------
(mssql): CREATE TABLE mdl_simpleblog ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0', intro text NOT NULL, name varchar(255) NOT NULL default '', menuvisible int(2) NOT NULL default '0', commentforum int(10) NOT NULL default '0', bloglevel int(2) NOT NULL default '1', teacher1 char(3) NOT NULL default '0', teacher1edit char(1) NOT NULL default 'y', teacher1others char(1) NOT NULL default 'y', teacher2 char(3) NOT NULL default '0', teacher2edit char(1) NOT NULL default 'y', teacher2others char(1) NOT NULL default 'y', student1 char(3) NOT NULL default '0', student1edit char(1) NOT NULL default 'y', student2 char(3) NOT NULL default '0', student2edit char(1) NOT NULL default 'y', PRIMARY KEY (id), KEY course (course)) TYPE=MyISAM COMMENT='Defines simpleblog'  
--------------------------------------------------------------------------------
170: Line 1: Incorrect syntax near 'unsigned'.

       ADOConnection._Execute(CREATE TABLE mdl_simpleblog ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0', intr..., false) % line 891, file: adodb.inc.php     ADOConnection.Execute(CREATE TABLE mdl_simpleblog ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0', intr...) % line 89, file: dmllib.php   execute_sql(CREATE TABLE mdl_simpleblog ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0', intr...) % line 235, file: dmllib.php modify_database(/var/www/html/moodle/mod/simpleblog/db/mssql.sql) % line 389, file: adminlib.php upgrade_activity_modules(https://imaze.hillsgrammar.nsw.edu.au:9003/moodle/admin/index.php) % line 422, file: index.php
ErrorScroll to next warning

--------------------------------------------------------------------------------
(mssql): CREATE TABLE mdl_simpleblog_archives ( id int(10) NOT NULL auto_increment, cmid int(10) NOT NULL default '0', userid int(10) NOT NULL default '0', searchString varchar(6) NOT NULL default '', archiveDate varchar(50) NOT NULL default '', PRIMARY KEY (id)) TYPE=MyISAM COMMENT='Holds simpleblog archives'  
--------------------------------------------------------------------------------
170: Line 1: Incorrect syntax near 'auto_increment'.

       ADOConnection._Execute(CREATE TABLE mdl_simpleblog_archives ( id int(10) NOT NULL auto_increment, cmid int(10) NOT NULL default '0', userid int(10) ..., false) % line 891, file: adodb.inc.php     ADOConnection.Execute(CREATE TABLE mdl_simpleblog_archives ( id int(10) NOT NULL auto_increment, cmid int(10) NOT NULL default '0', userid int(10) ...) % line 89, file: dmllib.php   execute_sql(CREATE TABLE mdl_simpleblog_archives ( id int(10) NOT NULL auto_increment, cmid int(10) NOT NULL default '0', userid int(10) ...) % line 235, file: dmllib.php modify_database(/var/www/html/moodle/mod/simpleblog/db/mssql.sql) % line 389, file: adminlib.php upgrade_activity_modules(https://imaze.hillsgrammar.nsw.edu.au:9003/moodle/admin/index.php) % line 422, file: index.php
Scroll to previous warningErrorScroll to next warning

--------------------------------------------------------------------------------
(mssql): CREATE TABLE mdl_simpleblog_entries ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0', cmid int(10) NOT NULL default '0', userid int(10) unsigned NOT NULL default '0', title varchar(255) NOT NULL default '', entry text NOT NULL, date varchar(50) NOT NULL default '', searchString varchar(6) NOT NULL default '', discussionPost int(10) NOT NULL default '0', timemodified bigint(10) NOT NULL default '0', usermodified bigint(10) NOT NULL, note text NOT NULL, notemodified bigint(10) NOT NULL default '0', noteid bigint(10) NOT NULL, imported varchar(1) NOT NULL default 'n', PRIMARY KEY (id), KEY course (course)) TYPE=MyISAM COMMENT='Holds simpleblog entries'  
--------------------------------------------------------------------------------
170: Line 1: Incorrect syntax near 'unsigned'.

       ADOConnection._Execute(CREATE TABLE mdl_simpleblog_entries ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0..., false) % line 891, file: adodb.inc.php     ADOConnection.Execute(CREATE TABLE mdl_simpleblog_entries ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0...) % line 89, file: dmllib.php   execute_sql(CREATE TABLE mdl_simpleblog_entries ( id int(10) unsigned NOT NULL auto_increment, course int(10) unsigned NOT NULL default '0...) % line 235, file: dmllib.php modify_database(/var/www/html/moodle/mod/simpleblog/db/mssql.sql) % line 389, file: adminlib.php upgrade_activity_modules(https://imaze.hillsgrammar.nsw.edu.au:9003/moodle/admin/index.php) % line 422, file: index.php
Scroll to previous warningErrorScroll to continue button

In reply to Stephen Liseo

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Andrew Atkinson -
Looks like you need the attached simpleblog/db/mssql.sql file and the attached patch to simpleblog/post.php to get things working in MSSQL.

Cheers,
Andrew



In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Julian Ridden -
Hi Matt,

I am having an issue with the Students only blog type.

Teachers cannot see the students blogs as it is creating a teacher blog as well (see screenshot) which it shouldn't be. In the attached image I am logged in as a teacher of the course but dont get to see the student blog list like I should.

Before you ask, yes I have assigned the Teacher and student blog roles in the setup but this has made no difference.

The other blog types all work as they should.

Any ideas?
Attachment screenshot.gif
In reply to Julian Ridden

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
I checked the files on my server and the ones that are in the zip, and they are the right ones. I noticed in your breadcrumb that it says "Online Journal" instead of "Course Blogs". Did you do some customization to the files? I can't seem to track this one down....
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Nigel Robertson -
Hi Matt

I am having the same problem as Julian although it seems more extensive тъжен Whatever role I am logged in as (admin, teacher, student) I am unable to add entries. With a couple of combinations of blog type and user type I may get an 'Add blog post" link but get thrown to the "You are not allowed to add ..." warning. Running 1.9 on postgres.

Nigel
In reply to Nigel Robertson

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Chris Thompson -

Nigel,

We had the same problem. I have attached the blogpost.php file. I think we only modified the blogpost file, but could send the post.php if this does not work. We found we had to give a field value to all fields in the post command and then it worked. The code is below, the files are attached. We are running 1.9, but do not have Matt's most recent (5/28) update (ours was in place on 5/1).

/// Set variables for blog post and create entry

$timenow = time();

$entryDate=date("F j, Y (g:i a)");

$searchString=date("Ym");

$archiveDate=date("F Y");

if ($entry) {

$newentry->course = $course->id;

$newentry->cmid = $cm->id;

$newentry->userid = $USER->id;

$newentry->title = $form->title;

$newentry->entry = $form->entry;

$newentry->date = $entryDate;

$newentry->searchString = $searchString;

$newentry->discussionPost = $discussions->id;

//We added the following

$newentry->timemodified = 0;

$newentry->usermodified = $USER->id;

$newentry->note = '';

$newentry->notemodified = 0;

$newentry->noteid = 0;

$newentry->imported = 0;

//print_r($newentry);

//exit;

if (! $newentry->cmid = insert_record("simpleblog_entries", $newentry)) {

error("Could not insert a new blog entry!!");

}

In reply to Chris Thompson

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Nigel Robertson -
Hi Chris

Thanks for the file but still no change тъжен

Reading through post.php it appears that for blog types 3 & 4, my set-up is failing to recognise the role of the logged in user. For blog types 1 & 2, I just don't get any option to add a blog entry at all so not sure where that is failing. I'll try your post.php if it has also been changed but think this may be something more fundamental.

Nigel


In reply to Nigel Robertson

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Nigel and Chris - the problem you are describing was a bug in course blog, but it was repaired with the last update. Have you both fully updated to the latest version? I just checked my installs of Course blog, and this problem is not occurring there.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Nigel Robertson -
Hi Matt

The only version that I have is v0.7.3 that is attached to the initial post in this thread. I've just pulled a clean version of 1.91 into my development environment (was on 1.9), reinstalled course blog and have exactly the same problems. With teacher only and community blogs, there are no 'add entry' links. With teacher and student individ blogs, and also student only blogs, instances of blogs for participants on the course are created with "add entry' links. However, clicking on a link brings the message that 'You are not allowed to add entries'

Nigel
In reply to Nigel Robertson

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Also check to make sure that you did set teacher and student roles and didn't leave those as just "(blank)" - some people here found that was causing some problems. Also, there is something wrong with the way course blog interacts with Moodle. Even if you choose a level, those settings may not stick on initial set-up. You may need to edit the blog and re-submit them to get them in there. I don't know if that is a bug with Moodle or something I need to fix on the course blog in - I am still checking in to that.

I also noticed that you are running yours on postgresql. If there is a problem there somewhere, I may not be able to find out what it is - I am on MySQL.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Nigel Robertson -
Hi Matt

Had to leave this for a couple of days. Still no joy though. Have tried Chris's blogpost.php as well (but don't have a changed post.php).

Had a close look at the error messages. Problem seems to be that courseblog is not recognising the roles; so whatever role I have, c/b thinks it doesn't have permission to either see the 'post new entry' link, or to post if it appears. Have tried all sorts of roles and combinations!

Cheers
Nigel
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Charlie Owen -
We've just upgraded to Moodle 1.9 and have found that a few instances of the Course Blog are now broken. Those that are broke seem to be set as "Individual students and teachers with their own blogs" or "Individual student blogs that only teachers can read" (sorry if that's not the right wording - I changed my language file and can't remember the original descriptions!). Community blogs seem to be working just fine.

I've attached a screenshot of a broken blog. I'll have a look through the code later on and see if I can see anything obvious that is causing it to break.


Attachment brokenblog.jpg
In reply to Charlie Owen

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Just to ask the obvious question to make sure - did you also upgrade to this latest version of course blog when you upgraded to 1.9?
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Charlie Owen -
Yup, we're using the latest code posted in this thread (version.php says it's version 2007122100).
In reply to Charlie Owen

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Well - just had to check. Let me know what you find when you check the code - I'm not running in to this problem on my installation of course blog.

Are you by any chance using custom student and teacher roles (other than the ones that are standard with Moodle install)? Theoretically, course blog should still work with those - but I haven't had a chance to test it to make sure.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Charlie Owen -
Actually, just found the reason for this and it is related to roles. Looks like these broken course blogs didn't have any roles set for teachers and students and were therefore breaking!

Are the blogs meant to work if these roles aren't set? If they do need to be set then there needs to be a warning in the form.

Anyway, once again many thanks for creating this module - it really is fantastic.
Attachment courseblog_roles.gif
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от John Watson -
HI Matt,

Will this version of simpleblog also work with Moodle 1.7?

Regards,
John


In reply to John Watson

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Its possible since roles were introduced in 1.7, but I have no way to test it for sure.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от John Watson -
Hi Matt,

I installed it on our 1.7.1+ version and I can setup a course blog. However I am running into the same issue as others, there is no 'add post' link. The roles are set ok (I think) and I've tried the blogpost.php and post.php workaround to no avail.

Any help is much appreciated.

Regards,
John
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
I think I have found the source of the problem with some of the Course blogs. It seems that the blog level does not get inserted in to the database correctly. This happens in a files outside of course blog, so I am not sure if I can get it to work correctly or not. The quick fix around is edit your course blog and set the level correctly. For some reason, it always defaults to a teacher only blog, even if you choose another one.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от John Watson -
Hi Matt,

I think you may be on to something. When I manually change the bloglevel to 4 in the MySql table I get the exact same behavior the Nigel describes in his
Friday the 13th of June 2008, 12:44 PM post.

That is, I do get the blog option block, but when I select 'Add a blog entry', the
'you are not allowed to add blog entries to this blog' message appears.

Regards,
John
In reply to John Watson

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
John - are you logged in as a student or a teacher when you get that message? Level 4 is student only, so if a teacher tries to post to something, they would get that message. I need to clean up the design some so that even teachers won't see that option.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от John Watson -
The blog is working now! Apparently I needed to add myself as an actual teacher for it to work properly. Logging in as an Admin and then changing my role to teacher wasn't working.

Regards,
John
In reply to John Watson

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Glad to know it is working - and now another warning to add to the admin page, or find a work around for усмивка I never thought to test that one out. I think I am going to add something in to the code that tells people why they can't post (i.e. "you are logged in as a _____ and only _____ can post.")
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Patrick Daisley -
Matt,
Thank you for this module. I am using it on my high school class page so that students can reflect, journal, and communicate with me privately. As such I have it set to "Students Only" so that only they and I can see their entries. This seems to work fine except for thing: one of my brighter students discovered that if he changed the "bloguser" number in the browsers address bar that he could access and read another students private blog. Yikes! To illustrate, suppose the address bar contained:

"http://www.mydomain.com/moodle/mod/simpleblog/viewStudent.php?id=21&bloguser=45".

If you changed the "bloguser-45" in the to "bloguser=46", keeping everything else the same, you could view the other students blog.

This is a real problem. I am uncomfortable telling students that no one can read their posts when in fact they can.

Is there a fix for this?


In reply to Patrick Daisley

Svar: Re: Course Blog v0.7.3 for Moodle 1.9

от Tobias Wallenqvist -
This should be easy to solve just by adding a PHP code that checks if the ID in the URL is the same as the ID in the session stored at the end user.

<%php
$url_id = $_GET['id'];
$session_id = $_SESSION['user?']['id'];

if($url_id = $session_id)
{
//grant access and view blog entry's.
}
else
{
echo "you don't have the permissions to view this blog";
}
%>
In reply to Tobias Wallenqvist

Re: Svar: Re: Course Blog v0.7.3 for Moodle 1.9

от Patrick Daisley -
Thank you. I'm not very experienced with PHP. Can you tell me where, which file, I should add this code? Anything else I should know?
In reply to Patrick Daisley

Re: Svar: Re: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
If you apply this code, the instructor will not be able to see the blog posts of the students. I will take a look at the code and see why this is happening - I had originally tested it to make sure that the students couldn't do that, since it is the oldest hack in the book.

The student only page was designed to let anyone that is designated as a teacher in the settings see blog posts, so the first thing I need to ask is if this student that is seeing other posts is maybe a designated TA or something else that is set up as a teacher in the settings. If so, then they will be able to see posts by design. If not, then there is a bug in there somewhere. The code is already present to stop this from happening, so the bug would be in there somewhere.
In reply to Patrick Daisley

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
Okay - the problem here is that students don't have access to links like this:

../mod/simpleblog/viewStudent.php?id=21&bloguser=45

Only teachers should. In my install, when a student logs in and then clicks on a blog that is set up as a "students only" level, they get a link that looks like this:

../mod/simpleblog/view.php?id=21

And they only see their blog. If I then change the link to the first one above, I just get a blank screen. I'll probably need to know the settings for your blog set-up and to be able to look in to this one further.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Patrick Daisley -
My students seem able to have that access. I'm not sure what setting you mean but here is a screen shot of the settings I know about:''

Is there something else I should set?
settings
In reply to Patrick Daisley

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
There aren't even any links to viewStudent.php in the student's only level. How are students even getting access to that link in the first place?
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Patrick Daisley -
I may have found the problem/solution. Under the student roles there is a drop down menu set to "blank" as default (see screen shot I added earlier). The associated "Edit Own" permission is set to "yes" by default. I assumed that this wasn't being applied since the role was "blank". When I changed the permission to "no" the students were no longer able to view the other students blogs by changing the bloguser ID because that part of the address no longer showed in the address field (its appeared as was earlier described).
In reply to Patrick Daisley

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
That is interesting to know - glad you found a way to get it to work. I have the exact same settings you have (2nd blank role edit own set to 'yes') on both of my installations, but students still can't get to the viewStudent.php. The only way to get to that link is through seeing a list of all students and then clicking on a student's name. I even tried manually changing the address to the viewStudent.php as a student and just got a blank page. In other words, there is just no direct link from the front page of a Moodle class to the viewStudent.php - you have to click on other pages to get there - something that isn't allowed in the "students only" level. You might want to update your php files with new ones, because it sounds like you may have some corrupted ones in your in stallation.
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Mike Forshaw -

Hi,

Just insalled your blog and it looks good. However I've got a few problems:

1. I want to use it for community access but when I create the blog or edit the settings, it doesn't appear to save any changes. I want to change the 'Blog teacher roles' to Teacher, so the teacher of the coure can add posts other than myself as administrator.

2. The 'Last edited' date always defaults to 1 January 1970!

I could delete all the database tables of the course blog and do a fresh install but I am worried I would lose any blog posts I have from an old Simpleblog install.

I am running v 1.9.1+ of Moodle.

Thanks,
Mike

Attachment blog_dates.jpg
In reply to Mike Forshaw

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
As far as the first one, there seems to be a problem outside of Course Blog that interferes with setting variables. On my installation, if I go back in and edit the settings after I have created them, they will usually stick. I wish I could find the source of this bug, but it seems to be in other code in Moodle.

For the second one - I just checked my installation and the dates are working (see below). Has anyone else run in to this? I'm sure what to do unless I get more information.
Attachment screenshot.jpg
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Patrick Fitchie -

Has anyone found a solution to the add post problems.  I receive the links to add blog post but fails when you try to save the post.  Also when using Teacher and Students blogs all users are listed under Teachers and there are no students in the blog list.  This is very frustrating as 0.7.3 works great on my development box but no on my production server.

In reply to Patrick Fitchie

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Matt Crosslin -
What is the difference between your production server and your development box?

For the add post problems, these are the solutions that I discovered worked on mine:

"Also check to make sure that you did set teacher and student roles and didn't leave those as just "(blank)" - some people here found that was causing some problems. Also, there is something wrong with the way course blog interacts with Moodle. Even if you choose a level, those settings may not stick on initial set-up. You may need to edit the blog and re-submit them to get them in there. I don't know if that is a bug with Moodle or something I need to fix on the course blog in - I am still checking in to that."
In reply to Matt Crosslin

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Patrick Fitchie -

Both sites run 1.9.3+ lastest weekly, 

mySQL

  • Production=5.0.45
  • development=5.0.51

php

  • production=5.2.0
  • development=5.2.5

However the the production server runs on W2K3 IIS and the development runs on a XAMP stack under WinXP.

I have ensured the roles are not blank and have edited the course blog settings many times to stick the level settings.

Here is the Blog record from the DB

1, 152, '', 'Test Blog', 10, 197, 3, '3', 'y', 'y', '0', 'y', 'y', '5', 'y', '0', 'y'

In reply to Patrick Fitchie

Re: Blogs: Course Blog v0.7.3 for Moodle 1.9

от Patrick Fitchie -

Hi Matt,

  I have discovered the problem.  For some reason on my mysql install when the tables get created, some of the fields are supposed to have a null default value.  In my case they did not.  I corrected these fields and I also discovered problems in other tables not related to simpleblog that resolved a lot of issues I have been having with moodle in general.

  Also in regards to some folks having issues with "role" detection for "Student only blogs" where the teacher is detected as a student I found in my instance the Teacher was assigned both the teacher and student role for the course context.  You may want to look into having your module detect the highest role a user has for the course context instead of just the first one found in the database.

Patrick