WeBWorK Main Forum

Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Wai Yan Pong -
Number of replies: 12

Students start complaining that they can't see their grades. And send a screenshot with the following message:

Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet" at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Grades.pm line 314.

Any idea of why this happen? Do we need to upgrade a perl module, or something?

Any help is greatly appreciated.

In reply to Wai Yan Pong

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Glenn Rice -

I found a way to reproduce this, but it takes some fiddling with changing a set back and forth between a gateway and homework set type.  I tested this with WeBWorK 2.17 and you are using WeBWorK 2.16 (based on the line number in the message), but the general logic in the code hasn't changed much here.

Basically, the problem is that the code never actually checks to see if a given set is a gateway quiz when determining if the display of scores is allowed for the set.  It only checks if the hide_score flag is set for the set.  Usually this is only set for gateway quizzes, so it is usually enough.  However, if you create a set and change its type to a "gateway/quiz", and then set "Show Scores on Finished Assignments?" to No and save, and then change the set type back to "homework" and save, then the hide_score flag will still be set in the database, and if a student has been assigned the set and tries to open grades the error you show occurs.

To fix this find the offending homework set and open it in the homework sets editor, and save settings one more time.  That is enough to reset the hide_score flag back to NULL, and will fix the problem.

If you have access to the database, then execute "select set_id from course_id_set where hide_score='Y' and assignment_type='default';" to list all homework sets that have hide_score incorrectly set.  Of course change "course_id" to the actual course id. Then for all of those sets listed open them in the homework sets editor and click save to fix them.

In reply to Glenn Rice

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Wai Yan Pong -

Hi Glenn, thanks so much for the detail explanation.

And yes, I did change the score availability setting for a quiz. But I did change it back. Maybe I have done something but I forget. 

I looked at the database, none of the hide_score is set to 'Y'. 

select hide_score from course_id_set; (and yes, I did replace course_id with the actual one) shows 3 types of entries for the sets:

"NULL", "N" and "BeforeAnswerDate"

The problem is still there. Any suggestion on what else I can try? The lucky part is that it is not affecting other courses. 

In reply to Wai Yan Pong

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Glenn Rice -

Try this instead in the database:

SELECT set_id FROM course_id_set WHERE (hide_score='Y' or hide_score='BeforeAnswerDate') and assignment_type NOT LIKE '%gateway%';

Somehow you must have a non gateway set that has hide_score set to one of the above values.  That is the only way the line of code you showed could possibly be executed.  You say that you have some sets with the value 'BeforeAnswerDate'.  That is most likely the problem then.

In reply to Glenn Rice

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Wai Yan Pong -

Glenn, indeed. The command in your reply returns 8 rows. After I revert the only one that I back to a gateway, the list is down to 7.

But now what should I do fix the rest?

I suppose I should set the hide_score field of those sets to 'NULL'. If that's right, could you tell me how, if I just have their set_id.

Many thanks. 

In reply to Wai Yan Pong

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Glenn Rice -

You should be able to open the sets in the homework sets editor, and just click "Save".  That should set the hide_score field back to NULL.

If you want to you can do this directly in the database with

UPDATE course_id_set set hide_score = NULL where set_id='set id found from other command';

Be careful with direct modification to the database though, if you are not certain of what you are doing.

In reply to Glenn Rice

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Wai Yan Pong -

Yes, using the homework sets editor is safer. But in case someone like me who forgets about which sets were changed and only have their set_id, how can one matches the set_ids with their corresponding  names?

To be on the safe way, I plan to unarchive the course on my local machine then play with the database. 

In reply to Wai Yan Pong

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Glenn Rice -
In webwork2 the set_id in the database is the set name that you see in the homework sets editor with underscores where spaces are shown.
In reply to Glenn Rice

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Wai Yan Pong -

Hum.. perhaps the database on our server was not set up in a standard way. When I issue 

SELECT set_id FROM course_id_set WHERE (hide_score='Y' or hide_score='BeforeAnswerDate') and assignment_type NOT LIKE '%gateway%';

I got a bunch of set_id's that looks like the one below"

0x5175697A5F35

That's why I don't know what are the corresponding sets in HW editor.


In reply to Wai Yan Pong

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Glenn Rice -

It sounds like your database may be corrupt.  Those don't look like valid set_id's.

In reply to Wai Yan Pong

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Danny Glin -

For some reason your query is returning set ids as hex values.  This could be something to do with your database configuration or the mysql client you are using.

If I remove the 0x at the front and enter the rest of the string into a hex to text converter (such as https://www.duplichecker.com/hex-to-text.php) it spits back Quiz_5.  This should at least allow you to determine the set names.

In reply to Danny Glin

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Glenn Rice -
Ahh, you must have the "binary-as-hex" setting enabled. Check your conf files in /etc/mysql.

You can pass the command line option "--skip-binary-as-hex" to output normal text. Use "mysql --skip-binary-as-hex webwork" (of course add username and such)
In reply to Glenn Rice

Re: Can't locate object method "version_id" via package "WeBWorK::DB::Record::UserSet"

by Wai Yan Pong -

Thanks to both Danny and Glenn! 

Yep, that's it "--skip-binary-as-hex" does the trick and it looks like "binary-as-hex" is the default.

Following Glenn advice: re-saving the those sets from HW sets editors solve the original problem. Now students can see their grades by clicking the grade button.