logicampus-cvs Mailing List for Logicampus (Page 3)
Brought to you by:
trilexcom
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(77) |
Oct
(33) |
Nov
(29) |
Dec
(5) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(36) |
Feb
(33) |
Mar
(5) |
Apr
(2) |
May
(7) |
Jun
(3) |
Jul
|
Aug
(2) |
Sep
(8) |
Oct
(1) |
Nov
(136) |
Dec
(30) |
2007 |
Jan
(64) |
Feb
(103) |
Mar
(29) |
Apr
(106) |
May
(185) |
Jun
(75) |
Jul
(3) |
Aug
(16) |
Sep
(154) |
Oct
(164) |
Nov
(26) |
Dec
|
2008 |
Jan
(15) |
Feb
(17) |
Mar
(32) |
Apr
(3) |
May
|
Jun
(4) |
Jul
|
Aug
(4) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
2009 |
Jan
|
Feb
(21) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2010 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Mark K <har...@us...> - 2008-03-02 22:42:08
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10894/services/classmgr Modified Files: restoreBackup.lcp Log Message: don't double import learning object with a matching GUID. Index: restoreBackup.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/restoreBackup.lcp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** restoreBackup.lcp 2 Mar 2008 22:29:24 -0000 1.4 --- restoreBackup.lcp 2 Mar 2008 22:42:02 -0000 1.5 *************** *** 144,155 **** } $lobRepoObj = Lc_Lob_Xml::parseNode($node, $tempdir); ! $lobRepoObj->save(); //link to this user; ! $lobUserObj = new LobUserLink(); ! $lobUserObj->set('lobRepoEntryId',$lobRepoObj->getRepoId()); ! $lobUserObj->set('userId',$u->userId); ! $lobUserObj->set('isOwner','1'); ! $lobUserObj->save(); $classObj = $lobRepoObj->useInClass($classId); --- 144,167 ---- } $lobRepoObj = Lc_Lob_Xml::parseNode($node, $tempdir); ! //don't save this object if the GUID is already present in the DB ! $existingLob = LobRepoEntry::load( array('lob_guid'=>$lobRepoObj->repoObj->lobGuid) ); ! if (is_object($existingLob) ) { ! $lobRepoObj->repoObj->lobRepoEntryId = $existingLob->lobRepoEntryId; ! $lobRepoObj->_isNew = false; ! } else { ! $lobRepoObj->save(); ! } //link to this user; ! $lobUserObj = LobUserLink::load( array('lob_repo_entry_id'=>$lobRepoObj->getRepoId(), 'user_id' => $u->userId)); ! if (is_object($lobUserObj) ) { ! //do nothing ! } else { ! $lobUserObj = new LobUserLink(); ! $lobUserObj->set('lobRepoEntryId',$lobRepoObj->getRepoId()); ! $lobUserObj->set('userId',$u->userId); ! $lobUserObj->set('isOwner','1'); ! $lobUserObj->save(); ! } $classObj = $lobRepoObj->useInClass($classId); |
From: Mark K <har...@us...> - 2008-03-02 22:29:29
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lob In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6016/lib/lob Modified Files: lc_lob_xml.php Log Message: Fix bug linking a LOB to a user from a backup file. Index: lc_lob_xml.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lob/lc_lob_xml.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lc_lob_xml.php 2 Mar 2008 21:59:00 -0000 1.3 --- lc_lob_xml.php 2 Mar 2008 22:29:24 -0000 1.4 *************** *** 92,104 **** $lobMetaObj = Lc_Lob_Xml::processLobMeta($n); - $lobUserObj = new LobUserLink(); - - /* - $lobUserObj->set('lobRepoEntryId',$lob->getPrimaryKey()); - $lobUserObj->set('userId',$u->userId); - $lobUserObj->set('isOwner','1'); - $lobUserObj->save(); - */ - //make the final wrapper object $lcLob = new Lc_Lob(); --- 92,95 ---- *************** *** 140,143 **** --- 131,138 ---- $tag = $childNode->tagName; + //remove the XML namespace + if ( substr($tag,0,4) == 'lob:') { + $tag = substr($tag,4); + } $subchild = $childNode->childNodes; $meta->set($tag, trim($subchild->item(0)->nodeValue) ); |
From: Mark K <har...@us...> - 2008-03-02 22:29:29
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6016/services/classmgr Modified Files: restoreBackup.lcp Log Message: Fix bug linking a LOB to a user from a backup file. Index: restoreBackup.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/restoreBackup.lcp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** restoreBackup.lcp 2 Mar 2008 22:05:08 -0000 1.3 --- restoreBackup.lcp 2 Mar 2008 22:29:24 -0000 1.4 *************** *** 104,109 **** } - $u->addSessionMessage('Successfully added content.'); - $u->sessionvars['restore_dir'] = $tempdir; } --- 104,107 ---- *************** *** 148,151 **** --- 146,156 ---- $lobRepoObj->save(); + //link to this user; + $lobUserObj = new LobUserLink(); + $lobUserObj->set('lobRepoEntryId',$lobRepoObj->getRepoId()); + $lobUserObj->set('userId',$u->userId); + $lobUserObj->set('isOwner','1'); + $lobUserObj->save(); + $classObj = $lobRepoObj->useInClass($classId); } *************** *** 173,176 **** --- 178,185 ---- $this->cleanupDir($tempdir); + + $u->addSessionMessage('Successfully restored backup file.'); + $this->presentor = 'redirectPresentation'; + $t['url'] = appurl('classmgr/display/id_classes='.$classId); } |
From: Mark K <har...@us...> - 2008-03-02 22:05:13
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/templates In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28416/services/classmgr/templates Modified Files: restoreBackup_confirmUpload.html Log Message: Properly cleanup the tempdir after a successfull restore. Index: restoreBackup_confirmUpload.html =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/templates/restoreBackup_confirmUpload.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** restoreBackup_confirmUpload.html 2 Mar 2008 19:00:32 -0000 1.1 --- restoreBackup_confirmUpload.html 2 Mar 2008 22:05:09 -0000 1.2 *************** *** 18,22 **** <ul> <? foreach ( $t['lob_material'] as $lobMaterial ): ?> ! <li> <?= $lobMaterial->lobTitle; ?></li> <? endforeach; ?> </ul> --- 18,22 ---- <ul> <? foreach ( $t['lob_material'] as $lobMaterial ): ?> ! <li> <?= $lobMaterial->get('lobTitle'); ?></li> <? endforeach; ?> </ul> *************** *** 28,32 **** <ul> <? foreach ( $t['lob_activity'] as $lobActivity ): ?> ! <li> <?= $lobActivity->lobTitle; ?></li> <? endforeach; ?> </ul> --- 28,32 ---- <ul> <? foreach ( $t['lob_activity'] as $lobActivity ): ?> ! <li> <?= $lobActivity->get('lobTitle'); ?></li> <? endforeach; ?> </ul> *************** *** 38,42 **** <ul> <? foreach ( $t['lob_test'] as $lobTest ): ?> ! <li> <?= $lobTest->lobTitle; ?></li> <? endforeach; ?> </ul> --- 38,42 ---- <ul> <? foreach ( $t['lob_test'] as $lobTest ): ?> ! <li> <?= $lobTest->get('lobTitle'); ?></li> <? endforeach; ?> </ul> |
From: Mark K <har...@us...> - 2008-03-02 22:05:12
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28416/services/classmgr Modified Files: restoreBackup.lcp Log Message: Properly cleanup the tempdir after a successfull restore. Index: restoreBackup.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/restoreBackup.lcp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** restoreBackup.lcp 2 Mar 2008 21:59:00 -0000 1.2 --- restoreBackup.lcp 2 Mar 2008 22:05:08 -0000 1.3 *************** *** 65,69 **** $this->presentor = 'errorMessage'; $t['message'] ="This file does not seem to be a proper backup file. (cannot find learningobjects.xml)"; ! $this->cleanupDir(); return false; } --- 65,69 ---- $this->presentor = 'errorMessage'; $t['message'] ="This file does not seem to be a proper backup file. (cannot find learningobjects.xml)"; ! $this->cleanupDir($tempdir); return false; } *************** *** 126,130 **** $this->presentor = 'errorMessage'; $t['message'] ="This file does not seem to be a proper backup file. (cannot find learningobjects.xml)"; ! $this->cleanupDir(); return false; } --- 126,130 ---- $this->presentor = 'errorMessage'; $t['message'] ="This file does not seem to be a proper backup file. (cannot find learningobjects.xml)"; ! $this->cleanupDir($tempdir); return false; } *************** *** 169,179 **** $lessonObj->lessonSeq = new Lc_LessonSequence(-1,$classId); $lessonObj->lessonSeq->items = $seqItems; ! //debug($seqItems); ! ! $lessonObj->save(); } ! $this->cleanupDir(); ! exit(); } --- 169,176 ---- $lessonObj->lessonSeq = new Lc_LessonSequence(-1,$classId); $lessonObj->lessonSeq->items = $seqItems; ! $lessonObj->save(); } ! $this->cleanupDir($tempdir); } *************** *** 181,186 **** * Erase /tmp/campus* and the session varaible "restore_dir" */ ! function cleanupDir() { ! $tempdir = $u->sessionvars['restore_dir']; unset($u->sessionvars['restore_dir']); unlink($tempdir.'/learningobjects.xml'); --- 178,183 ---- * Erase /tmp/campus* and the session varaible "restore_dir" */ ! function cleanupDir($tempdir) { ! // $tempdir = $u->sessionvars['restore_dir']; unset($u->sessionvars['restore_dir']); unlink($tempdir.'/learningobjects.xml'); |
From: Mark K <har...@us...> - 2008-03-02 21:59:05
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25933/services/classmgr Modified Files: restoreBackup.lcp Log Message: properly import lesson, lesson sequence, and content learning objects from a backup file. Index: restoreBackup.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/restoreBackup.lcp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** restoreBackup.lcp 2 Mar 2008 19:22:27 -0000 1.1 --- restoreBackup.lcp 2 Mar 2008 21:59:00 -0000 1.2 *************** *** 10,15 **** --- 10,18 ---- include_once(LIB_PATH.'lob/lc_lob.php'); + include_once(LIB_PATH.'lob/lc_lob_class.php'); include_once(LIB_PATH.'lob/lc_lob_xml.php'); include_once(LIB_PATH.'lesson/lc_lesson_xml.php'); + include_once(LIB_PATH.'lesson/lc_lesson_sequence.php'); + include_once(LIB_PATH.'lesson/lc_lesson.php'); /** *************** *** 80,100 **** continue; } - $lobSub = null; $lobRepoObj = Lc_Lob_Xml::parseNode($node, $tempdir); ! if ($lobRepoObj->lobType == 'content') { $t['lob_material'][] = $lobRepoObj; } ! if ($lobRepoObj->lobType == 'activity') { $t['lob_activity'][] = $lobRepoObj; } ! if ($lobRepoObj->lobType == 'test') { $t['lob_test'][] = $lobRepoObj; } } ! $lessonNodes = $collectionNode->getElementsByTagnameNS('http://logicampus.sourceforge.net/2006/learning_object','lesson'); $t['lesson_list'] = array(); ! for ($xidx = 0; $xidx < $lobNodes->length; $xidx++) { $lessonObj = Lc_Lesson_Xml::parseNode($node); $t['lesson_list'][] = $lessonObj; --- 83,103 ---- continue; } $lobRepoObj = Lc_Lob_Xml::parseNode($node, $tempdir); ! if ($lobRepoObj->type == 'content') { $t['lob_material'][] = $lobRepoObj; } ! if ($lobRepoObj->type == 'activity') { $t['lob_activity'][] = $lobRepoObj; } ! if ($lobRepoObj->type == 'test') { $t['lob_test'][] = $lobRepoObj; } } ! $lessonNodes = $collectionNode->getElementsByTagnameNS('http://logicampus.sourceforge.net/2006/lesson','lesson'); $t['lesson_list'] = array(); ! for ($xidx = 0; $xidx < $lessonNodes->length; $xidx++) { ! $node = $lessonNodes->item($xidx); $lessonObj = Lc_Lesson_Xml::parseNode($node); $t['lesson_list'][] = $lessonObj; *************** *** 113,116 **** --- 116,120 ---- $tempdir = $u->sessionvars['restore_dir']; + $classId = $u->activeClassTaught->id_classes; $doc = new DomDocument('1.0', 'UTF-8'); *************** *** 130,134 **** --- 134,179 ---- $collectionNode = $root->item(1); + //LOBS (course materials) + $lobNodes = $collectionNode->getElementsByTagnameNS('http://logicampus.sourceforge.net/2006/learning_object','obj'); + + $t['lob_material'] = array(); + $t['lob_test'] = array(); + $t['lob_activity'] = array(); + for ($xidx = 0; $xidx < $lobNodes->length; $xidx++) { + $node = $lobNodes->item($xidx); + if ($node->nodeType == XML_TEXT_NODE) { + continue; + } + $lobRepoObj = Lc_Lob_Xml::parseNode($node, $tempdir); + $lobRepoObj->save(); + + $classObj = $lobRepoObj->useInClass($classId); + } + + + //LESSON STRUCTURE (sequence and settings) + $lessonNodes = $collectionNode->getElementsByTagnameNS('http://logicampus.sourceforge.net/2006/lesson','lesson'); + + $t['lesson_list'] = array(); + for ($xidx = 0; $xidx < $lessonNodes->length; $xidx++) { + $node = $lessonNodes->item($xidx); + $lessonObj = Lc_Lesson_Xml::parseNode($node); + $lessonObj->lessonDo->idClasses = $classId; + //find the learning path, which is the encloser for all sequence items + $pathCollection = $node->getElementsByTagname('learningpath'); + $path = $pathCollection->item(0); + if (is_object($path) ) { + $seqItems = Lc_Lesson_Xml::parseSequenceNodes($path); + } + + $lessonObj->lessonSeq = new Lc_LessonSequence(-1,$classId); + $lessonObj->lessonSeq->items = $seqItems; + //debug($seqItems); + + $lessonObj->save(); + } + $this->cleanupDir(); + exit(); } |
From: Mark K <har...@us...> - 2008-03-02 21:59:05
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25933/lib/lesson Modified Files: lc_lesson.php lc_lesson_sequence.php lc_lesson_xml.php Log Message: properly import lesson, lesson sequence, and content learning objects from a backup file. Index: lc_lesson.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson/lc_lesson.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lc_lesson.php 2 Mar 2008 18:03:24 -0000 1.2 --- lc_lesson.php 2 Mar 2008 21:59:00 -0000 1.3 *************** *** 9,14 **** class Lc_Lesson { ! var $lessonDo = null; ! var $guid = ''; function Lc_Lesson($id=-1) { --- 9,16 ---- class Lc_Lesson { ! var $lessonDo = null; ! var $guid = ''; ! var $lessonSeq = null; ! var $seqLoaded = false; function Lc_Lesson($id=-1) { *************** *** 31,34 **** --- 33,61 ---- /** + * Save the lessonDo + */ + function save() { + $goodSave = true; + $goodSave &= $this->lessonDo->save(); + + if (is_object($this->lessonSeq) ) { + if ($this->lessonSeq->lessonId != $this->getId() ) { + $this->lessonSeq->lessonId = $this->getId(); + } + $goodSave &= $this->lessonSeq->save(); + } + return $goodSave; + } + + /** + * Load up the LOB sequence that goes with this lesson + */ + function loadSequence($classId) { + $this->lessonSeq = new Lc_LessonSequence($this->getId(),$classId); + $this->lessonSeq->loadItems(); + $this->seqLoaded = true; + } + + /** * Set the GUID */ Index: lc_lesson_sequence.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson/lc_lesson_sequence.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lesson_sequence.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lesson_sequence.php 2 Mar 2008 21:59:00 -0000 1.2 *************** *** 1,6 **** <?php include_once(LIB_PATH.'PBDO/ClassLessonSequence.php'); ! class LC_LessonSequence { var $lessonId = -1; --- 1,7 ---- <?php include_once(LIB_PATH.'PBDO/ClassLessonSequence.php'); + include_once(LIB_PATH.'PBDO/LobClassRepo.php'); ! class Lc_LessonSequence { var $lessonId = -1; *************** *** 8,12 **** var $items = array(); ! function LC_LessonSequence($lessonId,$classId) { $this->lessonId = $lessonId; $this->classId = $classId; --- 9,13 ---- var $items = array(); ! function Lc_LessonSequence($lessonId,$classId) { $this->lessonId = $lessonId; $this->classId = $classId; *************** *** 20,23 **** --- 21,77 ---- } + /** + * Save each item + */ + function save() { + foreach ($this->items as $_idx => $_item) { + if( isset($_item->guid)) { + $this->resolveReference($_item, $_item->guid); + } + if ($_item->lessonId != $this->lessonId || + $_item->classId != $this->classId ) { + $_item->lessonId = $this->lessonId; + $_item->classId = $this->classId; + } + if ($_item->rank == 0) { + $_item->rank = $_idx+1; + } + $_item->save(); + } + } + + /** + * Reload a class lob and set the cached info of this sequence item. + */ + function resolveReference(&$item,$guid) { + + $classLob = LobClassRepo::load( array('lob_guid'=>$guid)); + $item->set('lobClassRepoId', $classLob->lobClassRepoId); + $item->set('lobMime', $classLob->lobMime); + $item->set('lobType', $classLob->lobType); + $item->set('lobSubType', $classLob->lobSubType); + $item->set('lobTitle', $classLob->lobTitle); + $item->set('linkText', $classLob->lobUrltitle); + $item->set('lobGuid', $guid); + $item->set('lobVersion', $classLob->lobVersion); + $item->set('visible', 1); + unset($item->guid); + /* + lob_class_repo_id: 1 + class_id: 1 + lob_repo_entry_id: 1 + lob_guid: cf7ba7b8-9da9-4d1d-91dd-24d2ea65fa37 + lob_title: activity 1 + lob_urltitle: activity_1 + lob_copy_style: n + lob_type: activity + lob_sub_type: Text Response + lob_mime: X-LMS/activity + lob_description: sdfadsf + lob_version: 3 + lob_bytes: 0 + */ + } + function fetchObject($sequenceId) { $type = 'content'; Index: lc_lesson_xml.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson/lc_lesson_xml.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lc_lesson_xml.php 2 Mar 2008 18:03:24 -0000 1.2 --- lc_lesson_xml.php 2 Mar 2008 21:59:00 -0000 1.3 *************** *** 2,5 **** --- 2,6 ---- include_once(LIB_PATH.'PBDO/ClassLessons.php'); + include_once(LIB_PATH.'PBDO/ClassLessonSequence.php'); include_once(LIB_PATH.'lesson/lc_lesson.php'); *************** *** 32,38 **** $result = $n->getElementsByTagname('title'); $title = $result->item(0); - $lessonDo->title = $title->nodeValue; // TODO: double check the DB id belongs to this user. $dbid = $n->getAttribute('dbid'); --- 33,42 ---- $result = $n->getElementsByTagname('title'); $title = $result->item(0); $lessonDo->title = $title->nodeValue; + $result = $n->getElementsByTagname('description'); + $description = $result->item(0); + $lessonDo->description = $description->nodeValue; + // TODO: double check the DB id belongs to this user. $dbid = $n->getAttribute('dbid'); *************** *** 44,128 **** $lessonObj->setGuid($guid); return $lessonObj; ! /* ! $children = $type->childNodes; ! $content = ''; ! if ($children->length) { ! $content = trim($children->item(0)->nodeValue); ! $guid = $n->getAttribute('guid'); ! $dbid = $n->getAttribute('dbid'); ! } ! else { ! die ('unknown class: '. get_class($type)); ! return null; ! } ! ! $lob = null; ! $lob = new LobRepoEntry(); ! $lob->set('lobGuid',$guid); ! switch ($content) { ! case 'content': ! $lob->set('lobType','content'); ! break; ! case 'activity': ! $lob->set('lobType','activity'); ! break; ! case 'test': ! $lob->set('lobType','test'); ! break; ! } ! if ($lob->lobType == '') { return null; die ('unknown type '. $content); } ! ! ! $result = $n->getElementsByTagname('title'); ! $node = $result->item(0); ! $children = $node->childNodes; ! $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); ! ! $result = $n->getElementsByTagname('content'); ! $node = $result->item(0); ! if (is_object($node) ){ ! $children = $node->childNodes; ! $lob->set('lobContent', trim($children->item(0)->nodeValue) ); ! } ! ! $result = $n->getElementsByTagname('filename'); ! $node = $result->item(0); ! if (is_object($node) ){ ! $children = $node->childNodes; ! $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); ! ! $urlTitle = Lc_Lob_Util::createLinkText(trim($children->item(0)->nodeValue)); ! $lob->set('lobUrltitle', $urlTitle ); ! $lob->set('lobBinary', file_get_contents($this->tempdir.'/content/'.trim($children->item(0)->nodeValue)) ); ! } else { ! $urlTitle = Lc_Lob_Util::createLinkText(trim( $lob->get('lobTitle')) ); ! $lob->set('lobUrltitle', $urlTitle ); ! } ! ! $result = $n->getElementsByTagname('description'); ! $node = $result->item(0); ! if (is_object($node) ){ ! $children = $node->childNodes; ! $lob->set('lobDescription', trim($children->item(0)->nodeValue) ); ! } ! $result = $n->getElementsByTagname('subtype'); ! $node = $result->item(0); ! if (is_object($node) ){ ! $children = $node->childNodes; ! $lob->set('lobSubType', trim($children->item(0)->nodeValue) ); ! } ! ! $result = $n->getElementsByTagname('mime'); ! $node = $result->item(0); ! if (is_object($node) ){ ! $children = $node->childNodes; ! $lob->set('lobMime', trim($children->item(0)->nodeValue) ); } ! ! return $lob; ! // debug($children); ! */ } } --- 48,69 ---- $lessonObj->setGuid($guid); return $lessonObj; ! } ! function parseSequenceNodes($learningPathNode) { ! $seqNodes = $learningPathNode->getElementsByTagname('lobsequence'); ! $len = $seqNodes->length; ! $seqItems = array(); ! for ($x=0; $x < $len; $x++) { ! $_seqNode = $seqNodes->item($x); ! $_seqItem = new ClassLessonSequence(); ! $_start = $_seqNode->getElementsByTagname('start')->item(0); ! $_seqItem->startOffset = $_start->nodeValue - ( $_start->nodeValue % 86400 ); ! $_seqItem->startTime = ($_start->nodeValue % 86400); ! $_lobNode = $_seqNode->getElementsByTagname('lob')->item(0); ! $_seqItem->guid = $_lobNode->getAttribute('refid'); ! $seqItems[] = $_seqItem; } ! return $seqItems; } } |
From: Mark K <har...@us...> - 2008-03-02 21:59:05
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lob In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25933/lib/lob Modified Files: lc_lob.php lc_lob_xml.php Log Message: properly import lesson, lesson sequence, and content learning objects from a backup file. Index: lc_lob.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lob/lc_lob.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lc_lob.php 2 Mar 2008 19:00:38 -0000 1.2 --- lc_lob.php 2 Mar 2008 21:59:00 -0000 1.3 *************** *** 266,271 **** ! $this->lobSub->lobRepoEntryId = $this->repoObj->getPrimaryKey(); ! $this->lobSub->save(); $this->lobMetaObj->updatedOn = time(); --- 266,273 ---- ! if (is_object($this->lobSub) ) { ! $this->lobSub->lobRepoEntryId = $this->repoObj->getPrimaryKey(); ! $this->lobSub->save(); ! } $this->lobMetaObj->updatedOn = time(); Index: lc_lob_xml.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lob/lc_lob_xml.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lc_lob_xml.php 2 Mar 2008 19:00:39 -0000 1.2 --- lc_lob_xml.php 2 Mar 2008 21:59:00 -0000 1.3 *************** *** 1,5 **** <?php - /** * Process Learning Object XML formats --- 1,4 ---- *************** *** 92,120 **** } $lobSub = null; ! if ($lobObj->lobType == 'content') { $lobSub = $this->makeContentNode($n); } ! if ($lobObj->lobType == 'activity') { $lobSub = $this->makeActivityNode($n); } if ( is_object($lobSub) ) { ! $lob->lobSub = $lobSub; } ! $lobMetaObj = Lc_Lob_Xml::processLobMeta($n); ! $lobUserObj = new LobUserLink(); ! ! /* ! $lobUserObj->set('lobRepoEntryId',$lobObj->getPrimaryKey()); ! $lobUserObj->set('userId',$u->userId); ! $lobUserObj->set('isOwner','1'); ! $lobUserObj->save(); ! */ ! ! return $lob; ! // debug($children); } --- 91,124 ---- } + $lobMetaObj = Lc_Lob_Xml::processLobMeta($n); + $lobUserObj = new LobUserLink(); + + /* + $lobUserObj->set('lobRepoEntryId',$lob->getPrimaryKey()); + $lobUserObj->set('userId',$u->userId); + $lobUserObj->set('isOwner','1'); + $lobUserObj->save(); + */ + + //make the final wrapper object + $lcLob = new Lc_Lob(); + $lcLob->repoObj = $lob; + $lcLob->lobMetaObj = $lobMetaObj; + $lcLob->type = $lob->lobType; + $lobSub = null; ! if ($lob->lobType == 'content') { $lobSub = $this->makeContentNode($n); } ! if ($lob->lobType == 'activity') { $lobSub = $this->makeActivityNode($n); } if ( is_object($lobSub) ) { ! $lcLob->lobSub = $lobSub; } ! return $lcLob; } *************** *** 128,133 **** ! $lob = null; ! $lob = new LobMetadata(); foreach($children as $childNode) { --- 132,136 ---- ! $meta = new LobMetadata(); foreach($children as $childNode) { *************** *** 138,143 **** $tag = $childNode->tagName; $subchild = $childNode->childNodes; ! $lob->set($tag, trim($subchild->item(0)->nodeValue) ); } } /* --- 141,147 ---- $tag = $childNode->tagName; $subchild = $childNode->childNodes; ! $meta->set($tag, trim($subchild->item(0)->nodeValue) ); } + return $meta; } /* |
From: Mark K <har...@us...> - 2008-03-02 19:22:37
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24277 Added Files: restoreBackup.lcp Log Message: adding restore file. --- NEW FILE: restoreBackup.lcp --- <? include_once(LIB_PATH.'PBDO/LobRepoEntry.php'); include_once(LIB_PATH.'PBDO/LobMetadata.php'); include_once(LIB_PATH.'PBDO/LobUserLink.php'); include_once(LIB_PATH.'PBDO/LobContent.php'); include_once(LIB_PATH.'PBDO/LobActivity.php'); include_once(LIB_PATH.'PBDO/LobTest.php'); include_once(LIB_PATH.'lob/lc_lob.php'); include_once(LIB_PATH.'lob/lc_lob_xml.php'); include_once(LIB_PATH.'lesson/lc_lesson_xml.php'); /** * Learning Object Repository */ class RestoreBackup extends FacultyService { var $presentor='htmlPresentation'; var $sectionTitle = 'Classroom Manager'; var $navlinks = array ( ''=>'' ); /** * Display a form to upload the backup ZIP archive. */ function run(&$db,&$u,&$lc,&$t) { $lc->templateName='restoreBackup_main'; } /** * Extract the uploaded zip file, display the contents and ask for confirmation. */ function confirmUploadRun(&$db,&$u,&$lc,&$t) { if ($lc->uploads['lobxml']['error']) { $this->presentor = 'errorMessage'; $t['message'] = "There was a problem with the upload."; return false; } $tempdir = $this->tempdir('/tmp', 'campus'); $this->tempdir = $tempdir; //debug($tempdir); //exit(); //$za = zip_open($lc->uploads['lobxml']['tmp_name']); //debug($za); exec('unzip -d '. $tempdir.' '.$lc->uploads['lobxml']['tmp_name'] ); $doc = new DomDocument('1.0', 'UTF-8'); $doc->substituteEntities=false; $doc->resolveExternals=false; $doc->preserveWhiteSpace=true; $doc->validateOnParse=false; if (!$doc->load( $tempdir."/learningobjects.xml") ) { $this->presentor = 'errorMessage'; $t['message'] ="This file does not seem to be a proper backup file. (cannot find learningobjects.xml)"; $this->cleanupDir(); return false; } $root = $doc->childNodes; //get the "lobcol" node $collectionNode = $root->item(1); $lobNodes = $collectionNode->getElementsByTagnameNS('http://logicampus.sourceforge.net/2006/learning_object','obj'); $t['lob_material'] = array(); $t['lob_test'] = array(); $t['lob_activity'] = array(); for ($xidx = 0; $xidx < $lobNodes->length; $xidx++) { $node = $lobNodes->item($xidx); if ($node->nodeType == XML_TEXT_NODE) { continue; } $lobSub = null; $lobRepoObj = Lc_Lob_Xml::parseNode($node, $tempdir); if ($lobRepoObj->lobType == 'content') { $t['lob_material'][] = $lobRepoObj; } if ($lobRepoObj->lobType == 'activity') { $t['lob_activity'][] = $lobRepoObj; } if ($lobRepoObj->lobType == 'test') { $t['lob_test'][] = $lobRepoObj; } } $lessonNodes = $collectionNode->getElementsByTagnameNS('http://logicampus.sourceforge.net/2006/learning_object','lesson'); $t['lesson_list'] = array(); for ($xidx = 0; $xidx < $lobNodes->length; $xidx++) { $lessonObj = Lc_Lesson_Xml::parseNode($node); $t['lesson_list'][] = $lessonObj; } $u->addSessionMessage('Successfully added content.'); $u->sessionvars['restore_dir'] = $tempdir; } /** * read the temporary directory from the session and complete the import of the backup file. */ function handleUploadRun(&$db,&$u,&$lc,&$t) { $tempdir = $u->sessionvars['restore_dir']; $doc = new DomDocument('1.0', 'UTF-8'); $doc->substituteEntities=false; $doc->resolveExternals=false; $doc->preserveWhiteSpace=true; $doc->validateOnParse=false; if (!$doc->load( $tempdir."/learningobjects.xml") ) { $this->presentor = 'errorMessage'; $t['message'] ="This file does not seem to be a proper backup file. (cannot find learningobjects.xml)"; $this->cleanupDir(); return false; } $root = $doc->childNodes; //get the "lobcol" node $collectionNode = $root->item(1); $this->cleanupDir(); } /** * Erase /tmp/campus* and the session varaible "restore_dir" */ function cleanupDir() { $tempdir = $u->sessionvars['restore_dir']; unset($u->sessionvars['restore_dir']); unlink($tempdir.'/learningobjects.xml'); rmdir($tempdir.'/content'); rmdir($tempdir); } /** * return a lob content sub-object */ function makeContentNode($n) { $result = $n->getElementsByTagname('content'); $textContent = $result->item(0); $lobSub = new LobContent(); $lobSub->lobText = $textContent->nodeValue; return $lobSub; } /** * return a lob activity sub-object */ function makeActivityNode($n) { $result = $n->getElementsByTagname('response'); $responseNode = $result->item(0); $lobSub = new LobActivity(); switch($resposneNode->nodeValue) { case 'upload': $lobSub->responseTypeId = 1; break; case 'text': $lobSub->responseTypeId = 2; break; case 'uploadandtext': $lobSub->responseTypeId = 3; break; case 'forum': $lobSub->responseTypeId = 4; break; case 'none': $lobSub->responseTypeId = 5; break; case 'audio': $lobSub->responseTypeId = 6; break; default: $lobSub->responseTypeId = 5; } return $lobSub; } /** * return a lob object */ function makeRepoNode($n) { $result = $n->getElementsByTagname('type'); $type = $result->item(0); /* print_r($type); echo "new lob: <br/>"; // debug($type); echo $type->nodeValue; echo "\n<br/>"; echo "name lob: <br/>"; echo $type->tagName; echo "<br/>"; // */ $children = $type->childNodes; $content = ''; if ($children->length) { $content = trim($children->item(0)->nodeValue); $guid = $n->getAttribute('guid'); $dbid = $n->getAttribute('dbid'); } else { die ('unknown class: '. get_class($type)); return null; } $lob = null; $lob = new LobRepoEntry(); $lob->set('lobGuid',$guid); switch ($content) { case 'content': $lob->set('lobType','content'); break; case 'activity': $lob->set('lobType','activity'); break; case 'test': $lob->set('lobType','test'); break; } if ($lob->lobType == '') { return null; die ('unknown type '. $content); } $result = $n->getElementsByTagname('title'); $node = $result->item(0); $children = $node->childNodes; $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); $result = $n->getElementsByTagname('content'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobContent', trim($children->item(0)->nodeValue) ); } $result = $n->getElementsByTagname('filename'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); $urlTitle = Lc_Lob_Util::createLinkText(trim($children->item(0)->nodeValue)); $lob->set('lobUrltitle', $urlTitle ); $lob->set('lobBinary', file_get_contents($this->tempdir.'/content/'.trim($children->item(0)->nodeValue)) ); } else { $urlTitle = Lc_Lob_Util::createLinkText(trim( $lob->get('lobTitle')) ); $lob->set('lobUrltitle', $urlTitle ); } $result = $n->getElementsByTagname('description'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobDescription', trim($children->item(0)->nodeValue) ); } $result = $n->getElementsByTagname('subtype'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobSubType', trim($children->item(0)->nodeValue) ); } $result = $n->getElementsByTagname('mime'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobMime', trim($children->item(0)->nodeValue) ); } return $lob; // debug($children); } /** * return a lob metadata object */ function processLobMeta($n) { $result = $n->getElementsByTagname('metadata'); $meta = $result->item(0); $children = $meta->childNodes; $lob = null; $lob = new LobMetadata(); foreach($children as $childNode) { if ($childNode->nodeType == XML_TEXT_NODE) { continue; } $tag = $childNode->tagName; $subchild = $childNode->childNodes; $lob->set($tag, trim($subchild->item(0)->nodeValue) ); } /* $result = $n->getElementsByTagname('lobtitle'); $node = $result->item(0); $children = $node->childNodes; $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); $result = $n->getElementsByTagname('lobcontent'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobContent', trim($children->item(0)->nodeValue) ); } $result = $n->getElementsByTagname('lobfilename'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); $lob->set('lobUrltitle', urlencode(trim($children->item(0)->nodeValue)) ); } else { $urltitle = $lob->get('lobTitle'); $urltitle = str_replace(' ', '_', $urltitle); $urltitle = urlencode($urltitle); $lob->set('lobUrltitle', $urltitle ); } $result = $n->getElementsByTagname('lobdescription'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobDescription', trim($children->item(0)->nodeValue) ); } $result = $n->getElementsByTagname('subtype'); $node = $result->item(0); if (is_object($node) ){ $children = $node->childNodes; $lob->set('lobSubType', trim($children->item(0)->nodeValue) ); } */ return $lob; } function tempdir($dir, $prefix='', $mode=0700) { if (substr($dir, -1) != '/') $dir .= '/'; do { $path = $dir.$prefix.mt_rand(0, 9999999); } while (!mkdir($path, $mode)); return $path; } } ?> |
From: Mark K <har...@us...> - 2008-03-02 19:01:04
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lob In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13918/lib/lob Modified Files: lc_lob.php lc_lob_xml.php Log Message: Move xml processing of LOBs into specialized utility class. Index: lc_lob.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lob/lc_lob.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lob.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lob.php 2 Mar 2008 19:00:38 -0000 1.2 *************** *** 35,45 **** /** - * Document style content, word processing files, audio, etc - */ - function isFile() { - return $this->repoObj->lobSubType == 'document'; - } - - /** * Acitivty/assignment style content. homework, upload a file, etc. */ --- 35,38 ---- *************** *** 55,58 **** --- 48,74 ---- } + /** + * Content or classroom material style content. + */ + function isMaterial() { + return $this->repoObj->lobType == 'content'; + } + + /** + * Document style content, word processing files, audio, etc + * + * This sub type is a binary document file that can't be displayed + * in Web pages w/o a plugin or a download. + */ + function isFile() { + return $this->repoObj->lobSubType == 'document'; + } + + /** + * Textual content, plain text, html + * + * This sub type is a binary document file that can be displayed + * in Web pages. + */ function isText() { return $this->repoObj->lobSubType == 'text'; Index: lc_lob_xml.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lob/lc_lob_xml.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lob_xml.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lob_xml.php 2 Mar 2008 19:00:39 -0000 1.2 *************** *** 6,10 **** --- 6,176 ---- */ class Lc_Lob_Xml { + + /** + * return an Lc_Lob object + * + * @param $tempDir string The location of the unzipped backup file (/tmp/campus9999/). + * @static + */ + function parseNode($n,$tempDir='/tmp/') { + $result = $n->getElementsByTagname('type'); + $type = $result->item(0); + $children = $type->childNodes; + $content = ''; + if ($children->length) { + $content = trim($children->item(0)->nodeValue); + $guid = $n->getAttribute('guid'); + $dbid = $n->getAttribute('dbid'); + } + else { + die ('unknown class: '. get_class($type)); + return null; + } + $lob = null; + $lob = new LobRepoEntry(); + $lob->set('lobGuid',$guid); + switch ($content) { + case 'content': + $lob->set('lobType','content'); + break; + case 'activity': + $lob->set('lobType','activity'); + break; + case 'test': + $lob->set('lobType','test'); + break; + } + if ($lob->lobType == '') { return null; die ('unknown type '. $content); } + + + $result = $n->getElementsByTagname('title'); + $node = $result->item(0); + $children = $node->childNodes; + $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); + + $result = $n->getElementsByTagname('content'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobContent', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('filename'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); + + $urlTitle = Lc_Lob_Util::createLinkText(trim($children->item(0)->nodeValue)); + $lob->set('lobUrltitle', $urlTitle ); + $lob->set('lobBinary', file_get_contents($tempDir.'/content/'.trim($children->item(0)->nodeValue)) ); + } else { + $urlTitle = Lc_Lob_Util::createLinkText(trim( $lob->get('lobTitle')) ); + $lob->set('lobUrltitle', $urlTitle ); + } + + $result = $n->getElementsByTagname('description'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobDescription', trim($children->item(0)->nodeValue) ); + } + + + $result = $n->getElementsByTagname('subtype'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobSubType', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('mime'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobMime', trim($children->item(0)->nodeValue) ); + } + + $lobSub = null; + + if ($lobObj->lobType == 'content') { + $lobSub = $this->makeContentNode($n); + } + if ($lobObj->lobType == 'activity') { + $lobSub = $this->makeActivityNode($n); + } + + if ( is_object($lobSub) ) { + $lob->lobSub = $lobSub; + } + + $lobMetaObj = Lc_Lob_Xml::processLobMeta($n); + $lobUserObj = new LobUserLink(); + + /* + $lobUserObj->set('lobRepoEntryId',$lobObj->getPrimaryKey()); + $lobUserObj->set('userId',$u->userId); + $lobUserObj->set('isOwner','1'); + $lobUserObj->save(); + */ + + return $lob; + // debug($children); + } + + /** + * return a lob metadata object + */ + function processLobMeta($n) { + $result = $n->getElementsByTagname('metadata'); + $meta = $result->item(0); + $children = $meta->childNodes; + + + $lob = null; + $lob = new LobMetadata(); + + foreach($children as $childNode) { + if ($childNode->nodeType == XML_TEXT_NODE) { + continue; + } + + $tag = $childNode->tagName; + $subchild = $childNode->childNodes; + $lob->set($tag, trim($subchild->item(0)->nodeValue) ); + } + } + /* + + $result = $n->getElementsByTagname('lobtitle'); + $node = $result->item(0); + $children = $node->childNodes; + $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); + + $result = $n->getElementsByTagname('lobcontent'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobContent', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('lobfilename'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); + $lob->set('lobUrltitle', urlencode(trim($children->item(0)->nodeValue)) ); + } else { + $urltitle = $lob->get('lobTitle'); + $urltitle = str_replace(' ', '_', $urltitle); + $urltitle = urlencode($urltitle); + $lob->set('lobUrltitle', $urltitle ); + } + + $result = $n->getElementsByTagname('lobdescription'); + $node = $result->item(0); + */ } + ?> |
From: Mark K <har...@us...> - 2008-03-02 19:00:43
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/templates In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13918/services/classmgr/templates Added Files: restoreBackup_confirmUpload.html restoreBackup_main.html Log Message: Move xml processing of LOBs into specialized utility class. --- NEW FILE: restoreBackup_main.html --- <?=$t['sectionheader'];?> <h3>Upload your backup file.</h3> Add your XML file to the input box below. <form method="POST" action="<?=appurl('classmgr/restoreBackup/event=confirmUpload');?>" enctype="multipart/form-data"> <input type="file" size="35" name="lobxml"> <br/> <input type="submit" value="Start Import"> </form> --- NEW FILE: restoreBackup_confirmUpload.html --- <?=$t['sectionheader'];?> <h3>Backup file contents...</h3> <p> Your backup has <b>not</b> been restored yet. Click this button to finish the import. <form method="POST" action="<?=appurl('classmgr/restoreBackup/event=handleUpload');?>"> <input type="submit" value="Start Import"> </form> </p> <hr/> <p> The backup file contains the following objects: <ul> <li>Classroom Materials: <?= count($t['lob_material']);?> <? if ( count($t['lob_material']) ): ?> <ul> <? foreach ( $t['lob_material'] as $lobMaterial ): ?> <li> <?= $lobMaterial->lobTitle; ?></li> <? endforeach; ?> </ul> <? endif; ?> </li> <li>Student Activities: <?= count($t['lob_activity']);?> <? if ( count($t['lob_activity']) ): ?> <ul> <? foreach ( $t['lob_activity'] as $lobActivity ): ?> <li> <?= $lobActivity->lobTitle; ?></li> <? endforeach; ?> </ul> <? endif; ?> </li> <li>Tests: <?= count($t['lob_test']);?> <? if ( count($t['lob_test']) ): ?> <ul> <? foreach ( $t['lob_test'] as $lobTest ): ?> <li> <?= $lobTest->lobTitle; ?></li> <? endforeach; ?> </ul> <? endif; ?> </li> <li>Lessons: <?= count($t['lesson_list']);?> <? if ( count($t['lesson_list']) ): ?> <ul> <? foreach ( $t['lesson_list'] as $lessonObj ): ?> <li> <?= $lessonObj->getTitle(); ?></li> <? endforeach; ?> </ul> <? endif; ?> </li> </ul> </p> |
From: Mark K <har...@us...> - 2008-03-02 18:04:28
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23473/services/classmgr Modified Files: lessonManager.lcp Log Message: Fix missing dependency Index: lessonManager.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/lessonManager.lcp,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** lessonManager.lcp 2 Mar 2008 18:03:24 -0000 1.48 --- lessonManager.lcp 2 Mar 2008 18:04:16 -0000 1.49 *************** *** 6,9 **** --- 6,11 ---- include_once(LIB_PATH.'classLessonObj.php'); include_once(LIB_PATH.'lesson/lc_lesson_sequence.php'); + include_once(LIB_PATH.'lesson/lc_lesson.php'); + include_once(LIB_PATH.'lob/lc_lob.php'); // PBDO is the new standard, above object is DEPRECATED |
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23144/services/classmgr Modified Files: assignmentManage.lcp classMaterial.lcp display.lcp lessonManager.lcp lessonSequence.lcp Log Message: Fixing class naming convetion for Lc_Lesson Index: classMaterial.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/classMaterial.lcp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** classMaterial.lcp 1 Mar 2008 23:43:19 -0000 1.3 --- classMaterial.lcp 2 Mar 2008 18:03:24 -0000 1.4 *************** *** 379,385 **** $lessonId = $seqItem->lessonId; ! $lessonSequence = new LC_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new LC_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); --- 379,385 ---- $lessonId = $seqItem->lessonId; ! $lessonSequence = new Lc_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new Lc_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); *************** *** 517,523 **** $lessonId = $seqItem->lessonId; ! $lessonSequence = new LC_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new LC_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); --- 517,523 ---- $lessonId = $seqItem->lessonId; ! $lessonSequence = new Lc_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new Lc_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); Index: lessonSequence.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/lessonSequence.lcp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** lessonSequence.lcp 2 Nov 2007 00:29:06 -0000 1.15 --- lessonSequence.lcp 2 Mar 2008 18:03:24 -0000 1.16 *************** *** 274,278 **** // $sequences = ClassLessonSequencePeer::doSelect(' class_id = '.$class_id. ' AND lesson_id = '.$lesson_id.' ORDER BY rank'); ! $lessonSeqObj = new LC_LessonSequence($lesson_id,$class_id); $lessonSeqObj->loadItems(); foreach ($lessonSeqObj->items as $objIdx => $obj) { --- 274,278 ---- // $sequences = ClassLessonSequencePeer::doSelect(' class_id = '.$class_id. ' AND lesson_id = '.$lesson_id.' ORDER BY rank'); ! $lessonSeqObj = new Lc_LessonSequence($lesson_id,$class_id); $lessonSeqObj->loadItems(); foreach ($lessonSeqObj->items as $objIdx => $obj) { Index: assignmentManage.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/assignmentManage.lcp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** assignmentManage.lcp 1 Mar 2008 23:43:19 -0000 1.29 --- assignmentManage.lcp 2 Mar 2008 18:03:24 -0000 1.30 *************** *** 713,719 **** $lessonId = $seqItem->lessonId; ! $lessonSequence = new LC_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new LC_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); --- 713,719 ---- $lessonId = $seqItem->lessonId; ! $lessonSequence = new Lc_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new Lc_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); *************** *** 851,857 **** $lessonId = $seqItem->lessonId; ! $lessonSequence = new LC_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new LC_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); --- 851,857 ---- $lessonId = $seqItem->lessonId; ! $lessonSequence = new Lc_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new Lc_Lesson($lessonId); $t['lessonTitle'] = $lesson->getTitle(); Index: display.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/display.lcp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** display.lcp 1 Mar 2008 23:43:19 -0000 1.11 --- display.lcp 2 Mar 2008 18:03:24 -0000 1.12 *************** *** 69,73 **** $classId = $u->activeClassTaught->id_classes; ! $t['lessonList'] = LC_Lesson::loadClassLessons($classId); $t['contentCount'] = array(); --- 69,73 ---- $classId = $u->activeClassTaught->id_classes; ! $t['lessonList'] = Lc_Lesson::loadClassLessons($classId); $t['contentCount'] = array(); Index: lessonManager.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/lessonManager.lcp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** lessonManager.lcp 1 Mar 2008 23:43:19 -0000 1.47 --- lessonManager.lcp 2 Mar 2008 18:03:24 -0000 1.48 *************** *** 57,61 **** //*/ ! $t['lessonList'] = LC_Lesson::loadClassLessons($classId); $t['lessonDataGridList'] = array(); --- 57,61 ---- //*/ ! $t['lessonList'] = Lc_Lesson::loadClassLessons($classId); $t['lessonDataGridList'] = array(); *************** *** 538,542 **** } ! $lessonSequence = new LC_LessonSequence($lesson_id, $class_id); $lessonSequence->updateContent($itemArray,$lobRecord); --- 538,542 ---- } ! $lessonSequence = new Lc_LessonSequence($lesson_id, $class_id); $lessonSequence->updateContent($itemArray,$lobRecord); *************** *** 699,703 **** ! $lessonSequence = new LC_LessonSequence($lesson_id, $class_id); $lessonSequence->updateAssignments($itemArray,$lobRecord); --- 699,703 ---- ! $lessonSequence = new Lc_LessonSequence($lesson_id, $class_id); $lessonSequence->updateAssignments($itemArray,$lobRecord); *************** *** 762,766 **** $t['lessonId'] = $lessonId; ! $t['lessonObj'] = new LC_Lesson($lessonId); if (!$this->checkAuth($lessonId,$db,$u,$t)) return; --- 762,766 ---- $t['lessonId'] = $lessonId; ! $t['lessonObj'] = new Lc_Lesson($lessonId); if (!$this->checkAuth($lessonId,$db,$u,$t)) return; *************** *** 1186,1190 **** ! $lessonSequence = new LC_LessonSequence($lesson_id, $class_id); $lessonSequence->updateTests($itemArray,$lobRecord); --- 1186,1190 ---- ! $lessonSequence = new Lc_LessonSequence($lesson_id, $class_id); $lessonSequence->updateTests($itemArray,$lobRecord); |
From: Mark K <har...@us...> - 2008-03-02 18:03:44
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classroom In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23144/services/classroom Modified Files: assignments.lcp Log Message: Fixing class naming convetion for Lc_Lesson Index: assignments.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classroom/assignments.lcp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** assignments.lcp 1 Mar 2008 23:43:19 -0000 1.17 --- assignments.lcp 2 Mar 2008 18:03:25 -0000 1.18 *************** *** 142,151 **** //find the lesson id if ( empty($u->sessionvars['activeLesson']) ) { ! $lessonId = LC_Lesson::getLessonIdForSequenceId($classSeqId); ! LC_Lesson::storeLessonInSession($lessonId,$u); } else { if ( $u->sessionvars['activeLesson']['id_classes'] != $classId ) { ! $lessonId = LC_Lesson::getLessonIdForSequenceId($classSeqId); ! LC_Lesson::storeLessonInSession($lessonId,$u); } else { $lessonId = $u->sessionvars['activeLesson']['id_class_lessons']; --- 142,151 ---- //find the lesson id if ( empty($u->sessionvars['activeLesson']) ) { ! $lessonId = Lc_Lesson::getLessonIdForSequenceId($classSeqId); ! Lc_Lesson::storeLessonInSession($lessonId,$u); } else { if ( $u->sessionvars['activeLesson']['id_classes'] != $classId ) { ! $lessonId = Lc_Lesson::getLessonIdForSequenceId($classSeqId); ! Lc_Lesson::storeLessonInSession($lessonId,$u); } else { $lessonId = $u->sessionvars['activeLesson']['id_class_lessons']; *************** *** 153,157 **** } ! $lessonSequence = new LC_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); $activityLob = $lessonSequence->fetchObject($classSeqId); --- 153,157 ---- } ! $lessonSequence = new Lc_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); $activityLob = $lessonSequence->fetchObject($classSeqId); *************** *** 165,169 **** $t['activity'] = $activityLob; $sequence = $lessonSequence->getSequence($classSeqId); ! $lesson = new LC_Lesson($lessonId); $t['lessonId'] = $lessonId; $t['startDate'] = $lessonSequence->getStartDate($lesson, $classSeqId); --- 165,169 ---- $t['activity'] = $activityLob; $sequence = $lessonSequence->getSequence($classSeqId); ! $lesson = new Lc_Lesson($lessonId); $t['lessonId'] = $lessonId; $t['startDate'] = $lessonSequence->getStartDate($lesson, $classSeqId); *************** *** 302,308 **** $lessonId = $u->sessionvars['activeLesson']['id_class_lessons']; ! $lessonSequence = new LC_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new LC_Lesson($lessonId); $activityLob = $lessonSequence->fetchObject($classSeqId); --- 302,308 ---- $lessonId = $u->sessionvars['activeLesson']['id_class_lessons']; ! $lessonSequence = new Lc_LessonSequence($lessonId,$classId); $lessonSequence->loadItems(); ! $lesson = new Lc_Lesson($lessonId); $activityLob = $lessonSequence->fetchObject($classSeqId); |
From: Mark K <har...@us...> - 2008-03-02 18:03:44
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/templates In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23144/services/classmgr/templates Modified Files: display_main.html Log Message: Fixing class naming convetion for Lc_Lesson Index: display_main.html =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/templates/display_main.html,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** display_main.html 1 Feb 2008 03:05:38 -0000 1.17 --- display_main.html 2 Mar 2008 18:03:24 -0000 1.18 *************** *** 51,54 **** --- 51,55 ---- <li><a href="<?=modurl('dataexchange');?>"><?=lct('Backup Class Content')?></a></li> <li><a href="<?=APP_URL?>classmgr/semestercopy/"><?=lct('Semester Copy')?></a></li> + <li><a href="<?=APP_URL?>classmgr/restoreBackup/"><?=lct('Restore Backup')?></a></li> </ol> </td> |
From: Mark K <har...@us...> - 2008-03-02 18:03:43
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23144/lib/lesson Modified Files: lc_lesson.php lc_lesson_xml.php Log Message: Fixing class naming convetion for Lc_Lesson Index: lc_lesson.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson/lc_lesson.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lesson.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lesson.php 2 Mar 2008 18:03:24 -0000 1.2 *************** *** 7,15 **** * on the enrollment date for a student. */ ! class LC_Lesson { var $lessonDo = null; ! function LC_Lesson($id=-1) { if ($id > 0) { $this->lessonDo = ClassLessons::load($id); --- 7,16 ---- * on the enrollment date for a student. */ ! class Lc_Lesson { var $lessonDo = null; + var $guid = ''; ! function Lc_Lesson($id=-1) { if ($id > 0) { $this->lessonDo = ClassLessons::load($id); *************** *** 18,27 **** /** ! * Create a LC_Lesson object from a loaded dataobject * * @static */ function create($do) { ! $x = new LC_Lesson(); $x->lessonDo = $do; --- 19,28 ---- /** ! * Create a Lc_Lesson object from a loaded dataobject * * @static */ function create($do) { ! $x = new Lc_Lesson(); $x->lessonDo = $do; *************** *** 30,33 **** --- 31,41 ---- /** + * Set the GUID + */ + function setGuid($g) { + $this->guid = $g; + } + + /** * Load all lessons for this class * Index: lc_lesson_xml.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson/lc_lesson_xml.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lesson_xml.php 1 Mar 2008 23:43:19 -0000 1.1 --- lc_lesson_xml.php 2 Mar 2008 18:03:24 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- <?php + include_once(LIB_PATH.'PBDO/ClassLessons.php'); + include_once(LIB_PATH.'lesson/lc_lesson.php'); /** *************** *** 6,9 **** --- 8,129 ---- */ class Lc_Lesson_Xml { + + + /** + * return an Lc_Lesson object + * + * @static + */ + function parseNode($n) { + + /* + 'idClassLessons'=>'integer', + 'idClasses'=>'integer', + 'createdOn'=>'integer', + 'title'=>'varchar', + 'description'=>'longvarchar', + 'activeOn'=>'integer', + 'inactiveOn'=>'integer', + 'checkList'=>'longvarchar'); + */ + + $lessonDo = new ClassLessons(); + + $result = $n->getElementsByTagname('title'); + $title = $result->item(0); + + $lessonDo->title = $title->nodeValue; + + // TODO: double check the DB id belongs to this user. + $dbid = $n->getAttribute('dbid'); + $lessonDo->idClassLessons = $dbid; + + $lessonObj = Lc_Lesson::create($lessonDo); + + $guid = $n->getAttribute('guid'); + $lessonObj->setGuid($guid); + return $lessonObj; + /* + $children = $type->childNodes; + $content = ''; + if ($children->length) { + $content = trim($children->item(0)->nodeValue); + $guid = $n->getAttribute('guid'); + $dbid = $n->getAttribute('dbid'); + } + else { + die ('unknown class: '. get_class($type)); + return null; + } + + $lob = null; + $lob = new LobRepoEntry(); + $lob->set('lobGuid',$guid); + switch ($content) { + case 'content': + $lob->set('lobType','content'); + break; + case 'activity': + $lob->set('lobType','activity'); + break; + case 'test': + $lob->set('lobType','test'); + break; + } + if ($lob->lobType == '') { return null; die ('unknown type '. $content); } + + + $result = $n->getElementsByTagname('title'); + $node = $result->item(0); + $children = $node->childNodes; + $lob->set('lobTitle', trim($children->item(0)->nodeValue) ); + + $result = $n->getElementsByTagname('content'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobContent', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('filename'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobFilename', trim($children->item(0)->nodeValue) ); + + $urlTitle = Lc_Lob_Util::createLinkText(trim($children->item(0)->nodeValue)); + $lob->set('lobUrltitle', $urlTitle ); + $lob->set('lobBinary', file_get_contents($this->tempdir.'/content/'.trim($children->item(0)->nodeValue)) ); + } else { + $urlTitle = Lc_Lob_Util::createLinkText(trim( $lob->get('lobTitle')) ); + $lob->set('lobUrltitle', $urlTitle ); + } + + $result = $n->getElementsByTagname('description'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobDescription', trim($children->item(0)->nodeValue) ); + } + + + $result = $n->getElementsByTagname('subtype'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobSubType', trim($children->item(0)->nodeValue) ); + } + + $result = $n->getElementsByTagname('mime'); + $node = $result->item(0); + if (is_object($node) ){ + $children = $node->childNodes; + $lob->set('lobMime', trim($children->item(0)->nodeValue) ); + } + + return $lob; + // debug($children); + */ + } } |
From: Mark K <har...@us...> - 2008-03-02 00:06:12
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/file In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19253/file Added Files: lc_file_util.php Log Message: adding file utility functions. --- NEW FILE: lc_file_util.php --- <?php /** * Collection of static functions dealing with file IO */ class Lc_File_Util { /** * return the directory name where it is okay to store temporary files */ function getTempDir() { if ( function_exists('sys_get_temp_dir') ) { return sys_get_temp_dir(); } // Try to get from environment variable if ( !empty($_ENV['GCONF_TMPDIR']) ) { return $_ENV['GCONF_TMPDIR']; } if ( !empty($_ENV['TMP']) ) { return realpath( $_ENV['TMP'] ); } else if ( !empty($_ENV['TMPDIR']) ) { return realpath( $_ENV['TMPDIR'] ); } else if ( !empty($_ENV['TEMP']) ) { return realpath( $_ENV['TEMP'] ); } // Detect by creating a temporary file else { // Try to use system's temporary directory // as random name shouldn't exist $temp_file = tempnam( md5(uniqid(rand(), TRUE)), '' ); if ( $temp_file ) { $temp_dir = realpath( dirname($temp_file) ); unlink( $temp_file ); return $temp_dir; } else { return FALSE; } } } } |
From: Mark K <har...@us...> - 2008-03-02 00:05:44
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/file In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19176/file Log Message: Directory /cvsroot/logicampus/logicampus/src/logicreate/lib/file added to the repository |
From: Mark K <har...@us...> - 2008-03-01 23:45:22
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10834 Added Files: lc_email.php Removed Files: lcemail.php Log Message: renaming lc_email file --- lcemail.php DELETED --- --- NEW FILE: lc_email.php --- <? /* * LcEmail class * * use to send regular text mail, or to attach text, html or external files * to an email. * * sample usage * ------------ * $m = new LcEmail("ea...@jo...","pr...@un...","Subject","Regular message"); * $m->send(); * * $m = new LcEmail("ea...@jo...","pr...@un...","Subject","Regular message"); * $m->attachFile("/path/to/home/file.pdf"); * $m->send(); * * $m = new LcEmail("ea...@jo...","pr...@un...","Subject"); * $m->inlineHTML("<table width='500'><tr><td>TABLE CELL</td></tr></table>"); * $m->returnpath = "fo...@co..."; * $m->replyto = "no...@ho..."; * $m->cc = "ke...@im..."; * $m->send(); * * * this assumes 7bit content-transfer-encoding * can be changed with $m->encoding = "8bit"; * * calling this a full 'mailer' class is a bit much at this point - * it doesn't do smtp mailing or anything - it's currently just using * the php mail() command * * mgk 3/21/03 * */ class LcEmail{ var $to = ''; var $from = ''; var $subject = ''; var $body = ''; var $cc = ''; var $bcc = ''; var $returnpath = ''; var $replyto = ''; var $xmailer = "LogiCreate Mail"; var $charset = "us-ascii"; var $encoding = "7bit"; var $crflag = false; var $hasPlainText = false; function LcEmail($to='',$from='',$subject='',$body='') { $this->to = $to; $this->from = $from; $this->returnpath = $from; $this->replyto = $from; $this->subject = $subject; # $this->inlineText($body); if (trim($body )) { $this->body = $body; $this->hasPlainText = true; } } function attachFile($file, $name='', $enctype='BASE64') { $fp = fopen($file,"rb"); $f = fread($fp,filesize($file)); fclose($fp); if ($enctype=='BASE64') { $f = base64_encode($f); } $f = wordwrap($f,76,"\n",1); if ($name=='') { $temp = explode("/",$file); $temp = array_reverse($temp); $desc = $temp[0]; } else { $desc = $name; } $this->parts[] = array($enctype,$f, $desc,"attach",$this->charset); $this->hasFiles = true; } function attachText($f, $enctype='text/plain') { static $textcount; if ($desc=='') { $desc = "text".$textcount++; } $this->parts[] = array($enctype,$f, $desc,"attach",$this->charset); } function inlineText($f, $desc='inline', $enctype='text/plain') { static $textcount; if ($desc=='') { $desc = "text".$textcount++; } $this->parts[] = array($enctype,$f, $desc, "inline",$this->charset); } function attachHTML($f, $desc='', $enctype='text/html') { static $htmlcount; if ($desc=='') { $desc = "html".$htmlcount++; } $this->parts[] = array($enctype,$f, $desc, "attach",$this->charset); $this->hasHTML = true; } function inlineHTML($f, $desc='', $enctype='text/html') { static $htmlcount; if ($desc=='') { $desc = "html".$htmlcount++; } $this->parts[] = array($enctype,$f, $desc,"inline",$this->charset); $this->hasHTML = true; } function build() { $this->boundary = "LC_".time(); $this->isBuilt = true; if ($this->hasPlainText) { if (@count($this->parts)==0) { $this->message = $this->body; } else { $this->inlineText($this->body); $this->parts = array_reverse($this->parts); } } while(list($k,$v) = @each($this->parts)) { $enctype = $v[0]; $data = $v[1]; $desc = $v[2]; $disp = $v[3]; $charset = $v[4]; if ($enctype=='text/plain') { $header = "Content-Type: text/plain;\n"; $header .= " charset=\"$charset\";\n"; if ($desc!='inline') { $header .= " name=\"$desc\"\n"; } $header .= "Content-Transfer-Encoding: {$this->encoding}\n"; $header .= "Content-Disposition: $disp; "; if ($desc!='inline') { $filename="\"$desc\""; } } if ($enctype=='text/html') { $header = "Content-Type: text/html;"; $header .= " charset=\"$charset\";\n"; $header .= "Content-Transfer-Encoding: {$this->encoding}\n"; } if ($enctype=='BASE64') { $header = "Content-Type: application/octet-stream;\n"; $header .= " name=\"$desc\"\n"; $header .= "Content-Transfer-Encoding: base64\n"; $header .= "Content-Disposition: $disp; filename=\"$desc\""; } $x[] = $header."\n\n".$data."\n"; } if (is_array($x)) { $this->message .= "--".$this->boundary."\n".implode("--".$this->boundary."\n",$x)."\n--".$this->boundary."--"; $this->contenttype = "Content-Type: multipart/mixed; boundary=\"".$this->boundary."\"\n"; } else { $this->contenttype = "Content-Type: text/plain;\n"; } } function send() { if (!$this->isBuilt) { $this->build(); } $this->_extraheaders = ''; if ($this->extraheaders) { $this->_extraheaders=$this->extraheaders."\n"; } # if ($this->body!='') { $this->message = $this->body."\n\n".$this->message; } if ($this->cc!='') { $this->_extraheaders.="CC: ".$this->cc."\n"; } if ($this->bcc!='') { $this->_extraheaders.="BCC: ".$this->bcc."\n"; } if ($this->returnpath!='') { $this->_extraheaders.="Return-path: ".$this->returnpath."\n"; } if ($this->replyto!='') { $this->_extraheaders.="Reply-to: ".$this->replyto."\n"; } if ($this->xmailer!='') { $this->_extraheaders.="X-Mailer: ".$this->xmailer."\n"; } if ($this->contenttype) { $this->MIME = "MIME-Version: 1.0\n"; } // trying to resolve this for kendallhoward, at least // configs put in in unix don't display right in outlook mail??? if ($this->crflag) { $this->message = str_replace("\r","",$this->message); $this->message = str_replace("\n","\r\n",$this->message); } # return; $s = new smtp_client('dl.tccd.edu'); $s->email($this->from, $this->to,$this->to,($this->MIME.$this->contenttype.$this->_extraheaders),$this->subject,$this->message); #mail($this->to,$this->subject,$this->message,"From: {$this->from}\n{$this->contenttype}{$this->_extraheaders}"); #mail($this->to,$this->subject,$this->message,"From: <{$this->from}>\n{$this->contenttype}\n{$this->_extraheaders}"); } } class smtp_client { var $connection; var $server; var $elog_fp; var $log_file='/tmp/smtp_client.log'; var $do_log= true; // default constructor function smtp_client($server='') { if (!$server) $this->server="localhost"; else $this->server=$server; $this->connection = fsockopen($this->server, 25); if ($this->connection <= 0) return 0; $this->elog(fgets($this->connection, 1024)); $this->elog("HELO xyz\r\n", 1); fputs($this->connection,"HELO xyz\r\n"); $this->elog(fgets($this->connection, 1024)); } function email($from_mail, $to_mail, $to_name, $header, $subject, $body) { if ($this->connection <= 0) return 0; $this->elog("MAIL FROM:$from_mail", 1); fputs($this->connection,"MAIL FROM:$from_mail\r\n"); $this->elog(fgets($this->connection, 1024)); $this->elog("RCPT TO:$to_mail", 1); fputs($this->connection, "RCPT TO:$to_mail\r\n"); $this->elog(fgets($this->connection, 1024)); $this->elog("DATA", 1); fputs($this->connection, "DATA\r\n"); $this->elog(fgets($this->connection, 1024)); $this->elog("Subject: $subject", 1); $this->elog("To: $to_name", 1); fputs($this->connection,"Subject: $subject\r\n"); fputs($this->connection,"To: $to_name\r\n"); if ($header) { $this->elog($header, 1); fputs($this->connection, "$header\r\n"); } $this->elog("", 1); $this->elog($body, 1); $this->elog(".", 1); fputs($this->connection,"\r\n"); fputs($this->connection,"$body \r\n"); fputs($this->connection,".\r\n"); $this->elog(fgets($this->connection, 1024)); return 1; } function send() { if ($this->connection) { fputs($this->connection, "QUIT\r\n"); fclose($this->connection); $this->connection=0; } } function close() { $this->send(); } function elog($text, $mode=0) { if (!$this->do_log) return; // open file if (!$this->elog_fp) { if (!($this->elog_fp=fopen($this->log_file, 'a'))) return; fwrite($this->elog_fp, "\n-------------------------------------------\n"); fwrite($this->elog_fp, " Sent " . date("Y-m-d H:i:s") . "\n"); fwrite($this->elog_fp, "-------------------------------------------\n"); } // write to log if (!$mode) fwrite($this->elog_fp, " $text\n"); else fwrite($this->elog_fp, "$text\n"); } } ?> |
From: Mark K <har...@us...> - 2008-03-01 23:43:26
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9622/services/classmgr Modified Files: assignmentManage.lcp classMaterial.lcp display.lcp lessonManager.lcp Log Message: Moving libraries into sub folders. Index: classMaterial.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/classMaterial.lcp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** classMaterial.lcp 17 Feb 2008 04:35:35 -0000 1.2 --- classMaterial.lcp 1 Mar 2008 23:43:19 -0000 1.3 *************** *** 12,19 **** include_once(LIB_PATH."ClassGradebookVal.php"); ! include_once(LIB_PATH.'lc_lesson.php'); ! include_once(LIB_PATH.'lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lc_lob.php'); ! include_once(LIB_PATH.'lc_lob_class.php'); --- 12,19 ---- include_once(LIB_PATH."ClassGradebookVal.php"); ! include_once(LIB_PATH.'lesson/lc_lesson.php'); ! include_once(LIB_PATH.'lesson/lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lob/lc_lob.php'); ! include_once(LIB_PATH.'lob/lc_lob_class.php'); Index: assignmentManage.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/assignmentManage.lcp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** assignmentManage.lcp 2 Nov 2007 22:24:30 -0000 1.28 --- assignmentManage.lcp 1 Mar 2008 23:43:19 -0000 1.29 *************** *** 24,31 **** include_once(LIB_PATH."ClassGradebookVal.php"); ! include_once(LIB_PATH.'lc_lesson.php'); ! include_once(LIB_PATH.'lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lc_lob.php'); ! include_once(LIB_PATH.'lc_lob_class.php'); --- 24,31 ---- include_once(LIB_PATH."ClassGradebookVal.php"); ! include_once(LIB_PATH.'lesson/lc_lesson.php'); ! include_once(LIB_PATH.'lesson/lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lob/lc_lob.php'); ! include_once(LIB_PATH.'lob/lc_lob_class.php'); Index: display.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/display.lcp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** display.lcp 4 Oct 2007 17:13:29 -0000 1.10 --- display.lcp 1 Mar 2008 23:43:19 -0000 1.11 *************** *** 15,19 **** include_once(LIB_PATH.'SiteForms.php'); include_once(LIB_PATH.'semesterObj.php'); ! include_once(LIB_PATH.'lc_lesson.php'); include_once(LIB_PATH.'PBDO/ClassLessons.php'); --- 15,19 ---- include_once(LIB_PATH.'SiteForms.php'); include_once(LIB_PATH.'semesterObj.php'); ! include_once(LIB_PATH.'lesson/lc_lesson.php'); include_once(LIB_PATH.'PBDO/ClassLessons.php'); Index: lessonManager.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classmgr/lessonManager.lcp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** lessonManager.lcp 2 Nov 2007 00:29:06 -0000 1.46 --- lessonManager.lcp 1 Mar 2008 23:43:19 -0000 1.47 *************** *** 5,10 **** include_once(LIB_PATH.'datagrid.php'); include_once(LIB_PATH.'classLessonObj.php'); ! include_once(LIB_PATH.'lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lc_lob.php'); // PBDO is the new standard, above object is DEPRECATED include_once(LIB_PATH.'PBDO/ClassLessons.php'); --- 5,10 ---- include_once(LIB_PATH.'datagrid.php'); include_once(LIB_PATH.'classLessonObj.php'); ! include_once(LIB_PATH.'lesson/lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lob/lc_lob.php'); // PBDO is the new standard, above object is DEPRECATED include_once(LIB_PATH.'PBDO/ClassLessons.php'); |
From: Mark K <har...@us...> - 2008-03-01 23:43:26
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/gradebook In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9622/services/gradebook Modified Files: entry.lcp Log Message: Moving libraries into sub folders. Index: entry.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/gradebook/entry.lcp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** entry.lcp 8 Oct 2007 18:25:32 -0000 1.14 --- entry.lcp 1 Mar 2008 23:43:19 -0000 1.15 *************** *** 8,14 **** include_once(LIB_PATH.'lc_table.php'); include_once(LIB_PATH.'lc_table_renderer.php'); ! include_once(LIB_PATH.'lc_lob.php'); ! include_once(LIB_PATH.'lc_lesson_sequence.php'); --- 8,14 ---- include_once(LIB_PATH.'lc_table.php'); include_once(LIB_PATH.'lc_table_renderer.php'); ! include_once(LIB_PATH.'lob/lc_lob.php'); ! include_once(LIB_PATH.'lesson/lc_lesson_sequence.php'); |
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lob In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9622/lib/lob Added Files: lc_lob.php lc_lob_class.php lc_lob_class_test.php lc_lob_renderer.php lc_lob_test.php lc_lob_xml.php Log Message: Moving libraries into sub folders. --- NEW FILE: lc_lob_class_test.php --- <?php include_once(LIB_PATH.'PBDO/LobTest.php'); include_once(LIB_PATH.'PBDO/LobTestQst.php'); /** * Hold lob repo entries and lob test entries */ class Lc_Lob_ClassTest extends Lc_Lob_Class { var $type = 'test'; var $questionObjs = array(); var $mime = 'X-LMS/test'; function Lc_Lob_ClassTest($id = 0) { if ($id < 1) { $this->repoObj = new LobClassRepo(); $this->lobSub = new LobClassTest(); $this->lobMetaObj = new LobClassMetadata(); $this->lobMetaObj->createdOn = time(); } else { $this->repoObj = LobClassRepo::load($id); $tests = $this->repoObj->getLobClassTestsByLobClassRepoId(); $this->lobSub = $tests[0]; } } function addQuestion($qtext, $type = 'QUESTION_ESSAY', $choices = '', $answers = '') { $q = new LobTestQst(); $q->qstText = $qtext; if ( is_array($choices) ) { } $this->questionObjs[] = $q; } function getQuestionCount() { return count($this->questionObjs); } /** * Copy all the values of a specific sub Object to this lobSub */ function copySub(&$repoSub) { /* $this->lobSub->lobText = $repoSub->lobText; $this->lobSub->lobBinary = $repoSub->lobBinary; $this->lobSub->lobFilename = $repoSub->lobFilename; $this->lobSub->lobCaption = $repoSub->lobCaption; */ } /** * Skip the meta object for now */ function save() { if ($this->repoObj->lobGuid == '') { $guid = lcUuid(); $this->repoObj->set('lobGuid',$guid); } $this->repoObj->version++; $this->repoObj->save(); $ret = ($this->repoObj->getPrimaryKey() > 0); $this->lobSub->lobClassRepoId = $this->repoObj->getPrimaryKey(); $this->lobSub->save(); $this->lobMetaObj->updatedOn = time(); if ($this->lobMetaObj->isNew()) { //might be a brand new object $this->lobMetaObj->lobId = $this->repoObj->getPrimaryKey(); } return $this->lobMetaObj->save() && $ret; } //////////////// DEPRECATED //////////////// # Gradebook entry id # used for redirects back to the gradebook when modifying a user's score var $idClassGradebookEntries= ''; function load($id,$class_id) { if ( $class_id == '' ) { trigger_error('load with empty class id'); return false; } $array = AssessmentPeer::doSelect("class_id = $class_id and assessment_id = $id"); if (!is_array($array) ) { trigger_error('No permission to load assessment '.$id); return false; } return $array[0]; } function loadAll($class_id) { if ( $class_id == '' ) { trigger_error('Peer doSelect with empty key'); return false; } $array = AssessmentPeer::doSelect("class_id = $class_id"); return $array; } # boolean returns true if student can take the # test, false if they cannot # pass in the time stamp of when the user started taking the test # ($u->sessionvars['asmt_start_date'] for example function canTake($start) { $end = $this->dateUnavailable; $timeLimitSeconds = $this->minuteLimit * 60; $newEndingTime = $start + $timeLimitSeconds; $time = time(); /* echo '<br>'.$time. '= current time<br>'; echo $newEndingTime. '= ending time<br>'; */ if ( ($time > $newEndingTime) || ($time > $end) ) { return FALSE; } return TRUE; } function getAssessmentQuestions() { $array = AssessmentQuestionPeer::doSelect('assessment_id = \''.$this->getPrimaryKey().'\' order by question_sort'); $cc = count ($array); for($x=0; $x<$cc; ++$x) { $superObj = $array[$x]; switch($superObj->questionType) { case QUESTION_TRUEFALSE: $subObj = new AssessmentQuestionTrueFalse(); break; case QUESTION_MCHOICE: $subObj = new AssessmentQuestionMChoice(); break; case QUESTION_MANSWER: $subObj = new AssessmentQuestionMAnswer(); break; case QUESTION_MATCHING: $subObj = new AssessmentQuestionMatching(); break; case QUESTION_FILLINBLANK: $subObj = new AssessmentQuestionFill(); break; case QUESTION_ESSAY: $subObj = new AssessmentQuestionEssay(); break; default: trigger_error("Cannot find appropriate class for question. Question type was ".$superObj->questionType); } if( $superObj->assessmentQuestionId ) $subObj->_new = false; else $subObj->_new = true; $subObj->_modified = false; $subObj->assessmentQuestionId = $superObj->assessmentQuestionId; $subObj->assessmentId = $superObj->assessmentId; $subObj->questionType = $superObj->questionType; $subObj->questionSort = $superObj->questionSort; $subObj->questionDisplay = $superObj->questionDisplay; $subObj->questionText = $superObj->questionText; $subObj->questionPoints = $superObj->questionPoints; $subObj->questionChoices = $superObj->questionChoices; $subObj->fileHash = $superObj->fileHash; $subObjArray[] =$subObj; } return $subObjArray; } # $questions = array of question objects with answer object added on # $answers = array 0f answer objects # $u = user object # $grade = on / off to re-grade the assessment # If you want it to re-grade the assessment for you before sending out # the email, this does update the students grades for points_earned in the database function emailTeacher($questions, $stuUserObj, $logObj, $grade=0) { $u = $stuUserObj; $qstans .= "Student ID: ".$stuUserObj->username."\n"; $qstans .= "Name: ".$stuUserObj->profile->values['firstname']." ".$stuUserObj->profile->values['lastname']."\n"; $qstans .= "Assessment: Name ".$this->displayName."\n"; $qstans .= "Date Started: ".date('m-d-y h:i A', $u->sessionvars['asmt_date_start'])."\n"; $qstans .= "Date Stopped: ".date('m-d-y h:i A', $logObj->end_date)."\n\n"; $questionCount = count($questions); for ($i=0; $i<$questionCount; $i++) { $num = $i +1; $questionId = $questions[$i]->assessmentQuestionId; $qstans .= $num.".\n"; $qstans .= "Type of Question: ".$questions[$i]->questionDisplay."\nQuestion: ".$questions[$i]->questionText."\n"; $qstans .= "Points Assigned: ".$questions[$i]->answer->pointsEarned."\n"; if ($questions[$i]->questionType == QUESTION_MATCHING || $questions[$i]->questionType == QUESTION_MANSWER) { $answer = unserialize($questions[$i]->answer->assessmentAnswerValues); $qstans .= "Answers: \n"; for ($y=0;$y<$answerCount; $y++) { $ansnum = $y + 1; + //$qstans .= "\t $ansnum. ".$answer[$y]."\n"; + //trying out a fix for a bug where the teacher just + //gets the index of the correct answer + //MAK 11-03-04 + $qstans .= "\t $ansnum. ".$questions[$i]->questionChoices[$y]->label ." " .$answer[$y]."\n"; } } else { $qstans .= "Answer: ".$questions[$i]->answer->assessmentAnswerValues."\n\n"; } $total_points_earned += $questions[$i]->answer->pointsEarned; $total_possible_points += $questions[$i]->questionPoints; } $qstans .= "\n\nTotal Points Earned: ". $total_points_earned ." out of ". $total_possible_points; # Send email to teacher $db = DB::getHandle(); $sql = "select email from lcUsers where username='".$u->activeClassTaken->facultyId."'"; $db->queryOne($sql); $email = $db->record['email']; $subject = $this->displayName." completed by ".$u->profile->values['firstname']." ".$u->profile->values['lastname']; if ( mail($email, $subject, $qstans) ) { return TRUE; } return FALSE; } # Pulls in the last log entry for an assessment function getLastLogEntry($username) { include_once(LIB_PATH.'AssessmentLog.php'); $log = AssessmentLogPeer::doSelect("assessment_id='".$this->assessmentId."' AND id_student='".$username."' ORDER BY start_date DESC LIMIT 1"); return $log[0]; } # Loads answers onto questions object # And unserializes the matching and multiple answer questions for you automatcially function getQuestionsAndAnswers($studentId, $id_classes) { $questions = $this->getAssessmentQuestions(); $answers = AssessmentAnswerPeer::doSelect("assessment_id='".$this->assessmentId."' AND student_id='".$studentId."' AND id_classes='".$id_classes."'"); #debug($answers,1); $this->questionCount = count($questions); $answerCount = count($answers); for ($i=0; $i<$this->questionCount; $i++) { $num = $i +1; $questionId = $questions[$i]->assessmentQuestionId; for($x=0; $x<$answerCount; $x++) { if ($answers[$x]->assessmentQuestionId == $questionId) { #$questions[$i]->grade($answers[$x]); $questions[$i]->answer = $answers[$x]; # debug($questions[$i],1); if ($questions[$i]->questionType == QUESTION_MATCHING || $questions[$i]->questionType == QUESTION_MANSWER) { $questions[$i]->answer->assessmentAnswerValues = unserialize($questions[$i]->answer->assessmentAnswerValues); } else { $qstans .= "Answer: ".$questions[$i]->answer->assessmentAnswerValues."\n\n"; } } $this->pointsEarned += $questions[$i]->answer->pointsEarned; } $this->totalPoints += $questions[$i]->questionPoints; } return $questions; } # Loads the answers for a student for a given class and # update the gradebook score # Normally called in assessements/grade/event=updatePoints # MAK added 9/4/03 # always update gradebook scores in entries table to fix previous problem function updateGradebookScore($studentId, $id_classes) { $answer = AssessmentAnswerPeer::doSelect("student_id='$studentId' AND id_classes='$id_classes' AND assessment_id='".$this->assessmentId."'"); $count = count($answer); for ($i=0; $i<$count; $i++) { if ($answer[$i]->pointsGiven) { $totalPoints += $answer[$i]->pointsGiven; } else { $totalPoints += $answer[$i]->pointsEarned; } } $entry = $this->loadGradebookEntry($studentId); if (is_object($entry) ) { $entryId = $entry->getPrimaryKey(); $val = $this->loadGradebookVal($entryId, $studentId); if (is_object($val) ) { $val->score = $totalPoints; $val->save(); return $totalPoints; } else { # create val entry $val = new ClassGradebookVal(); $val->idClasses = $id_classes; $val->username = $studentId; $val->score = $totalPoints; $val->dateCreated = date('Y-m-d H:i:s'); $val->idClassGradebookEntries = $entryId; //__FIXME__ make comments field accept nulls // class_gradebook_val $val->save(); return $totalPoints; } } return $totalPoints; } function loadGradebookEntry($studentId) { include_once(LIB_PATH.'ClassGradebookEntries.php'); $entry = ClassGradebookEntriesPeer::doSelect("assessment_id='".$this->assessmentId."'"); $this->idClassGradebookEntries = $entry[0]->idClassGradebookEntries; return $entry[0]; } function loadGradebookVal($entryId, $studentId) { include_once(LIB_PATH.'ClassGradebookVal.php'); $val = ClassGradebookValPeer::doSelect("id_class_gradebook_entries='".$entryId."' AND username='".$studentId."'"); return $val[0]; } # Returns BOOL if the test has already been taken # or started by a student function isTaken() { include_once(LIB_PATH.'AssessmentLog.php'); $log = AssessmentLogPeer::doSelect("assessment_id='".$this->assessmentId."' AND id_classes='".$this->classId."'"); $count = count($log); if ($count) { return TRUE; } return FALSE; } } ?> --- NEW FILE: lc_lob_test.php --- <?php include_once(LIB_PATH.'PBDO/LobTest.php'); include_once(LIB_PATH.'PBDO/LobTestQst.php'); /** * Hold lob repo entries and lob test entries */ class Lc_Lob_Test extends Lc_Lob { var $type = 'test'; var $questionObjs = array(); var $mime = 'X-LMS/test'; function Lc_Lob_Test($id = 0) { if ($id < 1) { $this->repoObj = new LobRepoEntry(); $this->repoObj->lobMime = $this->mime; $this->repoObj->lobType = $this->type; $this->repoObj->lobSubType = $this->type; $this->lobSub = new LobTest(); $this->lobMetaObj = new LobMetadata(); $this->lobMetaObj->createdOn = time(); } else { $this->repoObj = LobRepoEntry::load($id); $tests = $this->repoObj->getLobTestsByLobRepoEntryId(); $this->lobSub = $tests[0]; } } function setTitle($t) { $this->repoObj->set('lobTitle', $t); } function setInstructions($i) { $this->repoObj->set('lobDescription', $i); } function setNotes($n) { $this->repoObj->set('lobNotes', $n); } function setQuestion($qidx, $qtext, $type = 'QUESTION_ESSAY', $choices = '', $answers = '') { $q = $this->_makeQuestion($qtext, $type, $choices, $answers); if ($qidx > -1) { $this->questionObjs[$qidx] = $q; } else { $this->questionObjs[] = $q; } } function addQuestion($qtext, $type = 'QUESTION_ESSAY', $choices = '', $answers = '') { $q = $this->_makeQuestion($qtext, $type, $choices, $answers); $this->questionObjs[] = $q; } function getQuestionCount() { return count($this->questionObjs); } function _makeQuestion($qtext, $type, $choices, $answers='') { $q = new LobTestQst(); $q->qstChoices = array(); $q->qstText = $qtext; $q->questionTypeId = constant($type); if ( is_array($choices) ) { } return $q; } /** * * @return bool successfully added the choice */ function addLabel($l, $correct, $qidx=-1) { if ($qidx == -1) { $qidx = $this->getQuestionCount()-1; } if ($qidx == -1) { return false; } $lidx = count($this->questionObjs[$qidx]->qstChoices); if ($lidx == -1) { $lidx = 0; } $this->questionObjs[$qidx]->qstChoices[$lidx]['label'] = $l; $this->questionObjs[$qidx]->qstChoices[$lidx]['correct'] = $correct; return true; } } ?> --- NEW FILE: lc_lob_class.php --- <?php include_once(LIB_PATH.'lob/lc_lob.php'); include_once(LIB_PATH.'PBDO/LobClassRepo.php'); include_once(LIB_PATH.'PBDO/LobClassContent.php'); include_once(LIB_PATH.'PBDO/LobClassActivity.php'); include_once(LIB_PATH.'PBDO/LobClassTest.php'); include_once(LIB_PATH.'PBDO/LobClassMetadata.php'); class Lc_Lob_Class extends Lc_Lob { var $repoObj; var $lobSub; var $lobMetaObj = null; var $type = 'unknown'; function Lc_Lob_Class($id=-1) { if ($id < 1) { $this->repoObj = new LobClassRepo(); $this->lobMetaObj = new LobMetadata(); $this->lobMetaObj->createdOn = time(); } else { $this->repoObj = LobClassRepo::load($id); $this->lobMetaObj = LobMetadata::load(array('lob_id'=>$id, 'lob_kind'=>$this->repoObj->lobType)); } } /** * Load a specific sub lob based on this type */ function loadSub() { switch($this->type) { case 'content': if ($this->repoObj->getPrimaryKey() > 0) { $results = $this->repoObj->getLobClassContentsByLobClassRepoId(); $this->lobSub = $results[0]; } else { $this->lobSub = new LobClassContent(); } break; case 'activity': if ($this->repoObj->getPrimaryKey() > 0) { $results = $this->repoObj->getLobClassActivitysByLobClassRepoId(); $this->lobSub = $results[0]; } else { $this->lobSub = new LobClassActivity(); } /* $results = $this->getLobActivitysByLobRepoEntryId(); if (! count($results) ) { trigger_error('learning object missing internal data.'); return null; } $subLob = $results[0]; include_once(LIB_PATH.'lc_lob_class.php'); $classLob = new Lc_Lob_ClassActivity(); trigger_error('un-implemented'); */ break; case 'test': if ($this->repoObj->getPrimaryKey() > 0) { $results = $this->repoObj->getLobClassTestsByLobClassRepoId(); $this->lobSub = $results[0]; } if (! is_object($this->lobSub)) { $this->lobSub = new LobClassTest(); } /* $results = $this->getLobTestsByLobRepoEntryId(); if (! count($results) ) { trigger_error('learning object missing internal data.'); return null; } $subLob = $results[0]; include_once(LIB_PATH.'lc_lob_class.php'); $classLob = new Lc_Lob_ClassTest(); trigger_error('un-implemented'); */ break; } } /** * Skip the meta object for now */ function save() { if ($this->repoObj->lobGuid == '') { $guid = lcUuid(); $this->repoObj->set('lobGuid',$guid); } $this->repoObj->version++; $this->repoObj->save(); $ret = ($this->repoObj->getPrimaryKey() > 0); $this->lobMetaObj->updatedOn = time(); if ($this->lobMetaObj->isNew()) { //might be a brand new object $this->lobMetaObj->lobId = $this->repoObj->getPrimaryKey(); } return $this->lobMetaObj->save() && $ret; } /** * Return the primary key */ function getRepoId() { return $this->repoObj->lobClassRepoId; } } class Lc_Lob_ClassContent extends Lc_Lob_Class { var $type = 'content'; function Lc_Lob_ClassContent($id=-1) { if ($id < 1) { $this->repoObj = new LobClassRepo(); $this->lobSub = new LobClassContent(); } else { $this->repoObj = LobClassRepo::load($id); $this->lobSub = LobClassContent::load($id); } } /** * Copy all the values of a specific sub Object to this lobSub */ function copySub(&$repoSub) { $this->lobSub->lobText = $repoSub->lobText; $this->lobSub->lobBinary = $repoSub->lobBinary; $this->lobSub->lobFilename = $repoSub->lobFilename; $this->lobSub->lobCaption = $repoSub->lobCaption; } /** * Skip the meta object for now */ function save() { if ($this->repoObj->lobGuid == '') { $guid = lcUuid(); $this->repoObj->set('lobGuid',$guid); } $this->repoObj->version++; $this->repoObj->save(); $ret = ($this->repoObj->getPrimaryKey() > 0); $this->lobSub->lobClassRepoId = $this->repoObj->getPrimaryKey(); $this->lobSub->save(); $this->lobMetaObj->updatedOn = time(); if ($this->lobMetaObj->isNew()) { //might be a brand new object $this->lobMetaObj->lobId = $this->repoObj->getPrimaryKey(); } return $this->lobMetaObj->save() && $ret; } } class Lc_Lob_ClassActivity extends Lc_Lob_Class { var $type = 'activity'; function Lc_Lob_ClassActivity($id=-1) { include_once(LIB_PATH.'PBDO/LobClassActivity.php'); if ($id < 1) { $this->repoObj = new LobClassRepo(); $this->lobSub = new LobClassActivity(); } else { $this->repoObj = LobClassRepo::load($id); $subs = LobClassActivityPeer::doSelect( 'lob_class_repo_id = '.$id); $this->lobSub = $subs[0]; } } /** * Copy all the values of a specific sub Object to this lobSub */ function copySub(&$repoSub) { $this->lobSub->responseTypeId = $repoSub->responseTypeId; /* $this->lobSub->instructions = $repoSub->lobDescription; $this->lobSub->lobFilename = $repoSub->lobFilename; $this->lobSub->lobCaption = $repoSub->lobCaption; */ } /** * Skip the meta object for now */ function save() { if ($this->repoObj->lobGuid == '') { $guid = lcUuid(); $this->repoObj->set('lobGuid',$guid); } $this->repoObj->version++; $this->repoObj->save(); $ret = ($this->repoObj->getPrimaryKey() > 0); $this->lobSub->lobClassRepoId = $this->repoObj->getPrimaryKey(); $this->lobSub->save(); $this->lobMetaObj->updatedOn = time(); if ($this->lobMetaObj->isNew()) { //might be a brand new object $this->lobMetaObj->lobId = $this->repoObj->getPrimaryKey(); } return $this->lobMetaObj->save() && $ret; } } ?> --- NEW FILE: lc_lob_xml.php --- <?php /** * Process Learning Object XML formats */ class Lc_Lob_Xml { } ?> --- NEW FILE: lc_lob_renderer.php --- <?php class LC_Lob_Renderer { function getMetadataForm() { $subject = array(); $subject[] = array( 'fieldName' => 'md_subj', 'displayName' => 'Subject', 'type' => 'text', ); $subdisc = array(); $subdisc[] = array( 'fieldName' => 'md_subdisc', 'displayName' => 'Sub-Discipline', 'type' => 'text', ); $author = array(); $author[] = array( 'fieldName' => 'md_author', 'displayName' => 'Author', 'type' => 'text', ); $copyright = array(); $copyright[] = array( 'fieldName' => 'md_copyright', 'displayName' => 'Copyright Year', 'type' => 'text', ); $license = array(); $license[] = array( 'fieldName' => 'md_license', 'displayName' => 'License', 'type' => 'text', ); return array($subject, $subdisc, $author, $copyright, $license); /* [1] => Array ( [0] => Array ( [pkey] => 2147483687 [formId] => 2147483654 [type] => text [fieldName] => txTitle [displayName] => Enter content title. [defaultValue] => [exp] => [validationType] => default [message] => [stripTags] => N [allowedTags] => [min] => 2 [max] => 255 [req] => Y [sort] => 1 [size] => 50 [maxlength] => 255 [selectOptions] => [checked] => [multiple] => [useValue] => [cols] => 0 [rows] => 0 [image] => [parentPkey] => 0 [rowStyle] => [groups] => Array ( [0] => reg ) [notgroups] => [row] => 1 [startYear] => [endYear] => [dateTimeBit] => [extra] => ) ) * */ } } ?> --- NEW FILE: lc_lob.php --- <?php include_once(LIB_PATH.'PBDO/LobRepoEntry.php'); include_once(LIB_PATH.'PBDO/LobMetadata.php'); include_once(LIB_PATH.'PBDO/LobContent.php'); //sub types include_once(LIB_PATH.'PBDO/LobTest.php'); include_once(LIB_PATH.'PBDO/LobActivity.php'); /** * Base class for all lob types (content, test, activity) */ class Lc_Lob { var $repoObj; var $lobSub = null; var $lobMetaObj; var $type = 'unknown'; function Lc_Lob($id=-1) { if ($id < 1) { $this->repoObj = new LobRepoEntry(); $this->lobMetaObj = new LobMetadata(); $this->lobMetaObj->createdOn = time(); } else { $this->repoObj = LobRepoEntry::load($id); $this->lobMetaObj = LobMetadata::load(array('lob_repo_entry_id'=>$id)); $this->type = $this->repoObj->lobType; } } function isImage() { return $this->repoObj->lobSubType == 'image'; } /** * Document style content, word processing files, audio, etc */ function isFile() { return $this->repoObj->lobSubType == 'document'; } /** * Acitivty/assignment style content. homework, upload a file, etc. */ function isActivity() { return $this->repoObj->lobType == 'activity'; } /** * Test/exam style content. */ function isTest() { return $this->repoObj->lobType == 'test'; } function isText() { return $this->repoObj->lobSubType == 'text'; } function get($key) { return $this->repoObj->{$key}; } function getMeta($key) { return $this->lobMetaObj->{$key}; } function set($key,$val) { $this->repoObj->set($key,$val); } function setMeta($key,$val) { $this->lobMetaObj->set($key,$val); } /** * Get version **/ function getVersion() { return $this->repoObj->lobVersion; } /** * Get Metadata **/ function getLicense() { return $this->lobMetaObj->license; } /** * Get Metadata **/ function getCopyright() { return $this->lobMetaObj->copyright; } /** * Get Metadata **/ function getSource() { return $this->lobMetaObj->source; } /** * Get Metadata **/ function getAuthor() { return $this->lobMetaObj->author; } /** * Get Metadata **/ function getSubject() { return $this->lobMetaObj->subject; } /** * Get Metadata **/ function getSubdiscipline() { return $this->lobMetaObj->subdisc; } /** * Get Metadata **/ function getEditedOn() { if ($this->lobMetaObj->updatedOn < 1) { return 'unknown'; } return date('M d \'y',$this->lobMetaObj->updatedOn); } /** * Get Metadata **/ function getCreatedOn() { if ($this->lobMetaObj->createdOn < 1) { return 'unknown'; } return date('M d \'y',$this->lobMetaObj->createdOn); } /** * Return the text to create a link to this object */ function getUrl() { return $this->repoObj->lobUrltitle; } /** * Return the type */ function getType() { return $this->repoObj->lobType; } /** * Return the sub type */ function getSubType() { return $this->repoObj->lobSubType; } /** * Return the primary key */ /* function getContentId() { return $this->repoObj->lobContentId; } */ /** * Return the primary key */ function getRepoId() { return $this->repoObj->lobRepoEntryId; } function updateAsFile($title, $subType = 'document') { $this->set('lobSubType',$subType); $this->set('lobTitle', $title); $n = $this->lobSub->lobFilename; $ext = substr ( $n, (strrpos($n, '.') - strlen($n) +1) ); $ext = strtolower($ext); $m = Lc_Lob_Util::getMimeForSubtype($subType,$ext); $this->set('lobMime', $m); } function updateAsText($title, $subType = 'text') { $this->set('lobSubType',$subType); $this->set('lobTitle', $title); } function makePublic() { $this->lobMetaObj->private = 0; } function makePrivate() { $this->lobMetaObj->private = 1; } function isPrivate() { if ($this->lobMetaObj->private ) { return 'yes'; } else { return 'no'; } } function updateMeta($vars) { $this->setMeta('lobKind','content'); $this->setMeta('author', $vars['md_author']); $this->setMeta('source', $vars['md_source']); $this->setMeta('copyright', $vars['md_copyright']); $this->setMeta('license', $vars['md_license']); $this->setMeta('subject', $vars['md_subj']); $this->setMeta('subdisc', $vars['md_subdisc']); } function save() { if ($this->repoObj->lobGuid == '') { $guid = lcUuid(); $this->repoObj->set('lobGuid',$guid); } if ($this->repoObj->lobType == '') { $this->repoObj->lobType = $this->type; } $this->repoObj->lobVersion++; $this->repoObj->save(); $ret = ($this->repoObj->getPrimaryKey() > 0); $this->lobSub->lobRepoEntryId = $this->repoObj->getPrimaryKey(); $this->lobSub->save(); $this->lobMetaObj->updatedOn = time(); $this->lobMetaObj->lobRepoEntryId = $this->repoObj->getPrimaryKey(); if ($this->lobMetaObj->isNew()) { //might be a brand new object $this->lobMetaObj->lobRepoEntryId = $this->repoObj->getPrimaryKey(); } $this->lobMetaObj->save(); $meta = ($this->lobMetaObj->getPrimaryKey() > 0); return $meta && $ret; } /** * Must be called by subclasses */ function &getRepoEntry() { return $this->repoObj; } function &getMetadata() { return $this->lobMetaObj; } /** * Make a copy or reference (link) of this lob in the * class_repo. */ function useInClass($classId = -1, $copyStyle = 'notify') { $subLob = null; $classRepo = null; $classMeta = null; if ($this->type == 'unknown') { return null; } $repo = $this->getRepoEntry(); $meta = $this->getMetadata(); switch($this->type) { case 'content': $results = $repo->getLobContentsByLobRepoEntryId(); if (! count($results) ) { trigger_error('learning object missing internal data.'); return null; } $subLob = $results[0]; include_once(LIB_PATH.'lc_lob_class.php'); $classLob = new Lc_Lob_ClassContent(); break; case 'activity': case 'interaction': $results = $repo->getLobActivitysByLobRepoEntryId(); if (! count($results) ) { trigger_error('learning object missing internal data.'); return null; } $subLob = $results[0]; include_once(LIB_PATH.'lc_lob_class.php'); $classLob = new Lc_Lob_ClassActivity(); break; case 'test': include_once(LIB_PATH.'lc_lob_test.php'); $results = $repo->getLobTestsByLobRepoEntryId(); if (! count($results) ) { trigger_error('learning object missing internal data.'); return null; } $subLob = $results[0]; include_once(LIB_PATH.'lc_lob_class.php'); include_once(LIB_PATH.'lc_lob_class_test.php'); $classLob = new Lc_Lob_ClassTest(); break; } //load or make a new class repository entry $classRepo = LobClassRepo::load( array ('lob_repo_entry_id'=> $repo->lobRepoEntryId) ); if (isset($classRepo)) { } else { $classRepo = new LobClassRepo(); $classRepo->type = $this->type; } //load or make a new class metadata entry $classMeta = LobClassMetadata::load( array ('lob_class_repo_id'=> $classRepo->lobClassRepoId) ); if (isset($classMeta)) { } else { $classMeta = new LobClassMetadata(); $classMeta->lobClassRepoId = $classRepo->lobClassRepoId; } $classLob->repoObj = $classRepo; $classLob->lobMetaObj = $classMeta; $classLob->loadSub(); //copy all values to classRepoEntry // $classLob->repoObj->classId = $classId; $classLob->repoObj->lobRepoEntryId = $repo->get('lobRepoEntryId'); $classLob->repoObj->lobGuid = $repo->get('lobGuid'); $classLob->repoObj->lobCopyStyle = $copyStyle; $classLob->repoObj->lobType = $repo->lobType; $classLob->repoObj->lobSubType = $repo->lobSubType; $classLob->repoObj->lobVersion = $repo->lobVersion; $classLob->repoObj->lobBytes = $repo->lobBytes; $classLob->repoObj->lobTitle = $repo->lobTitle; $classLob->repoObj->lobUrltitle = $repo->lobUrltitle; $classLob->repoObj->lobMime = $repo->lobMime; $classLob->repoObj->lobDescription = $repo->lobDescription; //copy all the values to lobClassMetadata // $classLob->lobMetaObj->subject = $meta->subject; $classLob->lobMetaObj->subdisc = $meta->subdisc; $classLob->lobMetaObj->author = $meta->author; $classLob->lobMetaObj->source = $meta->source; $classLob->lobMetaObj->copyright = $meta->copyright; $classLob->lobMetaObj->license = $meta->license; $classLob->lobMetaObj->userVersion = $meta->userVersion; $classLob->lobMetaObj->status = $meta->status; $classLob->lobMetaObj->updatedOn = $meta->updatedOn; $classLob->lobMetaObj->createdOn = $meta->createdOn; //update values of the sub object // $classLob->copySub($subLob); //save, get id // $classLob->save(); return $classLob; } } /** * Hold lob repo entries and lob content entries */ class Lc_Lob_Content extends Lc_Lob { var $type = 'content'; function Lc_Lob_Content($id = -1) { if ($id < 1) { $this->lobSub = new LobContent(); $this->repoObj = new LobRepoEntry(); $this->lobMetaObj = new LobMetadata(); $this->lobMetaObj->createdOn = time(); } else { $this->repoObj = LobRepoEntry::load($id); $content = $this->repoObj->getLobContentsByLobRepoEntryId(); $this->lobSub = $content[0]; $this->lobMetaObj = LobMetadata::load(array('lob_repo_entry_id'=>$id)); } } /** * Set the textual content */ function setTextContent(&$content) { $this->lobSub->lobText =& $content; $this->repoObj->lobSubType = 'text'; $this->repoObj->lobBytes = strlen($content); $this->lobSub->lobBinary = null; } /** * Set the textual content */ function setBinContent(&$binary) { $this->lobSub->lobBinary =& $binary; $this->repoObj->lobSubType = 'document'; $this->repoObj->lobBytes = strlen($binary); $this->lobSub->lobText = null; } /** * Set the textual content */ function setFile($filename, $filetitle = '') { if ($filetitle == '') { $filetitle = basename($filename); } $binary = file_get_contents($filename); $this->setBinContent($binary); $this->lobSub->lobFilename = $filetitle; } /** * Return the caption for this content, mostly for images */ function getCaption() { return $this->lobSub->lobCaption; } /** * Set the caption for this content, mostly for images */ function setCaption($cap) { $this->lobSub->lobCaption = $cap; } function getFilename() { return $this->lobSub->lobFilename; } /** * Return the text content contained in "lobSub" */ function getTextContent() { return $this->lobSub->lobText; } } /** * Hold lob repo entries and lob activity entries */ class Lc_Lob_Activity extends Lc_Lob { var $type = 'activity'; var $questionObjs = array(); var $mime = 'X-LMS/activity'; function Lc_Lob_Activity($id = -1) { if ($id < 1) { $this->repoObj = new LobRepoEntry(); $this->lobSub = new LobActivity(); $this->lobMetaObj = new LobMetadata(); $this->lobMetaObj->createdOn = time(); $this->repoObj->lobMime = $this->mime; } else { $this->repoObj = LobRepoEntry::load($id); $tests = $this->repoObj->getLobActivitysByLobRepoEntryId(); $this->lobSub = $tests[0]; $this->lobMetaObj = LobMetadata::load(array('lob_repo_entry_id'=>$id)); } } /** * Available response types are: * * 1 = upload file * 2 = text response * 3 = upload & text * 4 = forum post * 5 = None * 6 = audio */ function setResponseType($typeInt=5) { $this->lobSub->responseTypeId = $typeInt; } function getResponseTypeName($typeInt=-1) { if ($typeInt == -1) { $typeInt = $this->lobSub->responseTypeId; } switch ($typeInt) { case 1: return 'File Upload'; case 2: return 'Text Response'; case 3: return 'File Upload and Text Response'; case 4: return 'Forum Post'; case 5: return 'None'; case 6: return 'Audio Recording'; } } } /** * Handle static functions to reduce the size of Lc_Lob class */ class Lc_Lob_Util { /** * @static */ function getMimeIcon($mime) { switch ($mime) { case 'text/html': return 'html.png'; break; case 'application/pdf': return 'pdf.png'; break; case 'application/octet-stream': return 'document.png'; break; case 'X-LMS/assessment': case 'X-LMS/test': return 'quiz.png'; break; case 'X-LMS/assignment': case 'X-LMS/activity': case 'X-LMS/interaction': return 'activity.png'; break; case 'image/': case 'image/jpeg': case 'image/jpg': case 'image/gif': case 'image/bmp': case 'image/png': case 'image/mng': return 'image.png'; break; default: return 'document.png'; break; } } /** * @static */ function getSubTypeIcon($subType) { return Lc_Lob_Util::getMimeIcon( Lc_Lob_Util::getMimeForSubtype($subType)); } /** * Return an internet MIME for a specific sub-type. * Optional extension for generic sub-types like "open office" * * @static */ function getMimeForSubtype($subtype,$ext='') { if ($ext == 'jpeg' || $ext == 'pjpeg' || $ext == 'jpg') { $ext = 'jpeg'; } switch($subtype) { case 'text': return 'text/plain'; case 'wiki': return 'text/wiki'; case 'html': return 'text/html'; case 'image': return 'image/'.$ext; } if ($subtype == 'document' || $subtype == 'doc') { switch($ext) { case 'pdf': return 'application/pdf'; break; case 'sxw': return 'application/vnd.sun.xml.writer'; break; case 'sxc': return 'application/vnd.sun.xml.calc'; break; } } if ($subtype == 'audio') { switch($ext) { case 'mp3': return 'audio/mpeg'; break; } } return "application/octet-stream"; } /** * Make the text URL friendly by removing characters that would * have to be URL encoded to be valid. * * @static */ function createLinkText($name,$ext='') { $ext = strtolower($ext); $ret = str_replace('&', ' and ', $name); $ret = str_replace(' ', '_', $ret); $pattern = '/[\x{21}-\x{2C}]|[\x{2F}]|[\x{5B}-\x{5E}]|[\x{7E}]/'; $ret = preg_replace($pattern, '_', $ret); $ret = str_replace('___', '_', $ret); $ret = str_replace('__', '_', $ret); $ret = str_replace('__', '_', $ret); if ($ext != '' && $ext != 'html' && $ext != 'htm') { $ret .= '.'.$ext; } return $ret; } /** * Return a number of bytes as at least 0.00 kilobytes */ function formatBytes($intSize) { return sprintf('%0.2f', ($intSize/1000)). ' Kb'; } } ?> |
From: Mark K <har...@us...> - 2008-03-01 23:43:25
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/services/classroom In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9622/services/classroom Modified Files: assignments.lcp viewer.lcp Log Message: Moving libraries into sub folders. Index: assignments.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classroom/assignments.lcp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** assignments.lcp 26 Jan 2008 21:35:45 -0000 1.16 --- assignments.lcp 1 Mar 2008 23:43:19 -0000 1.17 *************** *** 4,11 **** */ include_once(LIB_PATH.'datagrid.php'); ! include_once(LIB_PATH.'lc_lesson.php'); ! include_once(LIB_PATH.'lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lc_lob.php'); ! include_once(LIB_PATH.'lc_lob_class.php'); include_once(SERVICE_PATH.'pm/privmess.php'); --- 4,11 ---- */ include_once(LIB_PATH.'datagrid.php'); ! include_once(LIB_PATH.'lesosn/lc_lesson.php'); ! include_once(LIB_PATH.'lesosn/lc_lesson_sequence.php'); ! include_once(LIB_PATH.'lob/lc_lob.php'); ! include_once(LIB_PATH.'lob/lc_lob_class.php'); include_once(SERVICE_PATH.'pm/privmess.php'); Index: viewer.lcp =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/services/classroom/viewer.lcp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** viewer.lcp 5 Oct 2007 22:37:38 -0000 1.16 --- viewer.lcp 1 Mar 2008 23:43:19 -0000 1.17 *************** *** 2,6 **** include_once(LIB_PATH.'classLessonContentObj.php'); ! include_once(LIB_PATH.'lc_lob.php'); //include_once(LIB_PATH.'datagrid.php'); include_once(LIB_PATH.'PBDO/ClassLessonSequence.php'); --- 2,6 ---- include_once(LIB_PATH.'classLessonContentObj.php'); ! include_once(LIB_PATH.'lob/lc_lob.php'); //include_once(LIB_PATH.'datagrid.php'); include_once(LIB_PATH.'PBDO/ClassLessonSequence.php'); |
From: Mark K <har...@us...> - 2008-03-01 23:43:25
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib/lesson In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9622/lib/lesson Added Files: lc_lesson.php lc_lesson_sequence.php lc_lesson_xml.php Log Message: Moving libraries into sub folders. --- NEW FILE: lc_lesson.php --- <?php include_once(LIB_PATH.'PBDO/ClassLessons.php'); /** * A lesson is the wrapper for content and content sequence for * a particular timeframe. The time may be based on a semester, or * on the enrollment date for a student. */ class LC_Lesson { var $lessonDo = null; function LC_Lesson($id=-1) { if ($id > 0) { $this->lessonDo = ClassLessons::load($id); } } /** * Create a LC_Lesson object from a loaded dataobject * * @static */ function create($do) { $x = new LC_Lesson(); $x->lessonDo = $do; return $x; } /** * Load all lessons for this class * * @static */ function loadClassLessons($classId) { $classId = intval($classId); if ($classId ==0 ) { lcError::throwError(E_USER_ERROR,'no class id specified'); return false; } $db = DB::getHandle(); $sql = "SELECT cl.* FROM class_lessons as cl WHERE id_classes = ".$classId." ORDER BY activeOn ASC"; $ret = array(); $db->query($sql); while ($db->nextRecord() ) { $temp = ClassLessonsPeer::row2Obj($db->record); $wrapper = LC_Lesson::create($temp); $ret[] = $wrapper; } return $ret; } /** * Count 'content' items linked to this lesson in class_lesson_sequence */ function getContentCount() { $db = DB::getHandle(); $sql = "SELECT count(class_lesson_sequence_id) as total FROM class_lesson_sequence WHERE lesson_id = ".$this->lessonDo->getPrimaryKey()." AND lob_type = 'content' "; $db->query($sql); $db->nextRecord(); $db->freeResult(); return $db->record['total']; } /** * Count 'interaction' items linked to this lesson in class_lesson_sequence */ function getObjectCountByType($type='content') { $db = DB::getHandle(); $sql = "SELECT count(class_lesson_sequence_id) as total FROM class_lesson_sequence WHERE lesson_id = ".$this->lessonDo->getPrimaryKey()." AND lob_type = '".$type."' "; $db->query($sql); $db->nextRecord(); $db->freeResult(); return $db->record['total']; } /** * __TODO__ make this relative to when a user enrolls */ function getStartDate() { return $this->lessonDo->activeOn; } /** * Returns integer representing the number of days left until this lesson starts */ function daysTilStart() { $days = floor(($this->lessonDo->activeOn - time()) / 86400); if ($days < 1) { return 0;} return $days; } /** * Returns integer representing the number of days left until this lesson ends */ function daysTilEnd() { $days = floor(($this->lessonDo->inactiveOn - time()) / 86400); if ($days < 1) { return 0;} return $days; } /** * Access Getters */ function getId() { return $this->lessonDo->getPrimaryKey(); } /** * Access Getters */ function getTitle() { return $this->lessonDo->title; } /** * Is this lesson over? */ function isFinished() { return $this->lessonDo->inactiveOn < time(); } /** * Store a lesson into the users' session */ function storeLessonInSession($lessonId, &$u) { $ut = time(); $db = DB::getHandle(); $sql = "select * from class_lessons where id_class_lessons='".$lesson_id."' and id_classes='{$u->activeClassTaken->id_classes}'"; if (!$u->isFaculty()) $sql .= " and (activeOn < ".time()." and inactiveOn > ".time().')'; $db->queryOne($sql); $u->sessionvars['activeLesson'] = $db->record; } /** * Find a lesson ID for a particular sequence */ function getLessonIdForSequenceId($seqId) { $seqObj = ClassLessonSequence::load($seqId); return $seqObj->lessonId; } } ?> --- NEW FILE: lc_lesson_sequence.php --- <?php include_once(LIB_PATH.'PBDO/ClassLessonSequence.php'); class LC_LessonSequence { var $lessonId = -1; var $classId = -1; var $items = array(); function LC_LessonSequence($lessonId,$classId) { $this->lessonId = $lessonId; $this->classId = $classId; } /** * Load all class_lesson_sequence items and store them in ->items */ function loadItems() { $this->items = ClassLessonSequencePeer::doSelect( 'class_id = '.$this->classId.' and lesson_id = '.$this->lessonId. ' order by rank'); } function fetchObject($sequenceId) { $type = 'content'; $repoId = -1; foreach ($this->items as $seqItem) { if ($seqItem->classLessonSequenceId == $sequenceId) { $type = $seqItem->lobType; $repoId = $seqItem->lobClassRepoId; } } if ($repoId == -1) { return null; } switch($type) { case 'activity': $activityLob = new Lc_Lob_ClassActivity($repoId); return $activityLob; break; } } function getSequence($sequenceId) { foreach ($this->items as $seqItem) { if ($seqItem->classLessonSequenceId == $sequenceId) { return $seqItem; } } } function getStartDate(&$lessonObj, $sequenceId) { foreach ($this->items as $seqItem) { if ($seqItem->classLessonSequenceId == $sequenceId) { return $lessonObj->getStartDate() + $seqItem->startOffset; } } } function getDueDate(&$lessonObj, $sequenceId) { foreach ($this->items as $seqItem) { if ($seqItem->classLessonSequenceId == $sequenceId) { if ($seqItem->dueOffset == 0) { return 0;} return $lessonObj->getStartDate() + $seqItem->dueOffset; } } } function isPastDueDate(&$lessonObj, $sequenceId) { $dueDate = $this->getDueDate($lessonObj, $sequenceId); if ($dueDate <= time() ) { return false; } return true; } function updateAssignments($contentIds,$lobData) { if (count($contentIds) < 1) { $contentIds = array(0);} $this->updateSequence($contentIds, $lobData, 'activity'); } function updateTests($contentIds,$lobData) { if (count($contentIds) < 1) { $contentIds = array(0);} $this->updateSequence($contentIds, $lobData, 'test'); } function updateContent($contentIds,$lobData) { if (count($contentIds) < 1) { $contentIds = array(0);} $this->updateSequence($contentIds, $lobData, 'content'); } function setStartDay($objIdx, $intDays) { $this->items[$objIdx]->startOffset = $intDays * (60*60*24); } function setStartTime($objIdx, $timestamp) { $this->items[$objIdx]->startTime = $timestamp; } function getStartDay($objIdx) { return $this->items[$objIdx]->startOffset / (60/60/24); } function getStartTime($objIdx) { return $this->items[$objIdx]->startTime; } /** * Must be set after startDay */ function setDueDay($objIdx, $intDays) { if ($intDays == -1) { $this->items[$objIdx]->dueOffset = -1; } else { $this->items[$objIdx]->dueOffset = $intDays * (60*60*24); $this->items[$objIdx]->dueOffset += $this->items[$objIdx]->startOffset; } } /** * Sets the hour and minute of the due time, requires unix timestamp */ function setDueTime($objIdx, $timestamp) { $this->items[$objIdx]->dueTime = $timestamp; } function getDueDay($objIdx) { return $this->items[$objIdx]->dueOffset / (60/60/24); } function getDueTime($objIdx) { return $this->items[$objIdx]->dueTime; } /** * Wrap utility function to update sequence table. */ function updateSequence($contentIds,$lobData,$type ='content') { $db = Db::getHandle(); //find content objects that we didn't recieve a checkbox for $sql = ('SELECT class_lesson_sequence_id, lob_class_repo_id FROM class_lesson_sequence WHERE lesson_id = '.$this->lessonId.' AND class_id = '.$this->classId.' AND lob_type = "'.$type.'" AND lob_class_repo_id NOT IN ('.implode(',',$contentIds).')'); //needs work to delete $deletes = array(); $db->query($sql); while ($db->nextRecord()) { $deletes[] = $db->record['class_lesson_sequence_id']; } //wipe all previous content links for this lesson if (count ($deletes) > 0 ) { $db->query('DELETE from class_lesson_sequence WHERE class_lesson_sequence_id IN ('.implode(',',$deletes).')'); } //find objects that got a checkbox but are already present in the DB $sql = ('SELECT class_lesson_sequence_id, lob_class_repo_id FROM class_lesson_sequence WHERE lesson_id = '.$this->lessonId.' AND class_id = '.$this->classId.' AND lob_type = "'.$type.'" AND lob_class_repo_id IN ('.implode(',',$contentIds).')'); $keepers = array(); $db->query($sql); while ($db->nextRecord()) { $keepers[] = $db->record['lob_class_repo_id']; } // debug($contentIds); // debug($keepers); //so we're only inserting absolutely new checkboxes, // this should keep the pkey count down significantly // over other methods of deleting all records in a table // and then adding all new records. $contentIds = array_diff($contentIds,$keepers); //one last thing, we need to find out the maximum rank in the sequence $sql = ('SELECT MAX(`rank`) as toprank FROM class_lesson_sequence WHERE lesson_id = '.$this->lessonId.' AND class_id = '.$this->classId); $db->query($sql); $db->nextRecord(); $topRank = $db->record['toprank']; //insert each new link $insert = 'INSERT INTO class_lesson_sequence (lesson_id,class_id, lob_class_repo_id, lob_type, lob_sub_type, lob_mime, lob_title, link_text, rank) VALUES (%d, %d, %d, "'.$type.'", "%s", "%s", "%s", "%s", %d)'; //debug($contentIds,1); //debug($lobData,1); foreach($contentIds as $k=>$v) { if ($v < 1 ) continue; $lob = $lobData[$v]; $topRank++; $db->query( sprintf($insert, $this->lessonId, $this->classId, $v, $lob['lob_sub_type'], $lob['lob_mime'], $lob['lob_title'], $lob['lob_urltitle'], $topRank)); } } function fetchLob() { } } --- NEW FILE: lc_lesson_xml.php --- <?php /** * Process Lesson XML formats */ class Lc_Lesson_Xml { } ?> |
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9622/lib Removed Files: lc_lesson.php lc_lesson_sequence.php lc_lob.php lc_lob_class.php lc_lob_class_test.php lc_lob_renderer.php lc_lob_test.php Log Message: Moving libraries into sub folders. --- lc_lob_class_test.php DELETED --- --- lc_lesson.php DELETED --- --- lc_lob_test.php DELETED --- --- lc_lob_class.php DELETED --- --- lc_lob_renderer.php DELETED --- --- lc_lob.php DELETED --- --- lc_lesson_sequence.php DELETED --- |