Oktech edit_forums and forum_add_discussion

Oktech edit_forums and forum_add_discussion

by Rimphy Darmanegara -
Number of replies: 7

Hi,

After creating a new course in moodle 2.2 next I tried to add a forum using oktech library edit_forums with type 'add'. This seems to work and the record is in the database, but when I see the course homepage there is no new forum there.

Then i tried to add discussion to that forum but i get exception:

string(141) "<?xml version="1.0" encoding="UTF-8" ?>
<EXCEPTION class="Exception">
<MESSAGE>Wspp Base Server :missingparameter</MESSAGE>
</EXCEPTION>
"

Anyone know why discussion creation failed?

I follow the chain and ended up in moodle-root/lib/datalib.php in function get_coursemodule_from_instance($modulename, $instance, $courseid=0, $sectionnum=false, $strictness=IGNORE_MISSING). I dont want to go any deeper into the core.

 

Another case is after creating a course, I click on the course link so that now im in the course's homepage where there is a default News Forum. In the mdl_forum table a new record was added and I use the 'id' of the new record to create new discussion(like above). And it worked.

 

Is there's something I missed between these two approaches?

 

Thank you;

Average of ratings: -
In reply to Rimphy Darmanegara

Re: Oktech edit_forums and forum_add_discussion

by Patrick Pollet -

Hello,

    OK Tech WS has never been created to replace the interactive mode for 'heavy administrative tasks' such as creating a forum and inserting it into a course 

     If you really want to create and immediatly use a new forum,  you MUST call the following operations :

1) edit_forum like you did with option='add' or more simply via add_forum  (that will add a new record to the DB) 

2) get the list of existing course sections by a call to get_sections 

/**
* Find and return a list of sections within one or several courses.
* OK PP tested with php5 5 and python clients
* @param int $client The client session ID.
* @param string $sesskey The client session key.
* @param string[] $courseids An array of input courses id values to search for. If empty return all sections
* @param string $idfield : the field used to identify courses
* @return sectionRecord[] An array of section records.
*/
public function get_sections($client, $sesskey, $courseids, $idfield = 'idnumber')

3) affect the forum to one of the sections of the target course  by a call to affect_forum_to_section($client, $sesskey, $forumid, $sectionid, $groupmode)

4) It should still works under Moodle 2.x ... 

i am glad to learn that the call forum_add_discussion still works on Moodle 2.2 on an existing forum such as the News Forum wink

Cheers

 

In reply to Patrick Pollet

Re: Oktech edit_forums and forum_add_discussion

by Rimphy Darmanegara -

Thanks Patrick, it work just like I wanted. big grin

But I have to make adjustment in my wspp/wslib.php I add:

require_once ($CFG->dirroot.'/course/lib.php'); on top of the file.

 

Prior to that the code:

if (!$course_module_id = add_course_module($course_module))

always return Internal Server Error(500)

In reply to Rimphy Darmanegara

Re: Oktech edit_forums and forum_add_discussion

by Patrick Pollet -

Great !!!!

Thanks for the report. I just pushed on github the revised wslib.php

Cheers.

In reply to Patrick Pollet

Re: Oktech edit_forums and forum_add_discussion

by Federico Ghigini -

Hi,
I followed the instructions above, but after the creation and affection of a new forum, this is not visible within the course.
If I manually create a new forum, then all the forums set up displays, including one created by WS!

I'm using moodle 2.2.2+ and the last version of Ok Tech WS

In reply to Federico Ghigini

Re: Oktech edit_forums and forum_add_discussion

by Patrick Pollet -

Hi 

 

As  I stated above

   OK Tech WS has never been created to replace the interactive mode for 'heavy administrative tasks' such as creating a forum and inserting it into a course 

 If you look at the script course/modedit.php you will see that adding an activity to a course is doing quite a lot of things and some are still not implemented in OK Tech (and never will be) such as initialisation of outcomes, gradings and completion support...

To fix your specific problem, I think that adding these  lines  near line 635 in wspp/wslib.php should do it. Moodle is using more and more caching these days ...

if ($CFG->wspp_using_moodle20)
rebuild_course_cache($section->course);

just before the ending :

 return "";

Let me know if this is enough wink

Cheers.

Average of ratings: Useful (1)
In reply to Patrick Pollet

Re: Oktech edit_forums and forum_add_discussion

by Federico Ghigini -

Thanks!
Now it works. The forum is displayed correctly after the fix.

In reply to Federico Ghigini

Re: Oktech edit_forums and forum_add_discussion

by Patrick Pollet -

Great

Fix committed on github

Thks for the report

Cheers

edit : if you have time, rate my answers as 'useful' ; it is good to my ego wink