Jump to content

ivn

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by ivn

  1. Hi there, I would like to create a feature in Moodle where in the admin can create Departments, have multiple section in those departments and have many areas in those sections. These areas would eventually have members/students in them. But in this way each of my student would belong to a particular area, a section and eventually a department. I would like to assign a manager for my department, a supervisor for each of my sections and areas. Also these departments should be able to access courses and various activities within that course. Now firstly is this achieveable? Is there already a feature in Moodle which can do all of what I have said? If yes, then where? If not then where I should start building my module directory wise? Can any one give me some starting point ? Thanks in advance
  2. Setting the header right at the start would give me no output, as the values of which I want to create a bar graph is in the first part of the code. So putting the header in the start of the code just prints the url of that file back on the screen.
  3. I kind of do not have an idea how to set the MIME type. Can someone please let me know how should i do it? the code I have written over all is as follows, the first part is retrieving the values I want the graph for, the second part is creating the graph. Please go through the code nd let me know what I can do. <?php require_once("../../config.php"); require_once("lib.php"); $qval=''; $ansval=array(); $arr=array(); $options=array(); $alloptions=array(); $selectedoptions=array(); $countA=0; $countB=0; $countC=0; $countD=0; $percentA=0; $percentB=0; $percentC=0; $percentD=0; $formatA=0; $formatB=0; $formatC=0; $formatD=0; echo "HI "; $query="select c.currentquestion from {$CFG->prefix}quiz_currentquestion c where c.id=1"; $execute=get_records_sql($query); foreach($execute as $currentquestion => $execute1) { $qval=$execute1->currentquestion; echo "$qval "; } $opquery="select s.id,s.answer from {$CFG->prefix}question_states s where s.question in ($qval) and s.seq_number=1"; $opexec=get_records_sql($opquery); foreach($opexec as $answer => $opexec1) { $ansval[]=$opexec1->answer; } $n=count($ansval); echo "$n"; for($i=0;$i<$n-1;$i++) { $arr = explode(":",$ansval[$i]); $selectedoptions[$i]=$arr[1]; //echo " $selectedoptions[$i] "; } $options=explode(",",$arr[0]); $opcount=count($options); //Keeping a count of options selected by user. for($r=0;$r<$n-1;$r++) { switch($selectedoptions[$r]) { case $options[0]: $countA=$countA+1; //$percentA=$countA/$c*100; break; case $options[1]: $countB=$countB+1; //$percentB=$countB/$c*100; //$formatB=number_format($percentB, 2, '.', ''); break; case $options[2]: $countC=$countC+1; //$percentC=$countC/$c*100; //$formatC=number_format($percentC, 2, '.', ''); break; case $options[3]: $countD=$countD+1; //$percentD=$countD/$c*100; //$formatD=number_format($percentD, 2, '.', ''); break; } } $percentA=$countA/$n*100; $formatA=number_format($percentA, 2, '.', ''); $percentB=$countB/$n*100; $formatB=number_format($percentB, 2, '.', ''); $percentC=$countC/$n*100; $formatC=number_format($percentC, 2, '.', ''); $percentD=$countD/$n*100; $formatD=number_format($percentD, 2, '.', ''); //Displaying answer text for feedback table. for($p=0;$p<$opcount;$p++) { $optionquery="select a.answer from {$CFG->prefix}question_answers a where a.id in ($options[$p])"; $opanswer=get_records_sql($optionquery); foreach($opanswer as $answer => $opanswer1) { $oneoption=$opanswer1->answer; $alloptions[$p]=$oneoption; } } //Displaying the questiontext $qtextquery="select q.questiontext from {$CFG->prefix}question q where q.id in ($qval)"; $qtextanswer=get_records_sql($qtextquery); foreach($qtextanswer as $questiontext => $qtextanswer1) { $prevques=$qtextanswer1->questiontext; } echo " "; echo " Count"; echo " Q.Text Options Count % Count "; echo " $prevques"; echo " $alloptions[0] $countA $formatA %"; echo " $alloptions[1] $countB $formatB %"; echo " $alloptions[2] $countC $formatC %"; echo " $alloptions[3] $countD $formatD %"; echo ""; echo " "; $values=array($alloptions[0] => $countA, $alloptions[1] => $countB, $alloptions[2] => $countC, $alloptions[3] => $countD); $sum = array_sum($values); $height = 255; $width = 320; $im = imagecreate($width,$height); // width , height px $white = imagecolorallocate($im,255,255,255); $black = imagecolorallocate($im,0,0,0); $red = imagecolorallocate($im,255,0,0); imageline($im, 10, 5, 10, 230, $black); imageline($im, 10, 230, 300, 230, $black); $x = 15; $y = 230; $x_width = 20; $y_ht = 0; $i=0; for ($i=0;$i<9;$i++){ $y_ht = ($values[$i]/$sum)* $height; imagerectangle($im,$x,$y,$x+$x_width,($y-$y_ht),$red); imagestring( $im,2,$x-1,$y+10,$values[$i],$black); $x += ($x_width+20); } imagejpeg($im); ?>
  4. Hello I am trying to create simple bar graphs in my php file wherein in the first part of my code I am retrieving the values from the database, and based on the count of those values I want to create simple bar graph. But whenever I am trying to create a graph it throws me an junk values like this, ‰PNG ��� IHDR��@���ÿ���ýç-��� PLTEÿÿÿ���ÿ��Àɝ°���{IDATxœíα €0EÁ( {e gH¦(=!ŽâËÕÉ¥è5 @ @ @ @ @ @ @ @ w€5wyfÇ8³¸[¹"ú#~ý¡$Izׁí'š‰Óú����IEND®B`‚ Please let me know how can I solve this error and how do I create a simple bar graph based on values from database. Regards ivn
  5. Hello I have tweaked the functionality of Quiz in such a way that even if there are say 5-10 questions in a quiz, each question is displayed to the student at a time. I have not done this using the settings of "question per page" but by coding all the question ids for a particular quiz in a temporary table and displaying each question one by one from the table. Thus every time the student receives only one question on a page as set in the table, and when he refreshes the page, (staying on the same page) another question comes up. But the problem is, only the last question in the quiz gets graded after clicking on "Submit all and Finish" Maybe it is because every time the page gets refreshed, a new question loads up, and finally it only recognises that question in the end. The responses for all other questions do not get stored. Right now I am kind of clueless so as to which functions or which files I should modify in order to grade each question. Can anyone please help me with this so as to how should I get a student's response on each question Can something be done in order to save which ever option student clicks on the click event of radio button and save it is question_states or would this be fiddling around with existing functions meant for doing the same thing. Please help as I at least need a right direction to proceed in further. Regards
  6. I did try posting my question on moodle forum in Quiz section but haven't received any reply yet. But I did get a solution. Anyway Thanks for replying.
  7. Hello I am working in moodle, and basically trying to add a few features to Quiz Activity as a part of my project. Since I am novice to moodle and PHP I need some help in PHP coding. I have built a web page using "Add a resource" in moodle and I am writing the code in its view.php file. I am trying to load all question ids for a particular quiz in an array and when the page loads for the first time (view.php) I am trying to print the first two values of array as follows: Current Question displayed: array[0] and Next Question displayed: array[1] So the value at array[0] position should get stored in another temporary table called quiz_currentquestion which has a field (currentquestion). Now on click of Add button, the existing value should get deleted from quiz_currentquestion table and the new value that is the array[1] should be inserted into the table. (i.e. every time there would be just one record in quiz_currentquestion table) Thus on click of ADD button, the string being displayed on screen should get incremented. i.e. Current Question wil nw be :array[1] and Next question would print: array[2]. But on click of button, it again executes the entire code and thus the prev value doesn't get stored in the database at all. Is it something to do with submit button, or the logic written in PHP is wrong. Please let me know as I have been trying this thing since last 3 days and am clueless so as to what is the possible reason behind this. Thanks Ivn
×
×
  • Create New...