Forum .LRN Q&A: Strange Code in LORS

Collapse
Posted by Nima Mazloumi on
I installed openacs/.lrn from oacs-5-3 branch and installed lors. after uploading a new course I went to the admin page and followed the link to "admin".

I get the following error:

Error in include template "/srv/www/openacs-4/packages/lors/lib/course-structure": char map list unbalanced

Looking at the tcl file there error appears here:

set type [string map $pretty_types_map $type]

This is how the two variables are set:

set pretty_types_map {}
if { [apm_package_installed_p assessment] } {
append pretty_types_map "as_sections Questions"
}
if { [apm_package_installed_p xowiki] } {
append pretty_types_map "::xowiki::Page Content"
}

Why is that?

Collapse
2: Re: Strange Code in LORS (response to 1)
Posted by Gustaf Neumann on
string map accepts as first argument a list. The correct code is to use set pretty_types_map [list] and lappend instead of append.
Collapse
3: Re: Strange Code in LORS (response to 1)
Posted by Nima Mazloumi on
Who is using lors with xowiki and assessment and how?
Collapse
4: Re: Strange Code in LORS (response to 3)
Posted by Emmanuelle Raffenne on
Hi Nima,

We (Adenu group at Uned) use assessment with LORSM. We use it to add tests to an existing IMS course. Or, What do you mean by "how"?

Collapse
5: Re: Strange Code in LORS (response to 1)
Posted by Nima Mazloumi on
With "how" I mean let's assume assessment and xowiki is installed where/how can I use it inside lors?
Collapse
6: Re: Strange Code in LORS (response to 1)
Posted by Dave Bauer on
Nima,

This code is mostly experimental. Basically if its installed it will allow you to create a couse by hand and add objects from assessment of xowiki into the course.

I can't imagine why that code uses append instead of lappend :) lappend is definitely correct. Each element, as_sections, Questions needs to be a seperate list element too.

Collapse
7: Re: Strange Code in LORS (response to 1)
Posted by Matthew Coupe on
WE have encountered some issues with LORS whereby a user will login to dotLRN, access a set of learning materials, then when they try to access another set of materials they are unable to and can only see the materials they accessed in the first instance. It is very strange behaviour indeed.

I'd also like to know how to use assessments in LORS. I evaluated the package recently and found it to have a few bugs and lacked a question bank functionality which would be a great improvement. Has anyone created this functionality and fixed some of the bugs?

Cheers
Matthew

Collapse
8: Re: Strange Code in LORS (response to 6)
Posted by Gustaf Neumann on
just to be on the safe side, avoid a stupid thread ala "lappend does not work either". string map uses a flat list for the map. The complete code is:
set pretty_types_map [list]
if { [apm_package_installed_p assessment] } {
  lappend pretty_types_map as_sections Questions
}
if { [apm_package_installed_p xowiki] } {
  lappend pretty_types_map ::xowiki::Page Content
}
In case people ask: why [list] instead of {}?

In byte-code compiled cases, [list] is directly compiled into a Tcl_Obj of type list. If {} is used instead if [list], the Tcl_Obj will be of type string and will be converted into a list by the first lappend operation. In the concrete example, the difference is not important, aside from a documentation point of view. In Tcl it is regarded as a good practice to use [list] where appropriate.

Btw, the code above is not very general, since xowiki supports different types of acs-objects, which are not handled by the snippet above. To label these object_types with "Content", one can query the available object_types by :xowiki::Page object_types and provide for these an entry in the map.

if { [apm_package_installed_p xowiki] } {
  foreach object_type [:xowiki::Page object_types] {
     lappend pretty_types_map $object_type Content
  }
}

The code is untested, i have never used LORS.

Collapse
Posted by Nima Mazloumi on
Several places with bad code I found:
---------------------------------------------
lorsm/www/admin/tracking-rte/index.tcl
---------------------------------------------
set man_id [ ad_get_client_property trackingrte man_id ]
set man_name [lorsm::get_course_name -manifest_id $man_id]

This breaks as soon as the server is restarted. Any idea?

---------------------------------------------
lorsm/www/delivery/view/index.vuh
---------------------------------------------
ad_return_complaint 1 "[_ lorsm.Your_session_has_expired]"

The message key is missing and also this displays the message inside the master template and thus we suddenly can browse openacs/dotlrn on the left frame while still inside a course.

Collapse
Posted by Silvia Margarita Baldiris Navarro on
Thanks Gustaf, my lors works very good now!