Student view of Assignment shows invalid comment item ID

Student view of Assignment shows invalid comment item ID

by Amir Mustafa -
Number of replies: 12

Hello Moodlers,

I am getting some strange error. When I am logged in as admin/teacher assignment opens perfectly. When I open in student view it throws invalid comment item ID message.

Admin View


Student View



Can someone please suggest me how to proceed.

Average of ratings: -
In reply to Amir Mustafa

Re: Student view of Assignment shows invalid comment item ID

by Ken Task -
Picture of Particularly helpful Moodlers

Did you recently set the moodle up with a valid cert ... https://?

Did you run search and replace ... admin tool?   Might also be a good idea to purge caches.

The lock icon in a regular desktop browser says site running https:// but some graphics/other content on the page is http://

'SoS', Ken

In reply to Ken Task

Re: Student view of Assignment shows invalid comment item ID

by Amir Mustafa -
Hello Ken,
No at present my server is without https.

Did you run search and replace ... admin tool? - no
I had to do some extra functionality on assignment plugin. So I duplicated the plugin and renamed with the plugin name i.e. fastassignment.

When creating the assignment I had to append data from api to description of Atto editor of assignment setting. I hit save and in student view I get this error. Otherwise it comes ok and once this error comes no matter what I do. it remains for other assignment activity create. This is really strage issue sir. Can you suggest me how to proceed.

In reply to Amir Mustafa

Re: Student view of Assignment shows invalid comment item ID

by Ken Task -
Picture of Particularly helpful Moodlers

So you've tried to clone the assignment plugin to a new assignment plugin called 'fastassignment'.   I take it your server recognized the new plugin and it installed correctly (new tables/code/etc.) with no errors?

Really, this discussion should be moved to the developlers forum as that is what you are doing.

https://moodle.org/mod/forum/view.php?id=55

However, 2 cents before you go .... really should get site under https and the messed up theme for students is typically due to caches ... manually purge those ... contents of moodledata/cache/ and contents of moodledata/localcache/ safe to do as moodle will rebuild as needed.

'SoS', Ken

In reply to Ken Task

Re: Student view of Assignment shows invalid comment item ID

by Amir Mustafa -
Hello Ken,

Yes, when I installed this plugin it installed successfully without errors. No errors were coming related with table or old assignment. Yes I am purging all cache. I need to clear data from moodledata/localcache/ and check.

Hope this issue gets resolved. Sorry for seeing this thread late.
In reply to Amir Mustafa

Re: Student view of Assignment shows invalid comment item ID

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Amir,

When you, "duplicated the plugin and renamed with the plugin name i.e. fastassignment," did you duplicate the assign plugin or the older assignment plugin? For example, if assign is the one you used, did you  search and replace, assign with fastassignment in every file in you new version of the plugin. You HAVE to do that because there are multiple places in the files where it will set up a link to run another file from the plugin. If you have NOT completed the search and replace for assign to fastassignment, then the links in your new version of the plugin, will link to files in the original version of the plugin. Once you go back into one of the old files, there is nothing in them that will get you back to your new code.

In reply to AL Rachels

Re: Student view of Assignment shows invalid comment item ID

by Amir Mustafa -
Hello AL,

I duplicated the assign directory (plugin) and renamed every every possible instance from assign to fastassignment, renamed some of the string files name from assign to the new name. It installed successfully. Earlier at some places it showed errors like in event or some page. So I renamed those specific to assign instead of fast assignment and it installed successfully without errors.

When I open the assignment from admin and click Grades- it is broken shows Unexpected son file
and from student view when I open I shows Invalid context.

Please suggest me how to proceed.
In reply to Amir Mustafa

Re: Student view of Assignment shows invalid comment item ID

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hi Amir,
Then I suspect your problem is caused by those places where, "So I renamed those specific to assign instead of fast assignment and it installed successfully without errors." You cannot do that! You cannot use fastassginment in some places, and then assign, in other places, because I bet that is what is causing you to start in your plugins pages, but then winding up stuck in a regular assignment page. You have to go back and fix the errors you experienced.

I have done the same type of cloning a plugin in the past with Forum and Journal and fixing the errors was what I HAD to do. Many of them were simply due to trying to have functions with the same name as the original plugin. In those cases, I just added an abbreviation of my new module to those functions.

I am not saying this will guarantee fixing all the errors, but it may help with some.
In reply to AL Rachels

Re: Student view of Assignment shows invalid comment item ID

by Amir Mustafa -
Hi AL,

Yes, you are right. I will try cloning the plugin from the beginning. It did not successfully clone, hence some of its functionality has broken. These real times errors do not go in regular cloning.

Steps I followed for cloning:
a. In the code - replaced assign with fastassignment
b. In the code files - replaced wherever assign key with fastassignment
c. Purging Cache. from moodledata deleting contents inside localcache and cache
d. Installing the plugin

Did I miss any important step? Please suggest to me.
In reply to Amir Mustafa

Re: Student view of Assignment shows invalid comment item ID

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Amir,

Sorry to be so slow to respond. Currently I am only able to work on Moodle stuff for a couple of hours each morning. Other projects keep me out of the house and very busy the rest of the day.

From your previous description of starting out in your new fastassign, then winding up back in a web page of the regular assignment plugin, I think the one step you may have missed, is to go through the code files, looking for links to other files that belong in the plugin.

For instance, when you go to an assignment, you generally start in the view.php file. Open that file from your fastassignment plugin in an editor such as Notepad++, and do a Find > Count search for ".php" (without the quotes). In view.php you should get a count of three. The first one in line 25, doesn't matter. The second you have to verify that, /mod/assign/locallib.php, has been changed to /mod/fastassign/locallib.php. Then down in line 44, /mod/assign/view.php has been changed to, /mod/fastassign/view.php. Then go repeat for every file in every folder of your plugin. When doing these searches, make sure that Match Case is OFF, and Wrap around is ON. Otherwise it is easy for a search and replace operation to miss some of the things you are looking for.

You need to go through every file and verify because  it is so easy to accidentally miss one occurrence, that breaks everything.

Another thing to check is in lib.php and locallib.php. Many times due to the way Moodle works, it will not let you use a function name that is the same in both assign and fastassign. Every assign function in local.php has assign in the name, so those all have to be checked and assign changed to fastassign. The functions in locallib.php are likely culprits for causing problems, as they do not currently have assign as part of their names and a search and replace would not do anything to them. So, try to run the parts of your new fastassign, to see if they are what caused your previous errors.

When trying to run your new version of the plugin, set debugging to developer, and try every part of the new plugin. If you get any problems, they HAVE to be fixed. Post the debug info, if you still have problems.


In reply to Amir Mustafa

Re: Student view of Assignment shows invalid comment item ID

by Deepak Bhalla -

Hi ! Amir Mustafa,

I understand that you have 2 assignment plugins and both of these are working fine when you view things as a teacher/admin, but you get an error when you try to view as a student.

I am not an expert however I would recommend that you review the grades view permission as course level and assignment level, are grades open to students? Even if that doesn't work, go to student role and verify permissions.

I hope  this will resolve the issue.

Cheers !

Deepak Bhalla

In reply to Deepak Bhalla

Re: Student view of Assignment shows invalid comment item ID

by Amir Mustafa -
Hello Deepak,

Okay, I will give permissions as you said.
In reply to Amir Mustafa

Re: Student view of Assignment shows invalid comment item ID

by Amir Mustafa -
Can any you duplicate assign plugin for me, so that it run default functionalities without error.

Thank you for suggesting me.