Skip to content
Permalink
Browse files

Many UI improvements. Add permissions checks to asm-admin pages that

were missing them!
Change type from an integer that has no meaning to a string, that might
give you a clue what it means. TODO change type to refer to a "template"
assessment_id with all the default values set so an admin can manage
types.
  • Loading branch information
tdxdave committed Sep 26, 2006
1 parent abf9b45 commit 433463faf6d50140fe26f848ab2f28662e0acc85
@@ -1,5 +1,5 @@
ad_page_contract {

e
This page allows to display an assessment with sections and items

@author Eduardo Pérez Ureta (eperez@it.uc3m.es)
@@ -13,7 +13,7 @@ ad_page_contract {
{item_order:integer,optional ""}
{item_id ""}
{return_url:optional}
response_to_item:array,optional,multiple,html
response_to_item:array,optional,multiple
{next_asm:optional}
{response:multiple,optional}
{next_url ""}
@@ -1,18 +1,17 @@
<if @has_permission_p@>
<h3>Comments</h3>
<h2>Reviewer Comments</h2>
<if @comments:rowcount@ gt 0>
<multiple name="comments">
<p />
<b>@comments.title@</b> <a href="@comments.edit_url@">Edit</a>
<br /><br />
<b>@comments.title@</b> <a href="@comments.edit_url@"></a>
<br />
@comments.html_content;noquote@
<br /><br />
<br />
- @comments.author@ (on @comments.creation_date_ansi@)
</multiple>
</if>
<else>
<i>No comments.</i>
<i>No reviewer comments have been added to this assessment yet.</i>
</else>
<br /><br />
<br />
<a href="@comment_add_url@" class="button">Add comment<a/>
</if>
@@ -1,9 +1,5 @@
<if @results:rowcount@ gt 0>
<ul>
<multiple name="results">
<li><if @results.title@ not nil><i>@results.title@</i><br></if>
@results.description@<br>
<b>@results.points@ #assessment.points#</b> #assessment.Results_change_display#</li>
</multiple>
</ul><br>
<li>@results.description@ #assessment.Results_change_display#</li>
</multiple>
</if>
@@ -1,9 +1,10 @@
# Display all change messages for result points
# author Timo Hentschel (timo@timohentschel.de)

set format "[lc_get formbuilder_date_format], [lc_get formbuilder_time_format]"
set format "[lc_get d_fmt], [lc_get t_fmt]"

db_multirow -extend {user_url} results result_changes {
} {
set creation_date [lc_time_fmt $creation_date $format]
set user_url [acs_community_member_url -user_id $creation_user]
}
@@ -5,7 +5,7 @@
<querytext>

select cr.title, cr.description, sr.points, p.first_names, p.last_name,
to_char(o.creation_date, :format) as create_date, o.creation_user
o.creation_date, o.creation_user
from as_session_results sr, cr_revisions cr, acs_objects o, persons p,
as_item_data d, as_session_item_map m
where cr.revision_id = sr.result_id
@@ -1,53 +1,22 @@
<formtemplate id="session_results_@section_id@">
<table cellspacing=0>
<if @items:rowcount@ eq 0>
<tr><td>#assessment.not_answered#</td></tr>
#assessment.not_answered#
</if>

<ul>
<multiple name="items">
<if @feedback_only_p@ eq 0 or @items.has_feedback_p@ eq 1>

<tr>

<td valign="top"><if @show_item_name_p@ eq t><b>@items.name@:</b></if></td>
<td>&nbsp;</td></tr>

<tr>

<td>
<if @survey_p@ ne t and @items.title@ ne @items.next_title@>
<if @items.max_time_to_complete@ not nil> (#assessment.max_time# @items.max_time_to_complete@) </if>
<if @items.result_points@ not nil><if @showpoints@ eq 1><b>@items.result_points@ / @items.points@ #assessment.points#</if>
<if @show_feedback@ ne none>
<if @items.feedback@ not nil>: @items.feedback;noquote@</if>
</if>
<li><if @feedback_only_p@ eq 0 or @items.has_feedback_p@ eq 1>
<if @show_item_name_p@ eq t><b>@items.name@:</b></if>
<if @survey_p@ ne t and @items.title@ ne @items.next_title@>
<if @items.max_time_to_complete@ not nil> (#assessment.max_time# @items.max_time_to_complete@) </if>
</b>
</if>
<else>
<if @items.answered_p@ eq t><b>#assessment.not_yet_reviewed#</b> </if>
<else><b>#assessment.not_answered#</b> </else>
</else>
<if @edit_p@ eq 1 and @items.answered_p@ eq t><a href="results-edit?session_id=@session_id@&section_id=@section_id@&as_item_id=@items.as_item_id@">#assessment.Edit#</a></if>
<include src="/packages/assessment/lib/results-messages" session_id="@session_id@" section_id="@section_id@" as_item_id="@items.as_item_id@">
</if>
</td><td>&nbsp;</td></tr>
</if>
</if>

<tr>
<td>
<if @items.presentation_type@ ne fitb>
<b>@items.title;noquote@</b>
@items.content;noquote@
<if @items.correct_p eq 1><if @show_feedback@ eq correct or @show_feedback@ eq all><br />@items.feedback_right;noquote@</if></if>
<if @items.correct_p@ eq 0><if @show_feedback@ eq all or @show_feedback@ eq incorrect><br />@items.feedback_wrong;noquote@</if></if>
</td><td>
<if @items.title@ ne @items.next_title@>
</td></tr>

<tr>
<td colspan=2>
</if>
<br />
</if>
<table>
<group column=title>
<td valign=top>@items.description;noquote@
<if @survey_p@ ne t>
@@ -74,7 +43,6 @@
<include src="/packages/assessment/lib/results-messages" session_id="@session_id@" section_id="@section_id@" as_item_id="@items.as_item_id@">
</if>
</if>
</td>
<if @items.presentation_type@ eq rb or @items.presentation_type@ eq cb>
<fieldset class="radio">
<if @items.choice_orientation@ ne horizontal>
@@ -103,18 +71,24 @@
<a href= "@items.view@" onclick= "var w=window.open(this.href, 'newWindow', 'width=650,height=400'); return !w;"><formwidget id="response_to_item.@items.as_item_id@"></a>
</elseif>
<else>
<td colspan=10><formwidget id="response_to_item.@items.as_item_id@">
<formwidget id="response_to_item.@items.as_item_id@">
</else>
<if @items.subtext@ not nil>
<div class="form-help-text">
<img src="/shared/images/info.gif" width="12" height="9" alt="[i]" title="Help text" border="0">
<noparse>@items.subtext@</noparse>
</div>
</if>
</td></tr>
</group></table>
</td></tr>
</group>
</if>
<if @items.correct_p eq 1><if @show_feedback@ eq correct or @show_feedback@ eq all>@items.feedback_right;noquote@</if></if>
<if @items.correct_p@ eq 0><if @show_feedback@ eq all or @show_feedback@ eq incorrect>@items.feedback_wrong;noquote@</if></if>
<ul> <include src="/packages/assessment/lib/results-messages" session_id="@session_id@" section_id="@section_id@" as_item_id="@items.as_item_id@" &=assessment> <if @edit_p@ eq 1 and @items.answered_p@ eq t><li><a href="results-edit?session_id=@session_id@&section_id=@section_id@&as_item_id=@items.as_item_id@">#assessment.Add_Comment#</a></li></if>
<!-- FIXME TODO move points to indented block with comments -->
<if @assessment_data.type@ ne survey and @items.result_points@ not nil and @showpoints@ eq 1><li><b>@items.result_points@ / @items.points@ #assessment.points#</b></li></if>
</ul>
</li>
<hr>
</multiple>
</table>
</ul>
</formtemplate>
@@ -5,7 +5,7 @@
<tr>
<th colspan="3" align=left>#assessment.Assessment#: <a href="assessment?assessment_id=@assessment_id@">@assessment_data.title@</a></th></tr>
<tr><td nowrap><b>#assessment.User_ID#:</b> <span><if @show_username_p@><a href="@session_user_url@">@first_names@ @last_name@</a><if @assessment_data.anonymous_p@ eq "t"><br />#assessment.lt_bNoteb_This_assessmen#</if></if><else>#assessment.anonymous_name#</else></span></td>
<td nowrap><b>#assessment.Attempt#:</b> <span><a href="sessions?assessment_id=@assessment_id@&subject_id=@subject_id@">@session_attempt@</a><if @assessment_data.number_tries@ not nil> / @assessment_data.number_tries@</if></span></td>
<td nowrap><b>#assessment.Attempt#:</b> <multiple name="session_attempts"><if @session_attempts.session_id@ eq @session_id@><b>@session_attempts.rownum@</b></if><else><a href="session?session_id=@session_attempts.session_id@">@session_attempts.rownum@</a></else>&nbsp;&nbsp; </multiple></td>
<td nowrap><if @assessment_data.survey_p@ ne t> <if @showpoints@ eq 1> <b>#assessment.Percent_Score#:</b> <span>@percent_score@</span></if></if> </td></tr>

<tr><td><b>#assessment.Started#:</b> <span>@session_start@</span></td>
@@ -6,12 +6,23 @@ ad_page_contract {
@date 2004-12-24
@cvs-id $Id:
} {
session_id:integer
{session_id:integer 0}
{assessment_id:integer 0}
{next_url ""}
} -properties {
context_bar:onevalue
page_title:onevalue
}
set user_id [ad_conn user_id]
if {$session_id == 0} {
# require assessment_id if session_id is blank
if {$assessment_id == 0} {
ad_return_complaint 1 "Session_id or Assessment_id is required"
}
#find the latest session
db_1row get_latest_session "" -column_array latest_session
set session_id $latest_session(session_id)
}

db_1row find_assessment {}

@@ -24,7 +35,6 @@ if {![info exists assessment_data(assessment_id)]} {
ad_script_abort
}

set user_id [ad_conn user_id]
if {$subject_id != $user_id} {
permission::require_permission -object_id $assessment_id -privilege admin
}
@@ -39,8 +49,8 @@ db_1row session_data {}
set session_time [as::assessment::pretty_time -seconds $session_time -hours]

# get the number of attempts
set session_attempt [db_string session_attempt {}]

db_multirow session_attempts session_attempts {}
set show_username_p 1
# only admins are allowed to see responses of other users
if {$assessment_data(anonymous_p) == "t" && $subject_id != $user_id} {
@@ -12,13 +12,14 @@
</querytext>
</fullquery>

<fullquery name="session_attempt">
<fullquery name="session_attempts">
<querytext>
select count(*)
select session_id
from as_sessions s, cr_revisions r
where s.subject_id = :subject_id
and s.assessment_id = r.revision_id
and r.item_id = :assessment_id
order by last_mod_datetime
</querytext>
</fullquery>

@@ -40,4 +41,17 @@
</querytext>
</fullquery>

<fullquery name="get_latest_session">
<querytext>
select max(o.creation_date), s.session_id
from as_sessions s,
acs_objects o,
cr_revisions cr
where s.subject_id=:user_id
and s.assessment_id=(select latest_revision from cr_items where item_id=:assessment_id)
and o.object_id = cr.item_id
and s.session_id = cr.revision_id
group by s.session_id
</querytext>
</fullquery>
</queryset>
@@ -7,4 +7,12 @@
--

update cr_revisions set content=title where item_id in (select item_id from cr_items where content_type='as_items');
update cr_items set storage_type='lob' where content_type='as_items';
update cr_items set storage_type='lob' where content_type='as_items';

alter table as_assessments rename type to type_int;
alter table as_assessments add type varchar2(1000);
update as_assessments set type='survey' where type_int = 1;
update as_assessments set type='test' where type_int = 2;
alter table as_assessments drop type_int;
update acs_attributes set datatype='string' where attribute_name='type' and object_type='as_assessments';

@@ -7,4 +7,12 @@
--

update cr_revisions set content=title where item_id in (select item_id from cr_items where content_type='as_items');
update cr_items set storage_type='text' where content_type='as_items';
update cr_items set storage_type='text' where content_type='as_items';

alter table as_assessments rename type to type_int;
alter table as_assessments add type varchar(1000);
update as_assessments set type='survey' where type_int = 1;
update as_assessments set type='test' where type_int = 2;
alter table as_assessments drop type_int;
update acs_attributes set datatype='string' where attribute_name='type' and object_type='as_assessments';

@@ -172,9 +172,8 @@ content::type::attribute::new -content_type {as_assessments} -attribute_name {ip
content::type::attribute::new -content_type {as_assessments} -attribute_name {password} -datatype {string} -pretty_name {Password} -column_spec {varchar(100)}
content::type::attribute::new -content_type {as_assessments} -attribute_name {show_feedback} -datatype {string} -pretty_name {Assessment Show comments to the user} -column_spec {varchar(50)}
content::type::attribute::new -content_type {as_assessments} -attribute_name {section_navigation} -datatype {string} -pretty_name {Assessment Navigation of sections} -column_spec {varchar(50)}
content::type::attribute::new -content_type {as_assessments} -attribute_name {survey_p} -datatype {string} -pretty_name {Survey} -column_spec {char(1)}
content::type::attribute::new -content_type {as_assessments} -attribute_name {type} -datatype {number} -pretty_name {Type} -column_spec {integer}

# survey_p is replaced by type
content::type::attribute::new -content_type {as_assessments} -attribute_name {type} -datatype {string} -pretty_name {Type} -column_spec {varchar(1000)}

# Sessions
content::type::attribute::new -content_type {as_sessions} -attribute_name {assessment_id} -datatype {number} -pretty_name {Assessment ID} -column_spec {integer}
@@ -139,7 +139,7 @@ namespace eval as::list {
(:as_item_id_$option_item_id is null
or
exists (select 1
from as_itemsi ii, as_item_data dd,
from as_items ii, as_item_data dd,
(select oi.object_type, it.item_rev_id as as_item_id
from as_item_rels it, as_item_rels dt, acs_objects oi
where dt.item_rev_id = it.item_rev_id
@@ -148,7 +148,7 @@ namespace eval as::list {
and oi.object_id = it.target_rev_id) tt,
cr_items ci

where ii.item_id = $option_item_id
where ci.item_id = $option_item_id
and ii.as_item_id = dd.as_item_id
and ii.as_item_id = tt.as_item_id
and dd.session_id = m.session_id
@@ -160,7 +160,6 @@ namespace eval as::list {
}
}

ns_log notice "as_list_filters returning '[list list_filters $list_filters assessment_search_options $assessment_search_options search_js_array $search_js_array]'"
return [list list_filters $list_filters assessment_search_options $assessment_search_options search_js_array $search_js_array]
}

@@ -301,7 +300,7 @@ namespace eval as::list {
(:as_item_id_$option_item_id is null
or
exists (select 1
from as_itemsi ii, as_item_data dd,
from as_items ii, as_item_data dd,
(select oi.object_type, it.item_rev_id as as_item_id
from as_item_rels it, as_item_rels dt, acs_objects oi
where dt.item_rev_id = it.item_rev_id
@@ -310,7 +309,7 @@ namespace eval as::list {
and oi.object_id = it.target_rev_id) tt,
cr_items ci

where ii.item_id = $option_item_id
where ci.item_id = $option_item_id
and ii.as_item_id = dd.as_item_id
and ii.as_item_id = tt.as_item_id
and dd.session_id = m.session_id
@@ -17,33 +17,32 @@ ad_proc -public as::session_results::new {
@creation-date 2005-02-17

New as_session_results

} {
if {$package_id eq ""} {
set package_id [ad_conn package_id]
}
ns_log notice "session results new package_id = '${package_id}'"
# ns_log notice "session results new package_id = '${package_id}'"
set folder_id [as::assessment::folder_id -package_id $package_id]

# Insert as_session_results in the CR (and as_session_results table) getting the revision_id
set transaction_successful_p 0

while { ! $transaction_successful_p } {
db_transaction {
# db_transaction {
if {![db_0or1row result_exists {}]} {
set result_item_id [content::item::new -parent_id $folder_id -content_type {as_session_results} -name [as::item::generate_unique_name]]
}
ns_log notice "DAVEB101 session rsults new new item $result_item_id"
}
ns_log notice "DAVEB101 session rsults new new revision $result_item_id"
set result_id [content::revision::new \
-item_id $result_item_id \
-content_type {as_session_results} \
-title $title \
-description $description \
-attributes [list [list target_id $target_id] \
[list points $points] ] ]
set transaction_successful_p 1
} on_error {
ns_log notice "as::session_results::new: Transaction Error: $errmsg"
}
}
# } on_error {
# ns_log notice "as::session_results::new: Transaction Error: $errmsg"
# }

return $result_id
}

0 comments on commit 433463f

Please sign in to comment.
You can’t perform that action at this time.