Index: openacs-4/packages/ae-portlet/ae-portlet.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/ae-portlet.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/ae-portlet.info 9 Jun 2005 05:54:35 -0000 1.1 @@ -0,0 +1,26 @@ + + + + + Anon Eval Portlet + Anon Evals Portlets + f + t + + + Anny Flores + 2004-06-12 + + + + + + + + + + + + + + Index: openacs-4/packages/ae-portlet/catalog/ae-portlet.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/catalog/ae-portlet.en_US.ISO-8859-1.xml,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/catalog/ae-portlet.en_US.ISO-8859-1.xml 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,7 @@ + + + + Course Evaluation Admin + There should be only one instance of Anon Eval for admin purpose + Results + Index: openacs-4/packages/ae-portlet/tcl/ae-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/tcl/ae-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/tcl/ae-portlet-procs.tcl 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,352 @@ +ad_library { + + Procedures to support the ae portlets + + + @author Anny Flores (annyflores@viaro.net) + @author Viaro Networks (www.viaro.net) + +} + +namespace eval ae_portlet {} +namespace eval ae_admin_portlet {} + + +# +# ae namespace +# + +ad_proc -private ae_portlet::get_my_name { +} { + return "ae_portlet" +} + + + +ad_proc -private ae_portlet::my_package_key { +} { + return "ae-portlet" +} + +ad_proc -public ae_portlet::get_pretty_name { +} { + return "#anon-eval.Anon_Eval#" +} + + + +ad_proc -public ae_portlet::link { +} { + return "" +} + + + +ad_proc -public ae_portlet::add_self_to_page { + {-portal_id:required} + {-package_id:required} + {-param_action:required} + {-force_region ""} + {-page_name "" } +} { + Adds a ae PE to the given portal. + + @param portal_id The page to add self to + @param package_id The community with the folder + + @return element_id The new element's id +} { + return [portal::add_element_parameters \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -value $package_id \ + -force_region $force_region \ + -page_name $page_name \ + -pretty_name [get_pretty_name] \ + -param_action $param_action + ] +} + + + +ad_proc -public ae_portlet::remove_self_from_page { + {-portal_id:required} + {-package_id:required} +} { + Removes a ae PE from the given page or the package_id of the + ae package from the portlet if there are others remaining + + @param portal_id The page to remove self from + @param package_id +} { + portal::remove_element_parameters \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -value $package_id +} + + + +ad_proc -public ae_portlet::show { + cf +} { + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "ae-portlet" +} + +# +# ae admin namespace +# + +ad_proc -private ae_admin_portlet::get_my_name {} { + return "ae_admin_portlet" +} + + +ad_proc -public ae_admin_portlet::get_pretty_name {} { + return "#anon-eval.Anon_Eval_Administration#" +} + + + +ad_proc -private ae_admin_portlet::my_package_key {} { + return "ae-portlet" +} + + + +ad_proc -public ae_admin_portlet::link {} { + return "" +} + + + +ad_proc -public ae_admin_portlet::add_self_to_page { + {-portal_id:required} + {-page_name ""} + {-package_id:required} +} { + Adds a ae admin PE to the given portal + + @param portal_id The page to add self to + @param package_id The package_id of the ae package + + @return element_id The new element's id +} { + return [portal::add_element_parameters \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -key package_id \ + -value $package_id + ] +} + +ad_proc -public ae_admin_portlet::remove_self_from_page { + {-portal_id:required} +} { + Removes a ae admin PE from the given page +} { + portal::remove_element \ + -portal_id $portal_id \ + -portlet_name [get_my_name] +} + + +ad_proc -public ae_admin_portlet::show { + cf +} { + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "ae-admin-portlet" +} + +ad_proc -private ae_portlet::after_install {} { + Create the datasources needed by the ae portlet. +} { + + db_transaction { + set ds_id [portal::datasource::new \ + -name "ae_portlet" \ + -description "Anon Eval Portlet"] + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key shadeable_p \ + -value t + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key hideable_p \ + -value t + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key user_editable_p \ + -value f + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key shaded_p \ + -value f + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key link_hideable_p \ + -value f + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p f \ + -key package_id \ + -value "" + + register_portal_datasource_impl + + } +} + +ad_proc -private ae_portlet::register_portal_datasource_impl {} { + Create the service contracts needed by the ae portlet. +} { + set spec { + name "ae_portlet" + contract_name "portal_datasource" + owner "ae-portlet" + aliases { + GetMyName ae_portlet::get_my_name + GetPrettyName ae_portlet::get_pretty_name + Link ae_portlet::link + AddSelfToPage ae_portlet::add_self_to_page + Show ae_portlet::show + Edit ae_portlet::edit + RemoveSelfFromPage ae_portlet::remove_self_from_page + } + } + + acs_sc::impl::new_from_spec -spec $spec +} + +ad_proc -private ae_admin_portlet::after_install {} { + Create the datasources needed by the ae portlet. +} { + + db_transaction { + set ds_id [portal::datasource::new \ + -name "ae_admin_portlet" \ + -description "Ae Admin Portlet"] + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key shadeable_p \ + -value f + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key hideable_p \ + -value f + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key user_editable_p \ + -value f + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key shaded_p \ + -value f + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p t \ + -key link_hideable_p \ + -value t + + portal::datasource::set_def_param \ + -datasource_id $ds_id \ + -config_required_p t \ + -configured_p f \ + -key package_id \ + -value "" + + register_portal_datasource_impl + } + +} + + + +ad_proc -private ae_admin_portlet::register_portal_datasource_impl {} { + Create the service contracts needed by the ae admin portlet. +} { + set spec { + name "ae_admin_portlet" + contract_name "portal_datasource" + owner "ae-portlet" + aliases { + GetMyName ae_admin_portlet::get_my_name + GetPrettyName ae_admin_portlet::get_pretty_name + Link ae_admin_portlet::link + AddSelfToPage ae_admin_portlet::add_self_to_page + Show ae_admin_portlet::show + Edit ae_admin_portlet::edit + RemoveSelfFromPage ae_admin_portlet::remove_self_from_page + } + } + + acs_sc::impl::new_from_spec -spec $spec +} + +ad_proc -private ae_portlet::uninstall {} { + Ae Portlet package uninstall proc +} { + unregister_implementations + set ds_id [portal::get_datasource_id ae_portlet] + db_exec_plsql delete_aes_ds { *SQL* } +} + +ad_proc -private ae_admin_portlet::uninstall {} { + Ae Portlet package uninstall proc +} { + unregister_implementations + set ds_id [portal::get_datasource_id ae_admin_portlet] + db_exec_plsql delete_admin_ds { *SQL* } +} + +ad_proc -private ae_portlet::unregister_implementations {} { + Unregister service contract implementations +} { + acs_sc::impl::delete \ + -contract_name "portal_datasource" \ + -impl_name "ae_portlet" +} + +ad_proc -private ae_admin_portlet::unregister_implementations {} { + Unregister service contract implementations +} { + acs_sc::impl::delete \ + -contract_name "portal_datasource" \ + -impl_name "ae_admin_portlet" +} Index: openacs-4/packages/ae-portlet/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/tcl/apm-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/tcl/apm-callback-procs.tcl 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,30 @@ +ad_library { + Procedures for initializing service contracts etc. for the + anon-eval portlet package. Should only be executed + once upon installation. + + @author Anny Flores (annyflores@viaro.net) + @author Viaro Networks (www.viaro.net) +} + +namespace eval apm::ae_portlet {} +namespace eval apm::ae_admin_portlet {} + +ad_proc -public apm::ae_portlet::after_install {} { + Create the datasources needed by the anon-eval portlets. +} { + ae_portlet::after_install + ae_admin_portlet::after_install +} + +ad_proc -public apm::anon-eval_portlet::before_uninstall {} { + Anon-Eval Portlet package uninstall proc +} { + + db_transaction { + ae_portlet::uninstall + ae_admin_portlet::uninstall + } +} + + Index: openacs-4/packages/ae-portlet/www/ae-admin-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/ae-admin-portlet.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-admin-portlet.adp 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,5 @@ + + +
+@actions;noquote@ +
Index: openacs-4/packages/ae-portlet/www/ae-admin-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/ae-admin-portlet.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-admin-portlet.tcl 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,62 @@ +ad_page_contract { + The display logic for the assessment admin portlet + + @author Anny Flores (annyflores@viaro.net) + @author Viaro Networks (www.viaro.net) + +} -properties { + +} + +array set config $cf +set user_id [ad_conn user_id] +set list_of_package_ids $config(package_id) +set dotlrn_admin_p [dotlrn::admin_p -user_id $user_id] + +if {[llength $list_of_package_ids] > 1} { + # We have a problem! + return -code error "[_ assessment-portlet.error_one_assessment] " +} + +set package_id [lindex $list_of_package_ids 0] + +set url [lindex [site_node::get_url_from_object_id -object_id $package_id] 0] +set user_id [ad_conn user_id] +set package_admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege "admin"] +set actions "[_ assessment.New_Assessment]" + +if { $package_admin_p == 0} { + set m_name "get_all_assessments_admin" +} else { + set m_name "get_all_assessments" +} + +#list all assessments + +db_multirow -extend { export permissions admin_request} assessments $m_name {} { + set export "[_ assessment.Export]" + set permissions "[_ assessment.permissions]" + set admin_request "[_ assessment.Request] [_ assessment.Administration]" +} + +list::create \ + -name assessments \ + -key assessment_id \ + -no_data "[_ assessment.None]" \ + -elements { + title { + label {[_ ae-portlet.title]} + display_template {
@assessments.title@
} + } + edit { + display_template {} + } + view_results { + label {[_ ae-portlet.view_results]} + display_template {#assessment.All# | + #assessment.CSV_file#} + } + } + + +ad_return_template Index: openacs-4/packages/ae-portlet/www/ae-admin-portlet.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/ae-admin-portlet.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-admin-portlet.xql 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,33 @@ + + + + + + + select ci.item_id as assessment_id, cr.title + from cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a + where cr.revision_id = ci.latest_revision + and a.assessment_id = cr.revision_id + and ci.parent_id = cf.folder_id and cf.package_id = :package_id + order by cr.title + + + + + + + + select ci.item_id as assessment_id, cr.title + from cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a + where cr.revision_id = ci.latest_revision + and a.assessment_id = cr.revision_id + and ci.parent_id = cf.folder_id + and ci.item_id in (select object_id from acs_permissions where + grantee_id=:user_id and privilege='admin') and cf.package_id = :package_id + order by cr.title + + + + + + Index: openacs-4/packages/ae-portlet/www/ae-portlet-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/Attic/ae-portlet-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-portlet-oracle.xql 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,26 @@ + + + +oracle8.1.6 + + + + select cri.item_id as assessment_id, + crr.title, + crr.description, + acs_object.name(apm_package.parent_id(crf.package_id)) as parent_name, + (select site_node.url(site_nodes.node_id) + from site_nodes + where site_nodes.object_id = crf.package_id) as url, + crf.package_id + from as_assessments asa, cr_items cri, cr_revisions crr, cr_folders crf + where crr.revision_id = asa.assessment_id + and crr.revision_id = cri.latest_revision + and cri.parent_id = crf.folder_id + and crf.package_id in ([join $list_of_package_ids ", "]) + and (asa.start_time < current_timestamp or asa.start_time is null) + order by package_id, lower(crr.title) + + + + Index: openacs-4/packages/ae-portlet/www/ae-portlet-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/Attic/ae-portlet-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-portlet-postgresql.xql 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,31 @@ + + + +postgresql7.1 + + + + select cr.item_id as assessment_id, cr.title, cr.description, a.password, + to_char(a.start_time, 'YYYY-MM-DD HH24:MI:SS') as start_time, + to_char(a.end_time, 'YYYY-MM-DD HH24:MI:SS') as end_time, + to_char(now(), 'YYYY-MM-DD HH24:MI:SS') as cur_time, + cf.package_id, p.instance_name as community_name, + sc.node_id as comm_node_id, sa.node_id as as_node_id + from as_assessments a, cr_revisions cr, cr_items ci, cr_folders cf, + site_nodes sa, site_nodes sc, apm_packages p + where a.assessment_id = cr.revision_id + and cr.revision_id = ci.latest_revision + and ci.parent_id = cf.folder_id + and cf.package_id in ([join $list_of_package_ids ", "]) + and sa.object_id = cf.package_id + and sc.node_id = sa.parent_id + and p.package_id = sc.object_id + and exists (select 1 + from as_assessment_section_map asm, as_item_section_map ism + where asm.assessment_id = a.assessment_id + and ism.section_id = asm.section_id) + order by lower(p.instance_name), lower(cr.title) + + + + Index: openacs-4/packages/ae-portlet/www/ae-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/ae-portlet.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-portlet.adp 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + + +

#assessment.answered_assessments#

+ +
+
+
+ +   + + Index: openacs-4/packages/ae-portlet/www/ae-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/ae-portlet.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-portlet.tcl 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,112 @@ +ad_page_contract { + The display logic for the assessment portlet + + @author Anny Flores (annyflores@viaro.net) + @author Viaro Networks (www.viaro.net) +} { + {page_num 0} +} -properties { +} + +set user_id [ad_conn user_id] + +array set config $cf +set shaded_p $config(shaded_p) + +set list_of_package_ids $config(package_id) +set package_id [lindex $list_of_package_ids 0] +set user_id [ad_conn user_id] +set package_admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege "admin"] +set dotlrn_admin_p [dotlrn::admin_p -user_id $user_id] + +set one_instance_p [ad_decode [llength $list_of_package_ids] 1 1 0] + +set elements [list] +if {!$one_instance_p} { + set elements [list community_name \ + [list \ + label "[_ dotlrn.Community]" \ + display_template {@assessments.community_name@ }]] +} + +lappend elements title \ + [list \ + label "[_ assessment.open_assessments]" \ + display_template {@assessments.title@}] + + +# create a list with all open assessments +template::list::create \ + -name assessments \ + -multirow assessments \ + -key assessment_id \ + -elements $elements \ + -main_class narrow + +# get the information of all open assessments +template::multirow create assessments assessment_id title description assessment_url community_url community_name +set old_comm_node_id 0 +db_foreach open_asssessments {} { + if {([empty_string_p $start_time] || $start_time <= $cur_time) && ([empty_string_p $end_time] || $end_time >= $cur_time)} { + if {$comm_node_id == $old_comm_node_id} { + set community_name "" + } + set community_url [site_node::get_url -node_id $comm_node_id] + set assessment_url [site_node::get_url -node_id $as_node_id] + set old_comm_node_id $comm_node_id + + if {[empty_string_p $password]} { + append assessment_url [export_vars -base "assessment" {assessment_id}] + } else { + append assessment_url [export_vars -base "assessment-password" {assessment_id}] + } + + template::multirow append assessments $assessment_id $title $description $assessment_url $community_url $community_name + } +} + + +set elements [list] +if {!$one_instance_p} { + set elements [list community_name \ + [list \ + label "[_ dotlrn.Community]" \ + display_template {@sessions.community_name@ }]] +} + +lappend elements title \ + [list \ + label "[_ assessment.Assessments]"] \ + +lappend elements edit\ + [list \ + display_template {
} + ] + +lappend elements view \ + [list \ + display_template {
} + ] + +# create a list with all answered assessments and their sessions +template::list::create \ + -name sessions \ + -multirow sessions \ + -key assessment_id \ + -elements $elements \ + -main_class narrow + +# get the information of all assessments store in the database +set old_comm_node_id 0 +db_multirow -extend { session_id session_url community_url } sessions answered_assessments {} { + if {$comm_node_id == $old_comm_node_id} { + set community_name "" + } + as::assessment::data -assessment_id $assessment_id + set assessment_rev_id $assessment_data(assessment_rev_id) + set session_id [db_string last_session {select max(session_id) as session_id from as_sessions where assessment_id = :assessment_rev_id and subject_id = :user_id}] + + set community_url [site_node::get_url -node_id $comm_node_id] + set session_url "[site_node::get_url -node_id $as_node_id][export_vars -base sessions {assessment_id}]" + set old_comm_node_id $comm_node_id +} Index: openacs-4/packages/ae-portlet/www/ae-portlet.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/www/Attic/ae-portlet.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ae-portlet/www/ae-portlet.xql 9 Jun 2005 05:54:36 -0000 1.1 @@ -0,0 +1,29 @@ + + + + + + select cr.item_id as assessment_id, cr.title, cr.description, + cf.package_id, p.instance_name as community_name, + sc.node_id as comm_node_id, sa.node_id as as_node_id + from as_assessments a, cr_revisions cr, cr_items ci, cr_folders cf, + site_nodes sa, site_nodes sc, apm_packages p + where a.assessment_id = cr.revision_id + and cr.revision_id = ci.latest_revision + and ci.parent_id = cf.folder_id + and cf.package_id in ([join $list_of_package_ids ", "]) + and sa.object_id = cf.package_id + and sc.node_id = sa.parent_id + and p.package_id = sc.object_id + and exists (select 1 + from as_sessions s + where s.assessment_id = a.assessment_id + and s.subject_id = :user_id + and s.completed_datetime is not null) + order by lower(p.instance_name), lower(cr.title) + + + + + + Index: openacs-4/packages/anon-eval/catalog/anon-eval.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/catalog/anon-eval.en_US.ISO-8859-1.xml,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/catalog/anon-eval.en_US.ISO-8859-1.xml 4 Jun 2005 10:15:55 -0000 1.1 +++ openacs-4/packages/anon-eval/catalog/anon-eval.en_US.ISO-8859-1.xml 9 Jun 2005 05:54:36 -0000 1.2 @@ -1,7 +1,10 @@ + You are not able to submit a respose for this evaluation. + You don't have permission to admin Course Evaluations. Course Evaluations Course Evaluations Administration Anonymous Course Evaluations + You don't have permission to see the results. Index: openacs-4/packages/anon-eval/www/assessment.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/www/assessment.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/www/assessment.tcl 2 Jun 2005 06:28:45 -0000 1.1 +++ openacs-4/packages/anon-eval/www/assessment.tcl 9 Jun 2005 05:54:36 -0000 1.2 @@ -18,7 +18,6 @@ context_bar:onevalue page_title:onevalue } - set user_id [ad_conn user_id] set page_title "[_ assessment.Show_Items]" set context [list $page_title] @@ -36,8 +35,13 @@ # Get the assessment data as::assessment::data -assessment_id $assessment_id -permission::require_permission -object_id $assessment_id -privilege read +set admin_p [permission::permission_p -privilege admin -object_id [ad_conn package_id]] +if { $admin_p } { + ad_return_complaint 1 "[_ anon-eval.admin_message]" + ad_script_abort +} + if {![info exists assessment_data(assessment_id)]} { ad_return_complaint 1 "[_ assessment.Requested_assess_does]" ad_script_abort @@ -55,7 +59,6 @@ db_transaction { if {[empty_string_p $session_id]} { - # Check if there is an unfinished session lying around set session_id [db_string unfinished_session_id {}] if {[empty_string_p $session_id]} { Index: openacs-4/packages/anon-eval/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/www/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/www/index.tcl 2 Jun 2005 06:28:45 -0000 1.1 +++ openacs-4/packages/anon-eval/www/index.tcl 9 Jun 2005 05:54:36 -0000 1.2 @@ -15,7 +15,13 @@ set package_id [ad_conn package_id] set folder_id [as::assessment::folder_id -package_id $package_id] set user_id [ad_conn user_id] +set admin_p [permission::permission_p -privilege admin -object_id [ad_conn package_id]] +if { $admin_p } { + ad_return_complaint 1 "[_ anon-eval.permission_denied]" + ad_script_abort +} + # create a list with all open assessments template::list::create \ -name assessments \ Index: openacs-4/packages/anon-eval/www/session.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/www/session.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/www/session.tcl 2 Jun 2005 06:28:45 -0000 1.1 +++ openacs-4/packages/anon-eval/www/session.tcl 9 Jun 2005 05:54:36 -0000 1.2 @@ -17,7 +17,13 @@ # Get the assessment data as::assessment::data -assessment_id $assessment_id permission::require_permission -object_id $assessment_id -privilege read +set admin_p [permission::permission_p -privilege admin -object_id [ad_conn package_id]] +if { $admin_p } { + ad_return_complaint 1 "[_ anon-eval.permission_denied]" + ad_script_abort +} + if {![info exists assessment_data(assessment_id)]} { ad_return_complaint 1 "[_ assessment.Requested_assess_does]" ad_script_abort Index: openacs-4/packages/anon-eval/www/sessions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/www/sessions.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/www/sessions.tcl 2 Jun 2005 06:28:45 -0000 1.1 +++ openacs-4/packages/anon-eval/www/sessions.tcl 9 Jun 2005 05:54:36 -0000 1.2 @@ -19,7 +19,14 @@ set format "[lc_get formbuilder_date_format], [lc_get formbuilder_time_format]" set user_id [ad_conn user_id] permission::require_permission -object_id $assessment_id -privilege read +set dotlrn_admin_p [dotlrn::admin_p] +if { !$dotlrn_admin_p } { + ad_return_complaint 1 "[_ anon-eval.permission_denied]" + ad_script_abort +} + + # Get the assessment data as::assessment::data -assessment_id $assessment_id Index: openacs-4/packages/anon-eval/www/asm-admin/assessment-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/www/asm-admin/assessment-form.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/www/asm-admin/assessment-form.tcl 2 Jun 2005 06:28:45 -0000 1.1 +++ openacs-4/packages/anon-eval/www/asm-admin/assessment-form.tcl 9 Jun 2005 05:54:37 -0000 1.2 @@ -25,6 +25,14 @@ set package_id [ad_conn package_id] permission::require_permission -object_id $package_id -privilege create +set dotlrn_admin_p [dotlrn::admin_p] + +if { !$dotlrn_admin_p } { + ad_return_complaint 1 "[_ anon-eval.admin_permission_denied]" + ad_script_abort +} + + set context [list [list index [_ assessment.admin]] $page_title] set sql_format "YYYY-MM-DD HH24:MI:SS" Index: openacs-4/packages/anon-eval/www/asm-admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/www/asm-admin/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/www/asm-admin/index.tcl 2 Jun 2005 06:28:45 -0000 1.1 +++ openacs-4/packages/anon-eval/www/asm-admin/index.tcl 9 Jun 2005 05:54:37 -0000 1.2 @@ -20,7 +20,14 @@ set categories_url [db_string get_category_url {}] set user_id [ad_conn user_id] set package_admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege "admin"] +set dotlrn_admin_p [dotlrn::admin_p] +if { !$dotlrn_admin_p } { + ad_return_complaint 1 "[_ anon-eval.admin_permission_denied]" + ad_script_abort +} + + if { $package_admin_p == 0} { set m_name "get_all_assessments_admin" } else { Index: openacs-4/packages/anon-eval/www/asm-admin/one-a.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/anon-eval/www/asm-admin/one-a.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/anon-eval/www/asm-admin/one-a.tcl 2 Jun 2005 06:28:45 -0000 1.1 +++ openacs-4/packages/anon-eval/www/asm-admin/one-a.tcl 9 Jun 2005 05:54:37 -0000 1.2 @@ -18,6 +18,13 @@ permission::require_permission -object_id $package_id -privilege create permission::require_permission -object_id $assessment_id -privilege admin +set dotlrn_admin_p [dotlrn::admin_p] + +if { !$dotlrn_admin_p } { + ad_return_complaint 1 "[_ anon-eval.admin_permission_denied]" + ad_script_abort +} + set admin_p [acs_user::site_wide_admin_p] # Get the assessment data as::assessment::data -assessment_id $assessment_id Index: openacs-4/packages/attendance/lib/cp-attendance.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/lib/cp-attendance.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attendance/lib/cp-attendance.adp 9 Jun 2005 05:54:37 -0000 1.1 @@ -0,0 +1,8 @@ +
  • Sessions
  • + + + Index: openacs-4/packages/attendance/lib/cp-attendance.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/lib/cp-attendance.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/attendance/lib/cp-attendance.tcl 9 Jun 2005 05:54:37 -0000 1.1 @@ -0,0 +1,66 @@ + +set current_url [ad_conn url] + +set package_id [ad_conn package_id] +set community_id [dotlrn_community::get_community_id] + +set attendance_package_id [db_string "getattpack" "select object_id from acs_objects a, apm_packages b where a.object_id = b.package_id and a.context_id = :package_id and b.package_key = 'attendance';"] +set attendance_url [apm_package_url_from_id $attendance_package_id] + +set calendar_id [dotlrn_calendar::get_group_calendar_id -community_id $community_id] +set calendar_url [calendar_portlet_display::get_url_stub $calendar_id] +set item_type_id [db_string item_type_id "select item_type_id from cal_item_types where type='Session' and calendar_id = :calendar_id limit 1" -default 0] + +set grade_item_id [db_string "getgradeid" "select eg.grade_item_id as grade_item_id + from evaluation_grades eg, acs_objects ao, cr_items cri + where cri.live_revision = eg.grade_id + and eg.grade_item_id = ao.object_id + and ao.context_id = :attendance_package_id + and eg.grade_name = 'Attendance'"] + +ns_log Notice " -- Attendance Package ID : $attendance_package_id, Grade Item : $grade_item_id --" + +attendance::add_sessions -community_id $community_id -grade_item_id $grade_item_id -package_id $attendance_package_id + +template::list::create \ + -name session_list \ + -multirow session_list \ + -pass_properties { attendance_url current_url calendar_url calendar_id item_type_id } \ + -key task_id \ + -no_data "No sessions" \ + -elements { + task_name { + label "Session" + } + action { + label "Actions" + display_template { Edit | Mark Attendance } + } + } + +db_multirow -extend {cal_item_id} session_list get_sessions { + select et.task_name, et.number_of_members, et.task_id, et.grade_item_id, + to_char(et.due_date,'YYYY-MM-DD HH24:MI:SS') as due_date_ansi, + et.online_p, + et.late_submit_p, + et.item_id, + et.task_item_id, + et.due_date, + et.requires_grade_p, et.description, et.grade_item_id, + cr.title as task_title, + et.data as task_data, + et.task_id as revision_id, + coalesce(round(cr.content_length/1024,0),0) as content_length, + et.late_submit_p, + crmt.label as pretty_mime_type + from cr_revisions cr, + evaluation_tasksi et, + cr_items cri, + cr_mime_types crmt + where cr.revision_id = et.revision_id + and grade_item_id = :grade_item_id + and cri.live_revision = et.task_id + and et.mime_type = crmt.mime_type +} { + set cal_item_id [db_string "getcalid" "select cal_item_id from evaluation_cal_task_map where task_item_id=:item_id"] +} \ No newline at end of file Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/attendance/tcl/attendance-init.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/attendance/tcl/attendance-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/tcl/attendance-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attendance/tcl/attendance-procs.tcl 31 May 2005 22:02:59 -0000 1.1 +++ openacs-4/packages/attendance/tcl/attendance-procs.tcl 9 Jun 2005 05:54:37 -0000 1.2 @@ -9,9 +9,8 @@ namespace eval attendance { - ad_proc get_grade_info { - {-package_id:required} + -package_id:required } { HAM (hamilton.chua@gmail.com) Retreives grade_id and grade_item_id from evaluation and sets them in the calling environment @@ -20,14 +19,15 @@ uplevel 1 { db_0or1row "getgradeid" "select eg.grade_id as grade_id, eg.grade_item_id as grade_item_id, eg.grade_plural_name from evaluation_grades eg, acs_objects ao, cr_items cri where cri.live_revision = eg.grade_id - and eg.grade_item_id = ao.object_id - and ao.context_id = :package_id + and eg.grade_item_id = ao.object_id + and ao.context_id = :package_id and eg.grade_name = 'Attendance'"} } ad_proc create_task { - {-cal_item_id:required} - {-grade_item_id:required} + -cal_item_id:required + -grade_item_id:required + {-package_id ""} } { HAM (hamilton.chua@gmail.com) Create an attendance task @@ -42,6 +42,10 @@ set item_id [db_nextval acs_object_id_seq] set cal_start_date [template::util::date::from_ansi $cal_item_array(start_date_ansi) "YYYY-MM-DD HH24:MI:SS"] set cal_end_date [template::util::date::from_ansi $cal_item_array(end_date_ansi) "YYYY-MM-DD HH24:MI:SS"] + + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } set due_date_ansi $cal_item_array(start_date_ansi) set url "" @@ -62,7 +66,7 @@ -storage_type $storage_type \ -due_date $due_date_ansi \ -requires_grade_p "f" \ - -title $title ] + -title $title -package_id $package_id ] content::item::set_live_revision -revision_id $revision_id db_dml update_date { @@ -82,26 +86,31 @@ } ad_proc add_sessions { - {-community_id:required} - {-grade_item_id:required} + -community_id:required + -grade_item_id:required + {-package_id ""} } { HAM (hamilton.chua@gmail.com) Check if there are calendar sessions for the section - Cehck if the session is arleady an evaluation + Check if the session is already an evaluation task if not then create a task with the session's details } { # let's retrieve sessions for this community set calendar_id [dotlrn_calendar::get_group_calendar_id -community_id $community_id] set item_type_id [db_string item_type_id "select item_type_id from cal_item_types where type='Session' and calendar_id = :calendar_id"] + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + # create the task db_transaction { # check if each session has corresponding evaluation task, if none then add it db_foreach "cal_item" "select cal_item_id from cal_items where on_which_calendar = :calendar_id and item_type_id = :item_type_id" { - attendance::create_task -cal_item_id $cal_item_id -grade_item_id $grade_item_id + attendance::create_task -cal_item_id $cal_item_id -grade_item_id $grade_item_id -package_id $package_id } Index: openacs-4/packages/attendance/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/www/index.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attendance/www/index.adp 31 May 2005 22:02:59 -0000 1.1 +++ openacs-4/packages/attendance/www/index.adp 9 Jun 2005 05:54:37 -0000 1.2 @@ -1,4 +1,4 @@ -ExpensesAttendanceFor admins only. Index: openacs-4/packages/attendance/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/www/admin/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attendance/www/admin/index.tcl 31 May 2005 22:02:59 -0000 1.1 +++ openacs-4/packages/attendance/www/admin/index.tcl 9 Jun 2005 05:54:37 -0000 1.2 @@ -14,14 +14,16 @@ # initial variables set page_title "Attendance Tasks" set context $page_title -set package_id [ad_conn package_id] set community_id [dotlrn_community::get_community_id] +set package_id [ad_conn package_id] # get grade info attendance::get_grade_info -package_id $package_id +ns_log Notice " -- Attendance Package ID : $package_id, Grade Item : $grade_item_id --" + # check calendar items for session and turn them into attendance tasks -attendance::add_sessions -community_id $community_id -grade_item_id $grade_item_id +attendance::add_sessions -community_id $community_id -grade_item_id $grade_item_id -package_id $package_id set elements [list task_name \ [list label "Task Name" \ Index: openacs-4/packages/attendance/www/admin/mark-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/www/admin/mark-2.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attendance/www/admin/mark-2.tcl 31 May 2005 22:02:59 -0000 1.1 +++ openacs-4/packages/attendance/www/admin/mark-2.tcl 9 Jun 2005 05:54:37 -0000 1.2 @@ -8,16 +8,18 @@ } { cal_item_id:integer,notnull user_id:integer,multiple,optional + {return_url "index"} } -# delete attendance for a cal_item_id -db_dml "delattendance" "delete from attendance_cal_item_map where cal_item_id = :cal_item_id" - if { [exists_and_not_null user_id ] } { + + # delete attendance for a cal_item_id + db_dml "delattendance" "delete from attendance_cal_item_map where cal_item_id = :cal_item_id" + foreach id $user_id { db_dml "updatemap" "insert into attendance_cal_item_map (cal_item_id, user_id) values (:cal_item_id, :id)" } } -ad_returnredirect -message "Attendance has been marked" "index" \ No newline at end of file +ad_returnredirect -message "Attendance has been marked" $return_url \ No newline at end of file Index: openacs-4/packages/attendance/www/admin/mark.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/www/admin/mark.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attendance/www/admin/mark.adp 31 May 2005 22:02:59 -0000 1.1 +++ openacs-4/packages/attendance/www/admin/mark.adp 9 Jun 2005 05:54:37 -0000 1.2 @@ -6,6 +6,7 @@
    +
    Index: openacs-4/packages/attendance/www/admin/mark.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/www/admin/mark.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/attendance/www/admin/mark.tcl 31 May 2005 22:02:59 -0000 1.1 +++ openacs-4/packages/attendance/www/admin/mark.tcl 9 Jun 2005 05:54:37 -0000 1.2 @@ -7,6 +7,7 @@ @cvs-id $Id$ } { item_id:integer,notnull + {return_url ""} } # initial vars @@ -19,10 +20,12 @@ db_1row "getgradeid" "select task_id, task_name, due_date from evaluation_tasks where task_item_id = :item_id" set cal_item_id [db_string "get_cal_id" "select cal_item_id from evaluation_cal_task_map where task_item_id =:item_id"] -set due_date_pretty [lc_time_fmt $due_date "%q %r"] +calendar::item::get -cal_item_id $cal_item_id -array cal_item_info -set message "

    Mark the users who were present for $task_name on $due_date_pretty

    " +# set due_date_pretty [lc_time_fmt $due_date "%q %r"] +set message "

    Mark the users who were present for $task_name on $cal_item_info(full_start_date)

    " + template::list::create \ -name eval_members \ -multirow eval_members \ Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/attendance/www/admin/student-list-oracle.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/attendance/www/admin/student-list-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/attendance/www/admin/student-list.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/attendance/www/admin/student-list.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/attendance/www/admin/student-list.xql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/dotlrn-ae/dotlrn-ae.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ae/dotlrn-ae.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ae/dotlrn-ae.info 9 Jun 2005 05:54:38 -0000 1.1 @@ -0,0 +1,27 @@ + + + + + dotLRN Anon Eval Applet + dotLRN Anon Eval Applets + f + t + + + Anny Flores + 2004-10-19 + + + + + + + + + + + + + + + Index: openacs-4/packages/dotlrn-ae/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ae/tcl/apm-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ae/tcl/apm-callback-procs.tcl 9 Jun 2005 05:54:38 -0000 1.1 @@ -0,0 +1,59 @@ +ad_library { + Procedures for registering implementations for the + dotlrn anon-eval package. + + @creation-date 2005-06-01 + @author Anny Flores (annyflores@viaro.net) + @author Viaro Networks (www.viaro.net) + +} + +namespace eval dotlrn_ae {} + +ad_proc -public dotlrn_ae::install {} { + dotLRN Anon Eval package install proc +} { + register_portal_datasource_impl +} + +ad_proc -public dotlrn_ae::uninstall {} { + dotLRN Anon Eval package uninstall proc +} { + unregister_portal_datasource_impl +} + +ad_proc -public dotlrn_ae::register_portal_datasource_impl {} { + Register the service contract implementation for the dotlrn_applet service contract +} { + set spec { + name "dotlrn_ae" + contract_name "dotlrn_applet" + owner "dotlrn-ae" + aliases { + GetPrettyName dotlrn_ae::get_pretty_name + AddApplet dotlrn_ae::add_applet + RemoveApplet dotlrn_ae::remove_applet + AddAppletToCommunity dotlrn_ae::add_applet_to_community + RemoveAppletFromCommunity dotlrn_ae::remove_applet_from_community + AddUser dotlrn_ae::add_user + RemoveUser dotlrn_ae::remove_user + AddUserToCommunity dotlrn_ae::add_user_to_community + RemoveUserFromCommunity dotlrn_ae::remove_user_from_community + AddPortlet dotlrn_ae::add_portlet + RemovePortlet dotlrn_ae::remove_portlet + Clone dotlrn_ae::clone + ChangeEventHandler dotlrn_ae::change_event_handler + } + } + + acs_sc::impl::new_from_spec -spec $spec +} + +ad_proc -public dotlrn_ae::unregister_portal_datasource_impl {} { + Unregister service contract implementations +} { + acs_sc::impl::delete \ + -contract_name "dotlrn_applet" \ + -impl_name "dotlrn_ae" +} + Index: openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs-postgresql.xql 9 Jun 2005 05:54:38 -0000 1.1 @@ -0,0 +1,35 @@ + + + +postgresql7.1 + + + + select ci.item_id as assessment_id, cr.title + from cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a + where cr.revision_id = ci.latest_revision + and a.assessment_id = cr.revision_id + and ci.parent_id = cf.folder_id and cf.package_id = :old_package_id + order by cr.title + + + + + + + + delete from dotlrn_community_applets where applet_id = :applet_id + + + + + + + + delete from dotlrn_applets where applet_id = :applet_id + + + + + + Index: openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs.tcl 9 Jun 2005 05:54:38 -0000 1.1 @@ -0,0 +1,259 @@ +ad_library { + + Procs to set up the dotLRN ae applet + + @author Anny Flores (annyflores@viaro.net) + @author Viaro Networks (www.viaro.net) +} + +namespace eval dotlrn_ae {} + +ad_proc -public dotlrn_ae::applet_key {} { + What's my applet key? +} { + return dotlrn_ae +} + +ad_proc -public dotlrn_ae::package_key {} { + What package do I deal with? +} { + return "anon-eval" +} + +ad_proc -public dotlrn_ae::my_package_key {} { + What package do I deal with? +} { + return "dotlrn-ae" +} + +ad_proc -public dotlrn_ae::get_pretty_name {} { + returns the pretty name +} { + return "#anon-eval.Applet#" +} + +ad_proc -public dotlrn_ae::add_applet {} { + One time init - must be repeatable! +} { + dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] -package_key [my_package_key] +} + +ad_proc -public dotlrn_ae::remove_applet {} { + One time destroy. +} { + set applet_id [dotlrn_applet::get_applet_id_from_key [my_package_key]] + db_exec_plsql delete_applet_from_communities { *SQL* } + db_exec_plsql delete_applet { *SQL* } +} + +ad_proc -public dotlrn_ae::add_applet_to_community { + community_id +} { + Add the ae applet to a specifc dotlrn community +} { + set portal_id [dotlrn_community::get_portal_id -community_id $community_id] + + # create the ae package instance + set package_id [dotlrn::instantiate_and_mount $community_id [package_key]] + + # set up the admin portal + set admin_portal_id [dotlrn_community::get_admin_portal_id \ + -community_id $community_id + ] + + ae_admin_portlet::add_self_to_page \ + -portal_id $admin_portal_id \ + -package_id $package_id + + set args [ns_set create] + ns_set put $args package_id $package_id + add_portlet_helper $portal_id $args + + return $package_id +} + +ad_proc -public dotlrn_ae::remove_applet_from_community { + community_id +} { + remove the applet from the community +} { + ad_return_complaint 1 "[applet_key] remove_applet_from_community not implimented!" +} + +ad_proc -public dotlrn_ae::add_user { + user_id +} { + one time user-specifuc init +} { + # noop +} + +ad_proc -public dotlrn_ae::remove_user { + user_id +} { +} { + ad_return_complaint 1 "[applet_key] remove_user not implimented!" +} + +ad_proc -public dotlrn_ae::add_user_to_community { + community_id + user_id +} { + Add a user to a specifc dotlrn community +} { + set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]] + set portal_id [dotlrn::get_portal_id -user_id $user_id] + + # use "append" here since we want to aggregate + set args [ns_set create] + ns_set put $args package_id $package_id + ns_set put $args param_action append + add_portlet_helper $portal_id $args +} + +ad_proc -public dotlrn_ae::remove_user_from_community { + community_id + user_id +} { + Remove a user from a community +} { + set package_id [dotlrn_community::get_applet_package_id -community_id $community_id -applet_key [applet_key]] + set portal_id [dotlrn::get_portal_id -user_id $user_id] + + set args [ns_set create] + ns_set put $args package_id $package_id + + remove_portlet $portal_id $args +} + +ad_proc -public dotlrn_ae::add_portlet { + portal_id +} { + A helper proc to add the underlying portlet to the given portal. + + @param portal_id +} { + # simple, no type specific stuff, just set some dummy values + + set args [ns_set create] + ns_set put $args package_id 0 + ns_set put $args param_action overwrite + add_portlet_helper $portal_id $args +} + +ad_proc -public dotlrn_ae::add_portlet_helper { + portal_id + args +} { + A helper proc to add the underlying portlet to the given portal. + + @param portal_id + @param args an ns_set +} { + ae_portlet::add_self_to_page \ + -portal_id $portal_id \ + -package_id [ns_set get $args package_id] \ + -param_action [ns_set get $args param_action] +} + +ad_proc -public dotlrn_ae::remove_portlet { + portal_id + args +} { + A helper proc to remove the underlying portlet from the given portal. + + @param portal_id + @param args A list of key-value pairs (possibly user_id, community_id, and more) +} { + ae_portlet::remove_self_from_page \ + -portal_id $portal_id \ + -package_id [ns_set get $args package_id] +} + +ad_proc -public dotlrn_ae::clone { + old_community_id + new_community_id +} { + Clone this applet's content from the old community to the new one +} { + ns_log notice "Cloning: [applet_key]" + set new_package_id [add_applet_to_community $new_community_id] + set old_package_id [dotlrn_community::get_applet_package_id \ + -community_id $old_community_id \ + -applet_key [applet_key] + ] + + set folder_id [as::assessment::folder_id -package_id $new_package_id] + + set assessments [db_list_of_lists get_assessments { }] + + foreach assessment $assessments { + dotlrn_ae::assessment_copy -assessment_id [lindex $assessment 0] -name [lindex $assessment 1] -folder_id $folder_id + } + return $new_package_id +} + +ad_proc -public dotlrn_ae::change_event_handler { + community_id + event + old_value + new_value +} { + listens for the following events: +} { +} + +ad_proc -public dotlrn_ae::assessment_copy { + {-assessment_id:required} + {-name ""} + {-folder_id} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-23 + + Copies an assessment with all sections and items +} { + as::assessment::data -assessment_id $assessment_id + array set a [array get assessment_data] + append a(title) "[_ assessment.copy_appendix]" + + + set new_assessment_id [db_nextval acs_object_id_seq] + if {[empty_string_p $name]} { + set name "ASS_$new_assessment_id" + } + set new_assessment_id [content::item::new -item_id $new_assessment_id -parent_id $folder_id -content_type {as_assessments} -name $name] + + set new_rev_id [content::revision::new \ + -item_id $new_assessment_id \ + -content_type {as_assessments} \ + -title $a(title) \ + -description $a(description) \ + -attributes [list [list creator_id $a(creator_id)] \ + [list instructions $a(instructions)] \ + [list run_mode $a(run_mode)] \ + [list anonymous_p $a(anonymous_p)] \ + [list secure_access_p $a(secure_access_p)] \ + [list reuse_responses_p $a(reuse_responses_p)] \ + [list show_item_name_p $a(show_item_name_p)] \ + [list random_p $a(random_p)] \ + [list entry_page $a(entry_page)] \ + [list exit_page $a(exit_page)] \ + [list consent_page $a(consent_page)] \ + [list return_url $a(return_url)] \ + [list start_time $a(start_time)] \ + [list end_time $a(end_time)] \ + [list number_tries $a(number_tries)] \ + [list wait_between_tries $a(wait_between_tries)] \ + [list time_for_response $a(time_for_response)] \ + [list ip_mask $a(ip_mask)] \ + [list password $a(password)] \ + [list show_feedback $a(show_feedback)] \ + [list section_navigation $a(section_navigation)] ] ] + + as::assessment::copy_sections -assessment_id $a(assessment_rev_id) -new_assessment_id $new_rev_id + as::assessment::copy_categories -from_id $a(assessment_rev_id) -to_id $new_rev_id + + + return $new_assessment_id +} Index: openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ae/tcl/dotlrn-ae-procs.xql 9 Jun 2005 05:54:38 -0000 1.1 @@ -0,0 +1,16 @@ + + + + + + + select ci.item_id as assessment_id, cr.title + from cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a + where cr.revision_id = ci.latest_revision + and a.assessment_id = cr.revision_id + and ci.parent_id = cf.folder_id and cf.package_id = :old_package_id + order by cr.title + + + + Index: openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 4 Jun 2005 10:05:17 -0000 1.2 +++ openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 9 Jun 2005 05:54:38 -0000 1.3 @@ -17,26 +17,44 @@ set package_id [ad_conn package_id] set user_id [ad_conn user_id] +set cc_package_id [apm_package_id_from_key "dotlrn-catalog"] + +set filters {} + # Generate filters based on categories -set filters { - category_f { - label "[_ dotlrn-catalog.categories]" - values { ${Course Type} } - where_clause { ${Course Type_where_query} } - } - uncat_f { - label "[_ dotlrn-catalog.uncat]" - values { "Watch" } - where_clause { dc.course_id not in ( select object_id from category_object_map where category_id in \ - ( select category_id from categories where tree_id =:tree_id )) - } - } -} +# set filters { +# uncat_f { +# label "[_ dotlrn-catalog.uncat]" +# values { "Watch" } +# where_clause { dc.course_id not in ( select object_id from category_object_map where category_id in \ +# ( select category_id from categories where tree_id =:tree_id )) +# } +# } +# } set filter_list [list category_f] set form [rp_getform] +set category_trees [concat [category_tree::get_mapped_trees $cc_package_id] [category_tree::get_mapped_trees $package_id]] +set course_categories [list] +set section_categories [list] + +foreach tree [category_tree::get_mapped_trees $cc_package_id] { + set tree_name [lindex $tree 1] + regsub -all { } $tree_name _ f + set f [string tolower $f]_f + + ns_log notice "DEBUG:: CATEGORY:: $tree_name" + + lappend filter_list $f + set ff [ns_set get $form $f] + + if { ! [empty_string_p $ff] } { + set $f $ff + } + lappend course_categories [lindex $tree 0] +} foreach tree [category_tree::get_mapped_trees $package_id] { set tree_name [lindex $tree 1] regsub -all { } $tree_name _ f @@ -50,6 +68,7 @@ if { ! [empty_string_p $ff] } { set $f $ff } + lappend section_categories [lindex $tree 0] } ns_log notice "DEBUG:: FILTER:: $filter_list" @@ -72,9 +91,9 @@ } # Get all tree categories -set category_trees [linsert [category_tree::get_mapped_trees $package_id] 0 $tree_id] +#set category_trees [linsert [category_tree::get_mapped_trees $package_id] 0 $tree_id] +#set category_trees [category_tree::get_mapped_trees $cc_package_id] -set count 0 foreach tree_id $category_trees { set tree_id [lindex $tree_id 0] @@ -101,12 +120,8 @@ lappend $name [list "${spacer}[lindex "$element" 1]" "[lindex $element 0]&level=[lindex $element 3]" ] } - if { $count == 0 } { - set f category_f - } else { - regsub -all { } $name _ f - set f [string tolower $f]_f - } + regsub -all { } $name _ f + set f [string tolower $f]_f # Get all sub categories set map_tree "(" @@ -138,7 +153,7 @@ append map_tree "0)" } - if { $count == 0 } { + if { [lsearch $course_categories $tree_id] != -1 } { if { [string equal $[set ${f}_category_v] ""] } { set ${name}_where_query "dc.course_id in ( select object_id from category_object_map_tree where tree_id = $tree_id )" } else { @@ -151,10 +166,9 @@ set ${name}_where_query "dec.community_id in ( select object_id from category_object_map_tree where tree_id = $tree_id and category_id in $map_tree )" } } - incr count } -foreach tree [category_tree::get_mapped_trees $package_id] { +foreach tree $category_trees { set tree_name [lindex $tree 1] regsub -all { } $tree_name _ f set f [string tolower $f]_f @@ -281,7 +295,7 @@ label "" display_template { - [_ dotlrn-ecommerce.add_to_cart] + [_ dotlrn-ecommerce.add_to_cart] @@ -299,7 +313,7 @@ label "Group by" type multivar values { - { { [_ dotlrn-ecommerce.info] [_ dotlrn-ecommerce.edit] [_ dotlrn-ecommerce.add_section] + { { [_ dotlrn-ecommerce.info] [_ dotlrn-ecommerce.edit] [_ dotlrn-ecommerce.add_section]
    @course_list.course_grades@
    @course_list.course_info;noquote@ @@ -315,7 +329,7 @@ where name = 'Grade' } -default 0] -db_multirow -extend { category_name community_url course_edit_url section_edit_url course_grades section_grades sections_url member_p sessions instructors prices } course_list get_courses { } { +db_multirow -extend { category_name community_url course_edit_url section_add_url section_edit_url course_grades section_grades sections_url member_p sessions instructors prices shopping_cart_add_url } course_list get_courses { } { # set mapped [category::get_mapped_categories $course_id] # foreach element $mapped { @@ -326,9 +340,12 @@ set community_url [dotlrn_community::get_community_url $community_id] set return_url [ad_return_url] set course_edit_url [export_vars -base admin/course-add-edit { course_id return_url }] + set section_add_url [export_vars -base admin/section-add-edit { course_id return_url }] set section_edit_url [export_vars -base admin/section-add-edit { course_id section_id return_url }] set sections_url [export_vars -base sections { course_id }] + set shopping_cart_add_url [export_vars -base [apm_package_url_from_key "ecommerce"]shopping-cart-add { product_id }] + set member_p [dotlrn_community::member_p $community_id $user_id] set section_grades "" Index: openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl 2 Jun 2005 06:39:41 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl 9 Jun 2005 05:54:38 -0000 1.2 @@ -96,7 +96,6 @@ } {add:text(submit) {label "Add Participant"}} - {addpatron:text(submit) {label "Add Participant and Select Patron"}} } ad_form -extend -name register -on_request { @@ -171,13 +170,13 @@ } -after_submit { - if { ! [empty_string_p [template::element get_value register add]] } { - ad_returnredirect [export_vars -base $add_url { user_id }] - ad_script_abort - } elseif { ! [empty_string_p [template::element get_value register addpatron]] } { - ad_returnredirect [export_vars -base $addpatron_url { user_id }] - ad_script_abort - } +# if { ! [empty_string_p [template::element get_value register add]] } { +# ad_returnredirect [export_vars -base $add_url { user_id }] +# ad_script_abort +# } elseif { ! [empty_string_p [template::element get_value register addpatron]] } { +# ad_returnredirect [export_vars -base $addpatron_url { user_id }] +# ad_script_abort +# } if { ![empty_string_p $next_url] } { # Add user_id and account_message to the URL Index: openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 4 Jun 2005 10:05:18 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 9 Jun 2005 05:54:38 -0000 1.4 @@ -51,4 +51,11 @@ age integer ); +create table dotlrn_ecommerce_orders ( + item_id integer references ec_items on delete cascade not null, +-- Can be a user or group + patron_id integer references users(user_id) on delete cascade not null, + participant_id integer references parties(party_id) on delete cascade not null +); + \i dotlrn-ecommerce-memberships-create.sql \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/tcl/apm-callback-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/tcl/apm-callback-procs.tcl 4 Jun 2005 10:05:18 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/tcl/apm-callback-procs.tcl 9 Jun 2005 05:54:38 -0000 1.4 @@ -27,8 +27,10 @@ # add new rel types for student and instructors # Roel: Figure out why this is failing but dotlrn_club_student_rel # is being created - catch {rel_types::new -supertype dotlrn_member_rel -role_two student dotlrn_club_student_rel "dotLRN Club Student" "dotLRN Club Students" dotlrn_club 0 "" user 0 ""} -# rel_types::new -supertype dotlrn_member_rel -role_two instructor "dotLRN Club Instructor" "dotLRN Club Instructors" dotlrn_club 0 "" user 0 "" + catch { + rel_types::new -supertype dotlrn_member_rel -role_two student dotlrn_club_student_rel "dotLRN Club Student" "dotLRN Club Students" dotlrn_club 0 "" user 0 "" + rel_types::new -supertype dotlrn_member_rel -role_two instructor dotlrn_club_instructor_rel "dotLRN Club Instructor" "dotLRN Club Instructors" dotlrn_club 0 "" user 0 "" + } rel_types::new -role_one user -role_two user patron_rel "Patron" "Patrons" user 0 65535 user 0 65535 Index: openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl 4 Jun 2005 10:05:18 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl 9 Jun 2005 05:54:38 -0000 1.4 @@ -11,73 +11,98 @@ } ad_proc -callback ecommerce::after-checkout -impl dotlrn-ecommerce { - -user_id:required - -product_id:required + -user_id + -order_id -patron_id - -price } { - Add users to community -} { - # Check first if user_id is actually a group - if { [acs_object_type $user_id] == "group" } { - set user_ids [db_list group_members { - select distinct object_id_two - from acs_rels - where object_id_one = :user_id - and rel_type = 'membership_rel' - }] - ns_log notice "dotlrn-ecommerce callback: Adding users ([join $user_ids ,]) in group $user_id" - } else { - set user_ids [list $user_id] - } +} { if { [exists_and_not_null patron_id] } { if { ! [dotlrn::user_p -user_id $patron_id] } { dotlrn::user_add -user_id $patron_id } } - foreach user_id $user_ids { - if { ! [dotlrn::user_p -user_id $user_id] } { - dotlrn::user_add -user_id $user_id + db_foreach items_in_order { + select i.product_id, o.patron_id as saved_patron_id, o.participant_id + from ec_items i, dotlrn_ecommerce_orders o + where i.item_id = o.item_id + and i.order_id = :order_id + group by i.product_id, o.patron_id, o.participant_id + } { + if { [empty_string_p $participant_id] } { + if { [exists_and_not_null user_id] } { + set participant_id $user_id + } else { + continue + } } - # Get community mapped to product - db_foreach communities { - select community_id - from dotlrn_ecommerce_section - where product_id = :product_id - } { - ns_log notice "dotlrn-ecommerce callback: Adding user $user_id to community $community_id" - - if { [catch { + # Check first if user_id is actually a group + if { [acs_object_type $participant_id] == "group" } { + set user_ids [db_list group_members { + select distinct object_id_two + from acs_rels + where object_id_one = :participant_id + and rel_type = 'membership_rel' + }] + ns_log notice "dotlrn-ecommerce callback: Adding users ([join $user_ids ,]) in group $participant_id" + } else { + set user_ids [list $participant_id] + } - dotlrn_community::add_user $community_id $user_id + if { [exists_and_not_null saved_patron_id] } { + if { ! [dotlrn::user_p -user_id $saved_patron_id] } { + dotlrn::user_add -user_id $saved_patron_id + } + } - # Keep track of patron relationships - if { [exists_and_not_null patron_id] } { - if { [db_0or1row member_rel { - select rel_id - from dotlrn_member_rels_full - where community_id = :community_id - and user_id = :user_id - limit 1 - }] } { - set patron_rel_id [db_exec_plsql relate_patron { - select acs_rel__new (null, - 'membership_patron_rel', - :rel_id, - :patron_id, - null, - null, - null) - }] + foreach user_id $user_ids { + if { ! [dotlrn::user_p -user_id $user_id] } { + dotlrn::user_add -user_id $user_id + } + + # Get community mapped to product + db_foreach communities { + select community_id + from dotlrn_ecommerce_section + where product_id = :product_id + } { + ns_log notice "dotlrn-ecommerce callback: Adding user $user_id to community $community_id" + + if { [catch { + + dotlrn_community::add_user $community_id $user_id + + if { ! [exists_and_not_null patron_id] } { + set patron_id $saved_patron_id } - } - } errMsg] } { - # Fixes for possible double click - ns_log notice "dotlrn-ecommerce callback: Probably a double-click: $errMsg" + # Keep track of patron relationships + if { [exists_and_not_null patron_id] } { + if { [db_0or1row member_rel { + select rel_id + from dotlrn_member_rels_full + where community_id = :community_id + and user_id = :user_id + limit 1 + }] } { + set patron_rel_id [db_exec_plsql relate_patron { + select acs_rel__new (null, + 'membership_patron_rel', + :rel_id, + :patron_id, + null, + null, + null) + }] + } + } + + } errMsg] } { + # Fixes for possible double click + ns_log notice "dotlrn-ecommerce callback: Probably a double-click: $errMsg" + } } } } Index: openacs-4/packages/dotlrn-ecommerce/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/index.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn-ecommerce/www/index.tcl 4 Jun 2005 10:05:18 -0000 1.2 +++ openacs-4/packages/dotlrn-ecommerce/www/index.tcl 9 Jun 2005 05:54:38 -0000 1.3 @@ -9,7 +9,6 @@ } set page_title "[_ dotlrn-catalog.course_catalog]" set context "" -set return_url "dt-admin/course-list" set cc_package_id [apm_package_id_from_key "dotlrn-catalog"] @@ -22,7 +21,6 @@ } set tree_id [db_string get_tree_id { } -default "-1"] -set add_course_url [export_vars -base admin/course-add-edit { return_url }] set admin_p [permission::permission_p -object_id $cc_package_id -privilege "admin"] set item_template "one-course?cal_item_id=\$item_id" \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl 31 May 2005 22:04:54 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl 9 Jun 2005 05:54:38 -0000 1.2 @@ -57,6 +57,7 @@ set element_mode "" set aditional_type "" set aditional_elements "" + set help_text "" switch [lindex $attribute 4] { string { if { [string equal [lindex $attribute 2] "assessment_id"]} { @@ -65,6 +66,7 @@ } else { if { [string equal [lindex $attribute 2] "course_key"]} { set element_mode [list mode $mode_p] + set help_text [list help_text "Short name used in URL"] } } } @@ -83,7 +85,7 @@ if { $count > 3 } { append aditional_type ",optional" } - set element [list [lindex $attribute 2]:text${aditional_type} [list label [lindex $attribute 3]] $aditional_elements $element_mode] + set element [list [lindex $attribute 2]:text${aditional_type} [list label [lindex $attribute 3]] $aditional_elements $element_mode $help_text] lappend elements $element incr count @@ -105,6 +107,7 @@ {label "[_ dotlrn-catalog.categories]"} {html {size 4}} {value "$revision_id $cc_package_id"} + {help_text "Hold the <Ctrl> key to select multiple categories"} } } Index: openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.adp 31 May 2005 22:04:54 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.adp 9 Jun 2005 05:54:38 -0000 1.2 @@ -1,6 +1,5 @@ Add Attribute - {course-attributes {Course Attributes}} - {Add Attribute} + {course-attributes {Course Attributes}} {Add Attribute} \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl 4 Jun 2005 10:05:18 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl 9 Jun 2005 05:54:38 -0000 1.4 @@ -19,9 +19,11 @@ set sort_order [expr [llength $attribute_list] + 1] ad_form -name attribute -export {sort_order} -form { - name:text - title:text - {widget:text(select) {options { + {name:text {label "Attribute Name"} + {help_text "Unique key to identify the attribute"} + } + {title:text {label "Title"}} + {widget:text(select) {label "Widget"} {options { {"String (textfield)" string} \ {"Text (textbox)" text} \ {Integer integer} Index: openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp 31 May 2005 22:04:54 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp 9 Jun 2005 05:54:39 -0000 1.2 @@ -3,11 +3,13 @@ @context;noquote@ \ No newline at end of file +
  • Scholarship Funds +
  • Expenses +
  • Process Purchases + Index: openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl 4 Jun 2005 10:05:18 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl 9 Jun 2005 05:54:39 -0000 1.4 @@ -24,4 +24,9 @@ set assistant_community_id [parameter::get -package_id [ad_conn package_id] -parameter AssistantCommunityId -default 0 ] -set assistant_community_url [dotlrn_community::get_community_url $assistant_community_id] \ No newline at end of file +set assistant_community_url [dotlrn_community::get_community_url $assistant_community_id] + +# HAM : check if scholarship is installed +set scholarship_installed_p [apm_package_installed_p "scholarship-fund"] +# HAM : check if expenses is installed +set expenses_installed_p [apm_package_installed_p "expenses"] Index: openacs-4/packages/dotlrn-ecommerce/www/admin/participant-create.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/participant-create.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/participant-create.adp 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,6 @@ + + Create a Participant Account + {Create a Participant Account} + + \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/admin/participant-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/participant-create.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/participant-create.tcl 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,17 @@ +# packages/dotlrn-ecommerce/www/admin/patron-create.tcl + +ad_page_contract { + + + + @author Roel Canicula (roelmc@pldtdsl.net) + @creation-date 2005-05-28 + @arch-tag: 2671f04d-3d9b-4e86-aa34-2dbf0dea6c35 + @cvs-id $Id: participant-create.tcl,v 1.1 2005/06/09 05:54:39 hamiltonc Exp $ +} { + next_url:trim,notnull +} -properties { +} -validate { +} -errors { +} + Index: openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-all.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-all.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-all.adp 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,15 @@ + + @title@ + @context;noquote@ + + +

    + + + + +

    + Or create an account for the purchaser + + Index: openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-all.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-all.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-all.tcl 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,94 @@ +# packages/dotlrn-ecommerce/www/admin/process-purchase.tcl + +ad_page_contract { + + + + @author Roel Canicula (roelmc@pldtdsl.net) + @creation-date 2005-05-19 + @arch-tag: d78f1eb7-313d-4c1a-8f1c-6be5c4f0765a + @cvs-id $Id: process-purchase-all.tcl,v 1.1 2005/06/09 05:54:39 hamiltonc Exp $ +} { + {orderby email_address} + {page 1} + {search:trim ""} + {return_url ""} +} -properties { +} -validate { +} -errors { +} + +set title "Who is paying for the course?" +set context {Process Purchase} + +if { [empty_string_p $search] } { + # Clear shopping cart + set user_session_id [ec_get_user_session_id] + + set order_id [db_string get_order_id "select order_id from ec_orders where user_session_id=:user_session_id and order_state='in_basket'" -default ""] + + if { ! [empty_string_p $order_id] } { + db_dml delete_item_from_cart "delete from ec_items where order_id=:order_id" + } +} + +if { [empty_string_p $return_url] } { + set return_url [export_vars -base [ad_conn package_url]admin/course-info {course_id}] +} + +ad_form -name "search" -export { return_url } -form { + {search:text {label "Search existing users"}} +} + +set add_action "Choose" + +if { ! [empty_string_p $search] } { + + set page_query { + select user_id, email, first_names, last_name + from dotlrn_users + where lower(first_names||' '||last_name||' '||email) like '%'||lower(:search)||'%' + } + + + template::list::create \ + -name "users" \ + -multirow "users" \ + -no_data "No users found" \ + -key user_id \ + -page_query $page_query \ + -page_size 50 \ + -page_flush_p 1 \ + -elements { + user_id { + label "User ID" + } + email { + label "Email Address" + } + first_names { + label "First Name" + } + last_name { + label "Last Name" + } + action { + html { nowrap } + display_template { + $add_action + } + } + } \ + -filters { + search {} + } + + db_multirow -extend { add_member_url } users users [subst { + $page_query + [template::list::page_where_clause -name users -key user_id -and] + }] { + set add_member_url [export_vars -base process-purchase-course { user_id return_url }] + } +} + +set next_url [export_vars -base process-purchase-course { { referer $return_url} }] \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.adp 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,5 @@ + + @title@ + {process-purchase-all {Process Purchase}} {@title@} + + \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,301 @@ +# packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl + +ad_page_contract { + + + + @author Roel Canicula (roelmc@pldtdsl.net) + @creation-date 2005-06-06 + @arch-tag: 8dc760f9-5c1e-4de6-bdb7-382d2eca096d + @cvs-id $Id: process-purchase-course.tcl,v 1.1 2005/06/09 05:54:39 hamiltonc Exp $ +} { + user_id:integer,notnull + + {participant ""} + {participant_id 0} + + {section ""} + {section_id 0} + + purchaser_id:integer,optional,notnull +} -properties { +} -validate { +} -errors { +} + +if { [info exists purchaser_id] } { + set participant_id $user_id + set user_id $purchaser_id + + # We already have everything we need, add to shopping cart +# if { $section_id > 0 } { +# db_1row product { +# select product_id +# from dotlrn_ecommerce_section +# where section_id = :section_id +# } +# ad_returnredirect [export_vars -base "ecommerce/shopping-cart-add" { product_id user_id participant_id {item_count 1} }] +# ad_script_abort +# } +} + +set title "Purchase courses/sections for [person::name -person_id $user_id]" + +set next_url [export_vars -base process-purchase-course { {purchaser_id $user_id} participant participant_id section section_id }] + +if { ! [dotlrn::user_p -user_id $user_id] } { + dotlrn::user_add -user_id $user_id +} + +if { $participant_id } { + if { ! [dotlrn::user_p -user_id $participant_id] } { + dotlrn::user_add -user_id $participant_id + } +} + +set validate [list] + +# Search course or section +set section_list [linsert [db_list_of_lists patrons { + select case when s.section_name is null + then c.course_name + else '... '||s.section_name + end, s.section_id + from dotlrn_catalogi c, (select -course_id as section_id, c.item_id as course_id, course_name, null as section_name + from dotlrn_catalogi c, cr_items i + where c.item_id = i.item_id + and c.course_id = i.live_revision + + union + + select section_id, course_id, null as course_name, section_name + from dotlrn_ecommerce_section + order by course_id, section_name) s, cr_items i + where c.item_id = s.course_id + and c.course_id = i.live_revision + and c.item_id = i.item_id + and + case when :section is null then true + else + case when s.section_name is null then lower(c.course_name) like '%'||lower(:section)||'%' + else lower(c.course_name||' '||s.section_name) like '%'||lower(:section)||'%' end + end + + order by c.course_name, s.section_id +}] 0 {{} 0}] + +ns_log notice "DEBUG:: $section - $section_list" + +if { [llength $section_list] == 1 } { + set form [rp_getform] + ns_set delkey $form __refreshing_p + ns_set put $form __refreshing_p 0 +} + +ad_form -name "participant" -form { + {purchaser:text(inform) {label "Purchaser"} {value "[person::name -person_id $user_id]"}} +} + +if { ( [empty_string_p $section] || [llength $section_list] == 1 ) && ! $section_id } { + set show_all_url [export_vars -base process-purchase-course { user_id participant participant_id {section ""} {section_id -1} }] + ad_form -extend -name "participant" -export { {section_id 0} } -form { + {section:text,optional {label "Search Course/Section"} {html {onchange "if (this.value != '') { this.form.__refreshing_p.value = 1; } else { this.form.__refreshing_p.value = 0 ; }" size 30}} + {help_text "Enter a string to search course and section names"} + {after_html {Show All}} + } + } + + lappend validate {section + { ! [empty_string_p $section] } + "Please enter a search string" + } + lappend validate {section + { [llength $section_list] > 1 } + "No courses/sections found. Please try again" + } +} elseif { $section_id > 0 } { + db_1row section { + select c.course_name, s.section_name + from dotlrn_ecommerce_section s, dotlrn_catalogi c + where s.course_id = c.item_id + and s.section_id = :section_id + limit 1 + } + + set search_url [export_vars -base process-purchase-course { user_id participant participant_id {section ""} {section_id 0} }] + ad_form -extend -name "participant" -export { section section_id } -form { + {section_name:text(inform) {label "Section"} {value "$course_name » $section_name"} + {after_html {Search Again}} + } + } + +} else { + set search_url [export_vars -base process-purchase-course { user_id participant participant_id {section ""} {section_id 0} }] + ad_form -extend -name "participant" -export { section } -form { + {section_id:integer(select),optional {label "Select Section"} {options {$section_list}} + {after_html {Search Again}} + } + + } + + lappend validate {section_id + { $section_id } + "Please select a section from the list" + } + lappend validate {section_id + { $section_id > 0 } + "Please select a section under this course" + } +} + +# Select a participant/participants +set participant_list [linsert [db_list_of_lists participants { + select first_names||' '||last_name||' ('||email||')', user_id + from dotlrn_users + where user_id != :user_id + and (case when :participant is null + then true + else lower(first_names||' '||last_name||' '||email) like '%'||lower(:participant)||'%' end) +}] 0 {{} 0}] + +if { [llength $participant_list] == 1 } { + set form [rp_getform] + ns_set delkey $form __refreshing_p + ns_set put $form __refreshing_p 0 +} + +if { ( [empty_string_p $participant] || [llength $participant_list] == 1 ) && ! $participant_id } { + ad_form -extend -name "participant" -export { {participant_id 0} } -form { + {-section "Individual Purchase"} + {participant_pays_p:boolean(checkbox),optional {label "Search Participant"} {options {{"Participant also pays for the course" t}}} + {help_text "If you select this option, there's no need to select a user below.
    Leave this unchecked for group purchases"} + } + {participant:text,optional {label ""} {html {onchange "if (this.value != '') { this.form.__refreshing_p.value = 1; } else { this.form.__refreshing_p.value = 0 ; }" size 30}} + {help_text "Enter a string to search names and email addresses.
    Or Create an account and return to this form"} + } + {-section "Group Purchase"} + {name:text,optional {label "Group Name"} {html {size 30}}} + {num_members:integer(text),optional {label "Number of attendees"} {html {size 30}}} + } + + lappend validate {participant + { ! [empty_string_p $participant] || [template::element::get_value participant participant_pays_p] == "t" || + (![empty_string_p [template::element::get_value participant name]] && + ![empty_string_p [template::element::get_value participant num_members]]) } + "Please enter a search string" + } + lappend validate {participant + { [llength $participant_list] > 1 || [template::element::get_value participant participant_pays_p] == "t" || + (![empty_string_p [template::element::get_value participant name]] && + ![empty_string_p [template::element::get_value participant num_members]]) } + "No users found. Please try again" + } +} elseif { $participant_id } { + acs_user::get -user_id $participant_id -array participant_user + + set search_url [export_vars -base process-purchase-course { user_id {participant ""} {participant_id 0} section section_id }] + ad_form -extend -name "participant" -export { participant participant_id } -form { + {-section "Individual Purchase"} + {participant_pays_p:boolean(checkbox),optional {label "Participant"} {options {{"Participant also pays for the course" t}}}} + {participant_name:text(inform) {label ""} {value "$participant_user(first_names) $participant_user(last_name) ($participant_user(email))"} + {after_html {Search Again}} + } + {-section "Group Purchase"} + {name:text,optional {label "Group Name"} {html {size 30}}} + {num_members:integer(text),optional {label "Number of attendees"} {html {size 30}}} + } + +} else { + set search_url [export_vars -base process-purchase-course { user_id {participant ""} {participant_id 0} section section_id }] + ad_form -extend -name "participant" -export { participant } -form { + {-section "Individual Purchase"} + {participant_pays_p:boolean(checkbox),optional {label "Select Participant"} {options {{"Participant also pays for the course" t}}}} + {participant_id:integer(select),optional {label ""} {options {$participant_list}} + {help_text "Select a participant from the list. Can't find the participant?
    Create an account and return to this form"} + {after_html {Search Again}} + } + {-section "Group Purchase"} + {name:text,optional {label "Group Name"} {html {size 30}}} + {num_members:integer(text),optional {label "Number of attendees"} {html {size 30}}} + } + + lappend validate {participant_id + { $participant_id || [template::element::get_value participant participant_pays_p] == "t" } + "Please select a participant from the list" + } +} + +set maxparticipants "" +set available_slots 0 +db_0or1row participants { + select v.maxparticipants, s.community_id, s.section_name, c.course_name + from dotlrn_ecommerce_section s, ec_custom_product_field_values v, dotlrn_catalogi c, cr_items ci + where s.product_id = v.product_id + and s.section_id = :section_id + and s.course_id = c.item_id + and ci.live_revision = c.revision_id +} + +if { ![empty_string_p $maxparticipants] } { + db_1row attendees { + select count(*) as attendees + from dotlrn_member_rels_approved + where community_id = :community_id + and (rel_type = 'dotlrn_member_rel' + or rel_type = 'dotlrn_club_student_rel') + } + + set available_slots [expr $maxparticipants - $attendees] +} + +if { [empty_string_p $maxparticipants] } { + lappend validate \ + {num_members + {$num_members > 1 || [empty_string_p $num_members] } + "Please enter a value greater than 1" + } +} else { + lappend validate \ + {num_members + { ($num_members > 1 && $num_members <= $available_slots) || [empty_string_p $num_members] } + "Please enter a value from 2 to $available_slots" + } +} + +ad_form -extend -name "participant" -export { user_id referer } -validate $validate -form { +} -on_submit { + db_1row product { + select product_id + from dotlrn_ecommerce_section + where section_id = :section_id + } + + set item_count 1 + if { $participant_pays_p != "t" && ! [empty_string_p $name] && ! [empty_string_p $num_members] } { + set group_id [db_nextval acs_object_id_seq] + + set unique_group_name "${name}_${group_id}" + group::new -group_id $group_id -group_name $unique_group_name + set section_community_id [db_string get_community_id "select community_id from dotlrn_ecommerce_section where section_id=:section_id" -default ""] + if {[string equal "" $section_community_id]} { + # FIXME error, do something clever here + } + for { set i 1 } { $i <= $num_members } { incr i } { + array set new_user [auth::create_user \ + -username "${name} Attendee $i" \ + -email "[util_text_to_url -text ${name}-attendee-${i}]@example.com" \ + -first_names "$name" \ + -last_name "Attendee $i" \ + -nologin] + + relation_add -member_state approved membership_rel $group_id $new_user(user_id) + } + relation_add relationship $group_id $section_community_id + + set participant_id $group_id + set item_count $num_members + } + + ad_returnredirect [export_vars -base "ecommerce/shopping-cart-add" { product_id user_id participant_id item_count }] + ad_script_abort +} \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/admin/section-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/section-add-edit.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/www/admin/section-add-edit.tcl 4 Jun 2005 10:05:18 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/section-add-edit.tcl 9 Jun 2005 05:54:39 -0000 1.4 @@ -15,6 +15,7 @@ set item_id [dotlrn_catalog::get_item_id -revision_id $course_id] set package_id [ad_conn package_id] +set validate [list] catch { db_1row template_community { @@ -31,11 +32,28 @@ {product_id:integer(hidden)} {return_url:text(hidden) {value $return_url}} {course_id:text(hidden) {value $course_id}} - {section_name:text {label "Section Name"}} - {price:currency,to_sql(sql_number) {label "Regular Price"} {html {size 6}} {section "Product Info"}} } +if { [ad_form_new_p -key section_id] } { + ad_form -extend -name add_section -form { + {section_key:text {label "Section Key"} + {help_text "Short name used in URL"} + } + } + + lappend validate {section_key + { [dotlrn_community::check_community_key_valid_p -community_key $section_key] } + "The section '$section_key' key already exists" + } +} else { +} +ad_form -extend -name add_section -form { + {section_name:text {label "Section Name"}} + {price:currency,to_sql(sql_number) {label "Regular Price"} {html {size 6}} {section "Product Info"}} +} + + # HAM : Let's check if we have MemberPriceP enabled and set # if it is let's add Member Price text if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] } { @@ -149,14 +167,12 @@ ] } else { ad_form -extend -name add_section -form [list \ - [list "${field_identifier}:text(radio),optional" {label $field_name} {value $default_value} {options {{t t} {f f}}}] \ + [list "${field_identifier}:text(radio),optional" {label $field_name} {value $default_value} {options {{Yes t} {No f}}}] \ ] } } # Create the section for predefined sessions -set validate [list] - if { [info exists template_calendar_id] } { set sessions_list [db_list_of_lists sessions { select 'cal_item_id', @@ -228,6 +244,24 @@ }] } +ns_log notice "DEBUG:: $validate" + +lappend validate {price + { ![template::util::negative [template::util::currency::get_property whole_part $price]] } + "Price can not be negative" +} {price + { !"[template::util::currency::get_property whole_part $price].[template::util::currency::get_property fractional_part $price]" == "0.00" } + "Price can not be zero" +} + +if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0] } { + lappend validate {member_price + { ![template::util::negative [template::util::currency::get_property whole_part $member_price]] } + "Member Price can not be negative" + } +} + + ad_form -extend -name add_section -validate $validate -on_request { # Set session times foreach s $sessions_list { @@ -243,6 +277,8 @@ } } -new_request { set product_id 0 + set price [template::util::currency::create "$" "0" "." "00" ] + set member_price [template::util::currency::create "$" "0" "." "00" ] } -edit_request { set course_item_id $course_id db_1row community { @@ -304,12 +340,16 @@ if { [exists_and_not_null template_community_id] } { set community_id [dotlrn_community::clone \ -community_id $template_community_id \ - -key [dotlrn_community::generate_key -name $section_name] \ + -key $section_key \ -pretty_name "$course_data(name): Section $section_name"] ns_log notice "DEBUG:: Cloned $community_id from $template_community_id" } else { - set community_id [dotlrn_club::new -pretty_name "$course_data(name): Section $section_name"] + set community_id [dotlrn_community::new \ + -community_type dotlrn_club \ + -object_type dotlrn_club \ + -community_key $section_key \ + -pretty_name "$course_data(name): Section $section_name"] ns_log notice "DEBUG:: New community created" } Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/finalize-order.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/Attic/finalize-order.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/finalize-order.tcl 4 Jun 2005 10:05:19 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/finalize-order.tcl 9 Jun 2005 05:54:39 -0000 1.2 @@ -34,6 +34,8 @@ ec_redirect_to_https_if_possible_and_necessary +set return_url [export_vars -base "../process-purchase-all"] + # first do all the normal checks to make sure nobody is doing url # or cookie surgery to get here @@ -85,17 +87,7 @@ rp_internal_redirect "../index" ns_log Notice "finalize-order.tcl ref(84): no confirmed order for user $user_id. Redirecting user." } else { - # Redirect to course page - db_1row section { - select c.live_revision as course_id - from ec_items i, dotlrn_ecommerce_section s, cr_items c - where i.product_id = s.product_id - and s.course_id = c.item_id - and i.order_id = :order_id - limit 1 - } - set course_url [export_vars -base ../course-info { course_id }] - ad_returnredirect $course_url + ad_returnredirect .. } ad_script_abort } @@ -115,19 +107,6 @@ ad_script_abort } - -# Redirect to course page -db_1row section { - select c.live_revision as course_id - from ec_items i, dotlrn_ecommerce_section s, cr_items c - where i.product_id = s.product_id - and s.course_id = c.item_id - and i.order_id = :order_id - limit 1 -} -set course_url [export_vars -base ../course-info { course_id }] - - # Make sure the order belongs to this user_id, otherwise they managed # to skip past checkout.tcl, or they messed w/their user_session_id # cookie @@ -211,17 +190,7 @@ ec_update_state_to_confirmed $order_id # Call after-checkout callback - db_foreach products { - select product_id, price_charged - from ec_items - where order_id = :order_id - } { - if { [exists_and_not_null participant_id] } { - callback -- ecommerce::after-checkout -user_id $participant_id -patron_id $user_id -product_id $product_id -price $price_charged - } else { - callback -- ecommerce::after-checkout -user_id $user_id -product_id $product_id -price $price_charged - } - } + callback -- ecommerce::after-checkout -patron_id $user_id -order_id $order_id } # (2) Try to authorize the user's credit card info and either @@ -287,7 +256,7 @@ # 'authorized'. ec_update_state_to_authorized $order_id - ad_returnredirect $course_url + ad_returnredirect $return_url } else { @@ -324,7 +293,7 @@ } if { [string equal $result "authorized"] || [string equal $result "no_recommendation"] } { - ad_returnredirect $course_url + ad_returnredirect $return_url ad_script_abort } elseif { [string equal $result "failed_authorization"] } { @@ -414,7 +383,7 @@ where transaction_id = :pgw_transaction_id" } - ad_returnredirect $course_url + ad_returnredirect $return_url } elseif { [string equal $result "failed_authorization"] || [string equal $result "no_recommendation"] } { @@ -555,7 +524,7 @@ set authorized_date = sysdate where transaction_id = :transaction_id" - ad_returnredirect $course_url + ad_returnredirect $return_url } elseif {[string equal $result "failed_authorization"] || [string equal $result "no_recommendation"] } { @@ -642,7 +611,7 @@ # 'authorized'. ec_update_state_to_authorized $order_id - ad_returnredirect $course_url + ad_returnredirect $return_url } else { @@ -678,7 +647,7 @@ } if { [string equal $result "authorized"] || [string equal $result "no_recommendation"] } { - ad_returnredirect $course_url + ad_returnredirect $return_url ad_script_abort } elseif { [string equal $result "failed_authorization"] } { @@ -751,7 +720,7 @@ # 'authorized'. ec_update_state_to_authorized $order_id - ad_returnredirect $course_url + ad_returnredirect $return_url } else { @@ -805,7 +774,7 @@ set marked_date = sysdate where transaction_id = :pgw_transaction_id" } - ad_returnredirect $course_url + ad_returnredirect $return_url } if {[string equal $result "failed_authorization"] || [string equal $result "no_recommendation"] } { @@ -868,6 +837,6 @@ # 'authorized'. ec_update_state_to_authorized $order_id - ad_returnredirect $course_url + ad_returnredirect $return_url } } Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-add-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/Attic/shopping-cart-add-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-add-postgresql.xql 4 Jun 2005 10:05:19 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-add-postgresql.xql 9 Jun 2005 05:54:39 -0000 1.2 @@ -28,7 +28,7 @@ insert into ec_items (item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date) - select ec_item_id_sequence.nextval, :product_id, :color_choice, + select :item_id, :product_id, :color_choice, :size_choice, :style_choice, :order_id, current_timestamp from dual Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/Attic/shopping-cart-add.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-add.tcl 4 Jun 2005 10:05:19 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-add.tcl 9 Jun 2005 05:54:39 -0000 1.2 @@ -33,7 +33,7 @@ usca_p:optional user_id:integer,notnull - participant_id:integer,optional + {participant_id:integer 0} } # added default values to above params so that this page works # when a post from a form to shopping-cart-add originates from another domain. @@ -49,7 +49,7 @@ # 5. ad_returnredirect them to their shopping cart set user_session_id [ec_get_user_session_id] -ec_create_new_session_if_necessary [export_url_vars product_id] +ec_create_new_session_if_necessary [export_url_vars product_id user_id] set n_confirmed_orders [db_string get_n_confirmed_orders " select count(*) from ec_orders @@ -122,22 +122,22 @@ # That should be enough to protect from double clicks yet provides a # more intuitive user experience. +# Roel: Participant also pays +if { $participant_id == 0 } { + set participant_id $user_id +} for {set i 0} {$i < $item_count} {incr i} { - ns_log notice "DEBUG:: Inserting [expr $i + 1] out of $item_count" - db_dml insert_new_item_in_order { - insert into ec_items - (item_id, product_id, color_choice, size_choice, style_choice, order_id, in_cart_date) - (select ec_item_id_sequence.nextval, :product_id, :color_choice, :size_choice, :style_choice, :order_id, current_timestamp - where not exists (select 1 - from ec_items - where order_id=:order_id - and product_id=:product_id - and color_choice [ec_decode $color_choice "" "is null" "= :color_choice"] - and size_choice [ec_decode $size_choice "" "is null" "= :size_choice"] - and style_choice [ec_decode $style_choice "" "is null" "= :style_choice"] - and (date_part('epoch', now()) - date_part('epoch', in_cart_date) < 5))) + db_transaction { + set item_id [db_nextval ec_item_id_sequence] + + db_dml insert_new_item_in_order {} + + db_dml insert_new_item_order_dotlrn_ecommerce { + insert into dotlrn_ecommerce_orders (item_id, patron_id, participant_id) + values (:item_id, :user_id, :participant_id) + } } } db_release_unused_handles -ad_returnredirect [export_vars -base checkout-one-form { user_id participant_id }] +ad_returnredirect [export_vars -base shopping-cart { user_id product_id }] Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-delete-from.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/Attic/shopping-cart-delete-from.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-delete-from.tcl 4 Jun 2005 10:05:19 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-delete-from.tcl 9 Jun 2005 05:54:39 -0000 1.2 @@ -14,6 +14,7 @@ size_choice:optional style_choice:optional + user_id:integer,notnull } Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/Attic/shopping-cart-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-postgresql.xql 4 Jun 2005 10:05:19 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart-postgresql.xql 9 Jun 2005 05:54:39 -0000 1.2 @@ -20,16 +20,17 @@ - select p.product_name, p.one_line_description, p.no_shipping_avail_p, p.shipping, p.shipping_additional, p.weight, p.product_id, count(*) as quantity, u.offer_code, i.color_choice, i.size_choice, i.style_choice, '' as price + select p.product_name, p.one_line_description, p.no_shipping_avail_p, p.shipping, p.shipping_additional, p.weight, p.product_id, count(*) as quantity, u.offer_code, i.color_choice, i.size_choice, i.style_choice, '' as price, deo.patron_id, deo.participant_id from ec_orders o join ec_items i on (o.order_id=i.order_id) join ec_products p on (i.product_id=p.product_id) left join (select product_id, offer_code from ec_user_session_offer_codes usoc where usoc.user_session_id=:user_session_id) u on (p.product_id=u.product_id) + left join dotlrn_ecommerce_orders deo on (i.item_id = deo.item_id) where o.user_session_id=:user_session_id and o.order_state='in_basket' - group by p.product_name, p.one_line_description, p.no_shipping_avail_p, p.shipping, p.shipping_additional, p.weight, p.product_id, u.offer_code, i.color_choice, i.size_choice, i.style_choice + group by p.product_name, p.one_line_description, p.no_shipping_avail_p, p.shipping, p.shipping_additional, p.weight, p.product_id, u.offer_code, i.color_choice, i.size_choice, i.style_choice, deo.patron_id, deo.participant_id Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/Attic/shopping-cart.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart.tcl 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,344 @@ +ad_page_contract { + @param usca_p User session begun or not + + @author + @creation-date + @author ported by Jerry Asher (jerry@theashergroup.com) + @author revised by Bart Teeuwisse (bart.teeuwisse@thecodemill.biz) + @revision-date April 2002 + +} { + usca_p:optional + product_id:optional + + user_id:integer,notnull,optional +} + +# bottom links: +# 1) continue shopping (always) + +# Case 1) Continue shopping +# Create the link now before the product_id gets overwritten when +# looping through the products in the cart. + +set previous_product_id_p 0 +set previous_product_id 0 + +if {[info exists product_id]} { + set previous_product_id_p 1 + set previous_product_id $product_id +} + +# We don't need them to be logged in, but if they are they might get a +# lower price +set first_names "" +set last_name "" +set email "" + +if { ! [info exists user_id] } { + set user_id [ad_verify_and_get_user_id] +} +if { $user_id != 0 } { + db_1row user_info { + select first_names, last_name, email + from dotlrn_users where user_id = :user_id + } +} + +# user sessions: +# 1. get user_session_id from cookie +# 2. if user has no session (i.e. user_session_id=0), attempt to set it if it hasn't been +# attempted before +# 3. if it has been attempted before, give them message that we can't do shopping carts +# without cookies + +set user_session_id [ec_get_user_session_id] +ec_create_new_session_if_necessary [export_url_vars user_id] + +# This is not being used anywhere +#set n_items_in_cart [db_string get_n_items " +# select count(*) +# from ec_orders o, ec_items i +# where o.order_id=i.order_id +# and o.user_session_id=:user_session_id and o.order_state='in_basket'"] + +# calculate shipping charge options when not using shipping-gateway, +# and then include the value with each option (for an informed choice) + +# mainly from process-order-quantity-shipping.tcl + +# set initial values for itemization loop +db_1row get_ec_admin_settings " + select nvl(base_shipping_cost,0) as base_shipping_cost, + nvl(default_shipping_per_item,0) as default_shipping_per_item, + nvl(weight_shipping_cost,0) as weight_shipping_cost, + nvl(add_exp_base_shipping_cost,0) as add_exp_base_shipping_cost, + nvl(add_exp_amount_per_item,0) as add_exp_amount_per_item, + nvl(add_exp_amount_by_weight,0) as add_exp_amount_by_weight + from ec_admin_settings" + +set last_product_id 0 +set product_counter 0 +set total_price 0 +set currency [parameter::get -parameter Currency] +set max_add_quantity_length [string length [parameter::get -parameter CartMaxToAdd]] +set offer_express_shipping_p [parameter::get -parameter ExpressShippingP] +set offer_pickup_option_p [parameter::get -parameter PickupP] +set total_reg_shipping_price 0 +set total_exp_shipping_price 0 +set no_shipping_options "t" +# Check if a shipping gateway has been selected. +set shipping_gateway [parameter::get -parameter ShippingGateway] +set shipping_gateway_in_use [acs_sc_binding_exists_p ShippingGateway $shipping_gateway] +set shipping_address_id 0 + +if { $shipping_gateway_in_use} { + #this section mainly from select-shipping.tcl + + # Replace the default ecommerce shipping calculations with the + # charges from the shipping gateway, which contains + # both the shipping service level and the associated total + # charges. Requries zipcode and country, so + # user needs to be logged in too. + + if { $user_id != 0 } { + set shipping_address_ids [db_list get_shipping_address_ids " + select address_id + from ec_addresses + where user_id=:user_id + and address_type = 'shipping'" ] + + if { [llength $shipping_address_ids] > 1 } { + # the max valued id is most likely the newest id (no last used date field available) + set shipping_address_id [ec_max_of_list $shipping_address_ids] + } elseif { $shipping_address_ids > 0 } { + set shipping_address_id $shipping_address_ids + } else { + set shipping_address_id 0 + set shipping_options "

    We need your shipping address before we can quote a shipping price. You are able to review your order and any shipping charges before confirming an order.

    " + } + if { $shipping_address_id > 0 } { + # we have a zipcode and country + db_1row select_shipping_area " + select country_code, zip_code + from ec_addresses + where address_id = :shipping_address_id" + + # Calculate the total value of the shipment. + set shipment_value 0 + } + } else { + # user_id == 0 + set shipping_options "

    If you were logged in, we could show you any associated shipping charges

    " + } +} + + +# adding some fields to handle calculating shipping prices +# p.no_shipping_avail_p, p.shipping, p.shipping_additional, p.weight +# basically collect shipping information for any items where ec_products.no_shipping_avail_p = 't' + +db_multirow -extend { line_subtotal patron_name participant_name participant_type } in_cart get_products_in_cart " + select p.product_name, p.one_line_description, p.no_shipping_avail_p, p.shipping, p.shipping_additonal, p.weight, p.product_id, count(*) as quantity, u.offer_code, i.color_choice, i.size_choice, i.style_choice, '' as price + from ec_orders o + join ec_items i on (o.order_id=i.order_id) + join ec_products p on (i.product_id=p.product_id) + left join (select product_id, offer_code + from ec_user_session_offer_codes usoc + where usoc.user_session_id=:user_session_id) u on (p.product_id=u.product_id) + where o.user_session_id=:user_session_id + and o.order_state='in_basket' + group by p.product_name, p.one_line_description, p.no_shipping_avail_p, p.shipping, p.shipping_additional, p.weight, p.product_id, u.offer_code, i.color_choice, i.size_choice, i.style_choice" { + set line_subtotal "$quantity" + if { ! [empty_string_p $patron_id] } { + set patron_name [person::name -person_id $patron_id] + } + if { ! [empty_string_p $participant_id] } { + set participant_type [acs_object_type $participant_id] + if { $participant_type == "user" } { + set participant_name [person::name -person_id $participant_id] + } else { + group::get -group_id $participant_id -array group + } + } + } + +for {set i 1} {$i <= [template::multirow size in_cart]} {incr i} { + + set product_name [template::multirow get in_cart $i product_name] + set one_line_description [template::multirow get in_cart $i one_line_description] + set product_id [template::multirow get in_cart $i product_id] + set no_shipping_avail_p [template::multirow get in_cart $i no_shipping_avail_p] + set shipping [template::multirow get in_cart $i shipping] + set shipping_additional [template::multirow get in_cart $i shipping_additional] + set weight [template::multirow get in_cart $i weight] + set quantity [template::multirow get in_cart $i quantity] + set offer_code [template::multirow get in_cart $i offer_code] + set color_choice [template::multirow get in_cart $i color_choice] + set size_choice [template::multirow get in_cart $i size_choice] + set style_choice [template::multirow get in_cart $i style_choice] + + set max_quantity_length [max $max_add_quantity_length [string length $quantity]] + # Deletions are done by product_id, color_choice, size_choice, + # style_choice, not by item_id because we want to delete the + # entire quantity of that product. Also print the price for a + # product of the selected options and the aforementioned delete + # option. + + set price_line [ec_price_line $product_id $user_id $offer_code] + set delete_export_vars [export_url_vars product_id color_choice size_choice style_choice user_id] + + # Too bad I have to do another call to get the price. That is + # because ec_price_line returns canned html instead of the price. + + set lowest_price_and_price_name [ec_lowest_price_and_price_name_for_an_item $product_id $user_id $offer_code] + set lowest_price [lindex $lowest_price_and_price_name 0] + + + # Calculate line subtotal for end users + set line_subtotal [ec_pretty_price [expr $quantity * $lowest_price] $currency] + template::multirow set in_cart $i line_subtotal $line_subtotal + + if { [string equal $no_shipping_avail_p "f"] && !$shipping_gateway_in_use} { + # at least one thing is shippable, begin calculating ship value(s) + set no_shipping_options "f" + + # Calculate shipping for line item + set first_instance 1 + set shipping_prices_for_first_line_item [ec_shipping_prices_for_one_item_by_rate $product_id $shipping $shipping_additional $default_shipping_per_item $weight $weight_shipping_cost $first_instance $add_exp_amount_per_item $add_exp_amount_by_weight] + set total_reg_shipping_price [expr $total_reg_shipping_price + [lindex $shipping_prices_for_first_line_item 0]] + set total_exp_shipping_price [expr $total_exp_shipping_price + [lindex $shipping_prices_for_first_line_item 1]] + + if { $quantity > 1 } { + set first_instance 0 + set shipping_prices_for_more_line_items [ec_shipping_prices_for_one_item_by_rate $product_id $shipping $shipping_additional $default_shipping_per_item $weight $weight_shipping_cost $first_instance $add_exp_amount_per_item $add_exp_amount_by_weight] + set total_reg_shipping_price [expr $total_reg_shipping_price + ( [lindex $shipping_prices_for_more_line_items 0] * ( $quantity - 1 ) ) ] + set total_exp_shipping_price [expr $total_exp_shipping_price + ( [lindex $shipping_prices_for_more_line_items 1] * ( $quantity - 1 ) ) ] + + } + } elseif { $shipping_gateway_in_use && $shipping_address_id > 0 && [string equal $no_shipping_avail_p "f"] } { + set shipment_value [expr $shipment_value + [lindex [ec_lowest_price_and_price_name_for_an_item $product_id $user_id $offer_code] 0]] + } + + # Add the price of the item to the total price + + set total_price [expr $total_price + ($quantity * $lowest_price)] + incr product_counter $quantity + + template::multirow set in_cart $i delete_export_vars $delete_export_vars + template::multirow set in_cart $i price "[lindex $lowest_price_and_price_name 1]:  [ec_pretty_price [lindex $lowest_price_and_price_name 0] $currency]" + +} + +# Add adjust quantities line if there are products in the cart. +set pretty_total_price [ec_pretty_price $total_price $currency] + +if { $shipping_gateway_in_use && $shipping_address_id > 0} { + + set weight_unit_of_measure [parameter::get -parameter WeightUnits] + + set shipping_options "" + + # Get the list of services and their charges + + set rates_and_services [lsort -index 1 -real \ + [acs_sc_call "ShippingGateway" "RatesAndServicesSelection" \ + [list "" "" "$country_code" "$zip_code" "$shipment_value" "$currency" "" "$weight_unit_of_measure"] "$shipping_gateway"]] + + # Present the available shipping services to the user + + foreach service $rates_and_services { + array set rate_and_service $service + set total_charges $rate_and_service(total_charges) + set service_code $rate_and_service(service_code) + set service_description [acs_sc_call "ShippingGateway" "ServiceDescription" "$service_code" "$shipping_gateway"] + set gateway_shipping_default_price $total_charges + append shipping_options " + " + } + append shipping_options "
    Shipping method:

    + $service_description + + [string map {USD $} $currency] + + $total_charges +
    " +} + +if { !$shipping_gateway_in_use } { + # Rate based shipping calculations + # 3. Determine base shipping costs that are separate from items + + # set base shipping charges + set order_shipping_cost $base_shipping_cost + set shipping_method_standard $order_shipping_cost + + # Add on the extra base cost for express shipping + set shipping_method_express [expr $order_shipping_cost + $add_exp_base_shipping_cost] + + # 4. set total costs for each shipping option + set total_shipping_price_default $total_reg_shipping_price + set total_reg_shipping_price [ec_pretty_price [expr $total_reg_shipping_price + $shipping_method_standard] $currency "t"] + set total_exp_shipping_price [ec_pretty_price [expr $total_exp_shipping_price + $shipping_method_express] $currency "t"] + set shipping_method_pickup [ec_pretty_price 0 $currency "t"] + set shipping_method_no_shipping 0 + + # 5 prepare shipping options to present to user + if { [string equal $no_shipping_options "f" ] } { + + # standard shipping is total_reg_shipping_price + set shipping_options "Shipping is addtional:" + if { $offer_express_shipping_p } { + # express shipping is total_exp_shipping_price + set shipping_options "Shipping is additional, choices are:" + } + if { $offer_pickup_option_p } { + # pickup instead of shipping is shipping_method_pickup + set shipping_options "Shipping is additional, choices are:" + } + } else { + set shipping_options "No shipping options available." + } +} + +# List the states that get charged tax. Although not 100% accurate +# as shipping might be taxed too this is better than nothing. + +db_multirow -extend { pretty_tax } tax_entries tax_states " + select tax_rate, initcap(state_name) as state + from ec_sales_tax_by_state tax, us_states state + where state.abbrev = tax.usps_abbrev" { + set pretty_tax "[format %0.2f [expr $tax_rate * 100]]%" +} + +# bottom links: +# 1) continue shopping (always and already created) +# 2) log in (if they're not logged in) +# 3) retrieve a saved cart (if they are logged in and they have a saved cart) +# 4) save their cart (if their cart is not empty) + +if { $user_id == 0 } { + + # Case 2) the user is not logged in. + set return_url [ns_urlencode "[ec_url]"] + +} else { + # Case 3) Retrieve saved carts + set saved_carts_p [db_string check_for_saved_carts " + select 1 + from dual + where exists ( + select 1 + from ec_orders + where user_id=:user_id + and order_state='in_basket' + and saved_p='t')" -default ""] +} + +set context_bar [template::adp_parse [acs_root_dir]/packages/[ad_conn package_key]/www/contextbar [list context_addition [list "Shopping Cart"]]] +set context [list [list [export_vars -base ../process-purchase-course { user_id }] "Process Purchase"] "Shopping Cart"] +set ec_system_owner [ec_system_owner] +db_release_unused_handles + +ad_return_template Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/Attic/shopping-cart.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/shopping-cart.xql 9 Jun 2005 05:54:39 -0000 1.1 @@ -0,0 +1,40 @@ + + + + + + + select count(*) + from ec_orders o, ec_items i + where o.order_id=i.order_id + and o.user_session_id=:user_session_id and o.order_state='in_basket' + + + + + + + select address_id + from ec_addresses + where user_id=:user_id + and address_type = 'shipping' + + + + + + select country_code, zip_code + from ec_addresses + where address_id = :shipping_address_id + + + + + + select tax_rate, initcap(state_name) as state + from ec_sales_tax_by_state tax, us_states state + where state.abbrev = tax.usps_abbrev + + + +